• <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)  編輯 收藏 引用

            欧美亚洲国产精品久久| 91精品国产高清久久久久久91| 77777亚洲午夜久久多人| 国产ww久久久久久久久久| 日产精品久久久一区二区| 亚洲国产成人久久一区WWW| 久久精品国产欧美日韩| 久久不见久久见免费影院www日本| 精品久久久久久亚洲| 久久99精品国产99久久6男男| 久久综合给合久久国产免费| 久久久婷婷五月亚洲97号色| 久久久久亚洲精品天堂| 2020久久精品国产免费| 久久国产乱子伦精品免费强| 国产成人精品久久亚洲高清不卡| 999久久久国产精品| 日韩AV毛片精品久久久| 欧美午夜精品久久久久久浪潮| 国产精品99久久久久久宅男小说| 久久天天躁夜夜躁狠狠| 久久A级毛片免费观看| 91精品国产综合久久香蕉| 久久精品国产国产精品四凭 | 香蕉久久一区二区不卡无毒影院 | 久久只这里是精品66| 漂亮人妻被黑人久久精品| 99久久国产综合精品成人影院 | 91精品国产91久久久久久蜜臀| 精品久久国产一区二区三区香蕉| 少妇人妻综合久久中文字幕| 99久久无码一区人妻a黑| 久久久久这里只有精品| 久久亚洲春色中文字幕久久久| 亚洲国产精品久久久久久| 青青草原综合久久大伊人导航 | 久久久久久久久无码精品亚洲日韩| 国产精品激情综合久久| 日韩精品久久久久久免费| 亚洲国产精品成人AV无码久久综合影院 | 99久久精品国产综合一区 |