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
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
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
 « Next Oldest | Next Newest »

 Messages In This Thread The most compact algorithm for Simpson's rule?? - Namir - 12-12-2015, 04:24 PM RE: The most compact algorithm for Simpson's rule?? - Thomas Klemm - 12-12-2015, 05:44 PM RE: The most compact algorithm for Simpson's rule?? - Namir - 12-12-2015, 08:29 PM RE: The most compact algorithm for Simpson's rule?? - Dieter - 12-12-2015, 09:16 PM RE: The most compact algorithm for Simpson's rule?? - Dieter - 12-12-2015, 09:44 PM RE: The most compact algorithm for Simpson's rule?? - Namir - 12-12-2015, 08:28 PM RE: The most compact algorithm for Simpson's rule?? - Dieter - 12-12-2015, 09:05 PM RE: The most compact algorithm for Simpson's rule?? - Namir - 12-12-2015, 10:54 PM RE: The most compact algorithm for Simpson's rule?? - Namir - 12-12-2015, 11:02 PM RE: The most compact algorithm for Simpson's rule?? - Dieter - 12-14-2015, 09:04 PM RE: The most compact algorithm for Simpson's rule?? - Namir - 12-15-2015, 12:09 AM RE: The most compact algorithm for Simpson's rule?? - Dieter - 12-15-2015 07:12 AM RE: The most compact algorithm for Simpson's rule?? - Namir - 12-13-2015, 01:52 AM RE: The most compact algorithm for Simpson's rule?? - Dieter - 12-13-2015, 01:27 PM RE: The most compact algorithm for Simpson's rule?? - Namir - 12-16-2015, 12:57 AM RE: The most compact algorithm for Simpson's rule?? - Dieter - 12-16-2015, 01:25 PM RE: The most compact algorithm for Simpson's rule?? - Namir - 12-16-2015, 01:54 PM

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