Post Reply 
The most compact algorithm for Simpson's rule??
12-15-2015, 07:12 AM (This post was last modified: 12-15-2015 07:30 AM by Dieter.)
Post: #14
RE: The most compact algorithm for Simpson's rule??
(12-15-2015 12:09 AM)Namir Wrote:  To get good results the value of N has to be high. In this case one more call to f(x) does not make much of a difference. By contrast, saving one call to f(x) when N is low is not to help reducing the error.

Sorry, if I'm a bit stubborn here, but the question is not whether one more call hurts or not, but where is the benefit of modifiying the original method so that another call is required, so that a value is added to the sum and subtracted again to compensate this error. One could just as well work with factors 8 and 4 instead of 4 and 2 and apply a correction by a factor of 0,5 afterwards. Doesn't make much sense either. ;-)

As far as accuracy is concerned: The error of Simpson's rule (or: Kepler's, to be more precise) can be estimated quite well. Here a method similar to the Romberg scheme can be applied: Calculate the integral for n and 2n intervals, then determine an extrapolated result via (16·I2n – In)/15. This way an accuracy is achieved that is comparable to a Simpson approximation with a much higher number of iterations.

Example 1:
f(x) = 1/x, a=1, b=2
Exact integral = ln 2 = 0,6931471806

Result for n=24: I = 0,6931472743...
Result for n=48: I = 0,6931471864...
Extrapolation: I = 0,6931471806

A comparable accuracy would require a simple Simpson approximation with n=150...200.

Example 2:
f(x) = sin(x), a=0, b=Pi
Exact integral = 2

Result for n=40: I = 2,000000423...
Result for n=80: I = 2,000000026...
Extrapolation: I = 2,0000000000

A comparable accuracy would require a simple Simpson approximation with n=500.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: The most compact algorithm for Simpson's rule?? - Dieter - 12-15-2015 07:12 AM



User(s) browsing this thread: 1 Guest(s)