• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            牽著老婆滿街逛

            嚴以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            Blitz++ 計算二階導數

            // 整理?by?RobinKin

            #include?
            < blitz / vector.h >

            using ? namespace ?blitz;

            int ?main()
            {
            ????
            // ?In?this?example,?the?function?cos(x)^2?and?its?second?derivative
            ????
            // ?2?(sin(x)^2?-?cos(x)^2)?are?sampled?over?the?range?[0,1).
            ????
            // ?The?second?derivative?is?approximated?numerically?using?a
            ????
            // ?[?1?-2??1?]?mask,?and?the?approximation?error?is?computed.

            /* ?cos(x)^2??的二階導數?是2?(sin(x)^2?-?cos(x)^2)

            下面在[0,1)?的范圍中,以delta為步長?,用[?1?-2??1?]?的方法計算二階導數

            看看和精確值的誤差
            */



            ????
            const ? int ?numSamples? = ? 100 ;?????????????? // ?Number?of?samples
            ???? double ?delta? = ? 1 .? / ?numSamples;?????????? // ?Spacing?of?samples
            ????Range?R( 0 ,?numSamples? - ? 1 );?????????????? // ?Index?set?of?the?vector

            ????
            // ?Sample?the?function?y?=?cos(x)^2?over?[0,1)
            ????
            //
            ????
            // ?An?object?of?type?Range?can?be?treated?as?a?vector,?and?used
            ????
            // ?as?a?term?in?vector?expressions.
            ????
            //
            ????
            // ?The?initialization?for?y?(below)?will?be?translated?via?expression
            ????
            // ?templates?into?something?of?the?flavour
            ????
            //
            ????
            // ?for?(unsigned?i=0;?i?<?99;?++i)
            ????
            // ?{
            ????
            // ?????double?_t1?=?cos(i?*?delta);
            ????
            // ?????y[i]?=?_t1?*?_t1;
            ????
            // ?}
            ????
            ????Vector
            < double > ?y? = ?sqr(cos(R? * ?delta));

            ????
            // ?Sample?the?exact?second?derivative
            ????Vector < double > ?y2exact? = ? 2.0 ? * ?(sqr(sin(R? * ?delta))? - ?sqr(cos(R? * ?delta)));

            ????
            // ?Approximate?the?2nd?derivative?using?a?[?1?-2??1?]?mask
            ????
            // ?We?can?only?apply?this?mask?to?the?elements?1?..?98,?since
            ????
            // ?we?need?one?element?on?either?side?to?apply?the?mask.
            ????Range?I( 1 ,numSamples - 2 );
            ????Vector
            < double > ?y2(numSamples);

            ????y2(I)?
            = ?(y(I - 1 )? - ? 2 ? * ?y(I)? + ?y(I + 1 ))? / ?(delta * delta);
            ??
            ????
            // ?The?above?difference?equation?will?be?transformed?into
            ????
            // ?something?along?the?lines?of
            ????
            //
            ????
            // ?double?_t2?=?delta*delta;
            ????
            // ?for?(int?i=1;?i?<?99;?++i)
            ????
            // ?????y2[i]?=?(y[i-1]?-?2?*?y[i]?+?y[i+1])?/?_t2;
            ?
            ????
            // ?Now?calculate?the?root?mean?square?approximation?error:

            ????
            double ?error? = ?sqrt(mean(sqr(y2(I)? - ?y2exact(I))));
            ?
            ????
            // ?Display?a?few?elements?from?the?vectors.
            ????
            // ?This?range?constructor?means?elements?1?to?91?in?increments
            ????
            // ?of?15.
            ????Range?displayRange( 1 ,? 91 ,? 15 );
            ?
            ????cout?
            << ? " Exact?derivative: " ? << ?y2exact(displayRange)? << ?endl
            ?????????
            << ? " Approximation:??? " ? << ?y2(Range(displayRange))? << ?endl
            ?????????
            << ? " RMS?Error:??????? " ? << ?error? << ?endl;

            ????
            return ? 0 ;
            }



            Output:

            Exact?derivative:[????
            - 1.9996 ?? - 1.89847 ?? - 1.62776 ?? - 1.21164 ? - 0.687291 ? - 0.1015495
            ???]
            Approximation:???[???
            - 1.99953 ?? - 1.89841 ??? - 1.6277 ??? - 1.2116 ? - 0.687269 ? - 0.1015468
            ???]
            RMS?Error:???????
            4.24826e-05

            posted on 2006-07-01 13:23 楊粼波 閱讀(703) 評論(0)  編輯 收藏 引用

            九九久久99综合一区二区| 久久青青草原精品国产软件| av无码久久久久不卡免费网站| 久久精品www人人爽人人| 狠狠色丁香婷婷综合久久来| 青春久久| 久久99国产精一区二区三区| 国产精品久久久久蜜芽| 久久国产亚洲精品麻豆| 一本久道久久综合狠狠躁AV| aaa级精品久久久国产片| 久久性生大片免费观看性| 久久人爽人人爽人人片AV| 久久99热这里只有精品国产| 久久久久亚洲AV无码网站| 思思久久99热只有频精品66| 亚洲国产精品婷婷久久| 久久亚洲中文字幕精品有坂深雪 | 久久99精品国产99久久6男男| 久久久国产精品| 曰曰摸天天摸人人看久久久| 中文字幕无码精品亚洲资源网久久| 国产午夜电影久久| www久久久天天com| 久久久久久国产精品免费无码| 久久亚洲高清综合| 久久精品国产99久久香蕉| 精品久久久久久亚洲| 久久精品国产亚洲AV无码偷窥 | 精品多毛少妇人妻AV免费久久| 久久久久亚洲AV无码网站| 亚洲va国产va天堂va久久| 久久这里只有精品首页| 2021国产精品久久精品| 久久99这里只有精品国产| 怡红院日本一道日本久久| 久久久国产精品福利免费 | 亚洲午夜福利精品久久| 亚洲国产日韩欧美综合久久| 亚洲&#228;v永久无码精品天堂久久| 久久综合狠狠色综合伊人|