How accurate is the numerical integrator, cumtrapz?

5 ビュー (過去 30 日間)
Noob
Noob 2017 年 6 月 11 日
編集済み: Noob 2017 年 6 月 19 日
How accurate is the numerical integrator, cumtrapz?

採用された回答

Walter Roberson
Walter Roberson 2017 年 6 月 11 日
編集済み: Walter Roberson 2017 年 6 月 11 日
There is no bound to the error of cumtrapz()
Consider f = x^3-sin(x) over 0 to 5, with step size 1/1000, then the numeric error from the trapazoid rule is about 6E-6.
Now consider f = 1000*cot(Pi*x-2) over 0 to 1/2, with step size 1/1000, then the numeric error from the trapazoid rule is about 1E-4 . This is 1/10th of the range that produced the 6E-6 error for the first function, so if it were range alone that made the difference than you would expect around 6E-7 error. If you were to then examine and say "Oh but the multiplier is 1000 times more" then that would at get you to about 6E-4 error, more than the 1E-4 observed. We can thus determined that there must be more factors than just constant multipliers or length of the range: the numeric error must depend upon the shape of the function itself.
Now consider f = cot(Pi*x-2) over 0 to 5, with step size 1/1000, then the numeric error from the trapazoid rule is undefined, as the calculation would involve adding values that range from -inf to +inf and adding -inf to +inf is undefined. So it definitely depends upon the function being evaluated.
You can calculate the error symbolically. The trapazoid rule estimate of the integral of F from A to B step size H is
(symsum(F(k*H), k, 1, B/H-1)+(1/2)*F(A)+(1/2)*F(B))*H
from which you can subtract int(F,A,B) to get the error.
  1 件のコメント
Stephen23
Stephen23 2017 年 6 月 11 日
編集済み: Stephen23 2017 年 6 月 11 日
+1 maths wins again :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by