Simpson revival
|
09-28-2016, 10:00 PM
(This post was last modified: 09-28-2016 10:46 PM by Dieter.)
Post: #6
|
|||
|
|||
RE: Simpson revival
(09-28-2016 03:50 PM)Namir Wrote: Version 1 gave better results. These results seem counter intuitive, since I expected version 2 to give a better final result. I am not sure how your code works in detail, but here is an example to compare with. Edit: I think I now know where your error is. The improved result is calculated from the previous (W) and current (Z) Simpson approximation. But in your second program W is replaced with the last improved approximation, cf. line 160. So the next improved value is calculated from the the previous improved value and the current Simpson approximation. Here seems to be the problem. You must not overwrite W. Leave it as it is and only print/display the improved value. Or, even better, calculate the previous and current improved approximations WI and ZI and stop the iteration as soon as these agree within the specified tolerance. Finally, here is my example: Let f(x) = 1/x and integrate it from 1 to 2. The exact result, rounded to 12 digits, is ln(2)=0,693147180560. Code: n Standard Simpson Error Improved Error The "improved" column holds the extrapolated results, i.e. [16*Simpson(a, b, n) – Simpson(a, b, n/2)] / 15. The "Error" columns show the absolute error of the calculated integrals. You can see that the "improved" values are roughly as accurate as the standard Simpson results with twice the number of intervals, and sometimes even better. From step to step the error of the standard method improves by a factor approaching 16, while it's finally factor 64 for the improved method. Here is the VBA code I used to calculate Simpson(1, 2, n): Code: Function Simpson(a, b, n) What results do you get? Dieter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Simpson revival - Pekis - 09-28-2016, 08:04 AM
RE: Simpson revival - Namir - 09-28-2016, 10:40 AM
RE: Simpson revival - Dieter - 09-28-2016, 12:25 PM
RE: Simpson revival - Namir - 09-28-2016, 02:00 PM
RE: Simpson revival - Namir - 09-28-2016, 03:50 PM
RE: Simpson revival - Dieter - 09-28-2016 10:00 PM
RE: Simpson revival - Albert Chan - 07-31-2018, 02:57 PM
RE: Simpson revival - Namir - 09-29-2016, 04:44 PM
RE: Simpson revival - Dieter - 09-29-2016, 06:23 PM
RE: Simpson revival - Namir - 09-29-2016, 10:27 PM
RE: Simpson revival - Dieter - 09-30-2016, 06:00 AM
RE: Simpson revival - Dieter - 10-02-2016, 03:29 PM
RE: Simpson revival - Namir - 10-02-2016, 04:48 PM
RE: Simpson revival - Namir - 10-09-2016, 03:14 AM
RE: Simpson revival - Albert Chan - 08-04-2018, 05:29 PM
|
User(s) browsing this thread: 1 Guest(s)