필터 지우기
필터 지우기

How accurate is the numerical integrator, cumtrapz?

조회 수: 3 (최근 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 CenterFile Exchange에서 Numerical 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