Post Reply 
WP34s 3924 Calculation Error
08-27-2024, 12:43 PM
Post: #1
WP34s 3924 Calculation Error
the 3924 is wrong        
the 3844 is right        
Find all posts by this user
Quote this message in a reply
09-02-2024, 06:44 PM
Post: #2
RE: WP34s 3924 Calculation Error
The different results given by v3844 and v3924 are due to the change in the integration algorithm used, which happened in v3893. Before that the Romberg method was used; the current code uses the Double Exponential method. (If you wish you can read about this here.)

For many integrals the new method is quicker and more accurate. It is particularly good when there is an integrable singularity at either end of the interval of integration. However it is less good when integrating functions that vary periodically many times over the interval, which is the case for your integral.

Of course, since your integrand is periodic it’s easy to evaluate it by integrating over one cycle, multiplying by the number of complete cycles, and then adding the result of integrating over the final partial cycle. In general this won’t be possible and you will have to be content with spotting the sorts of integrand that are likely to give problems.

I don’t know an integration method which is superior to all other methods for all types of integrand. The double exponential method is good but - as your example shows - not perfect. It would be possible to re-include the Romberg code in addition to the new code - what do you think? How much code space would it be worth sacrificing for this?

Nigel (UK)
Find all posts by this user
Quote this message in a reply
09-03-2024, 10:45 AM
Post: #3
RE: WP34s 3924 Calculation Error
(09-02-2024 06:44 PM)Nigel (UK) Wrote:  The different results given by v3844 and v3924 are due to the change in the integration algorithm used, which happened in v3893. Before that the Romberg method was used; the current code uses the Double Exponential method. (If you wish you can read about this here.)

For many integrals the new method is quicker and more accurate. It is particularly good when there is an integrable singularity at either end of the interval of integration. However it is less good when integrating functions that vary periodically many times over the interval, which is the case for your integral.

Of course, since your integrand is periodic it’s easy to evaluate it by integrating over one cycle, multiplying by the number of complete cycles, and then adding the result of integrating over the final partial cycle. In general this won’t be possible and you will have to be content with spotting the sorts of integrand that are likely to give problems.

I don’t know an integration method which is superior to all other methods for all types of integrand. The double exponential method is good but - as your example shows - not perfect. It would be possible to re-include the Romberg code in addition to the new code - what do you think? How much code space would it be worth sacrificing for this?

Nigel (UK)
Thank you very much for your explanation. The new version is really much faster than the 3844 version, I will use the faster one.
Find all posts by this user
Quote this message in a reply
Post Reply 




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