WP34s 3924 Calculation Error
|
08-27-2024, 12:43 PM
Post: #1
|
|||
|
|||
WP34s 3924 Calculation Error | |||
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) |
|||
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.)Thank you very much for your explanation. The new version is really much faster than the 3844 version, I will use the faster one. |
|||
11-13-2024, 12:19 AM
Post: #4
|
|||
|
|||
RE: WP34s 3924 Calculation Error
(09-02-2024 06:44 PM)Nigel (UK) Wrote: 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. You are right. DE algorithm does not like oscillatory integrand. It assumed transformed function is bell-shaped, then simply sum the rectangles. For this case, DE algorithm work too. It is just that software had placed a hard limit on levels deep. Note: my code changed meaning of levels, start from 1 instead of 0 --> levels = 12 get 12 rows output. lua> f = fn'x: exp(sin(x)*cos(x))' lua> ; Q.quad(f, 0, 1000, 1, 12, 1e-16, true) Code: 1103.4366650221054 0.370273314848271 Problem is this take about 2^(levels + 2) = 2^14 samples. Still, it beat Romberg by a factor of 2 lua> ; Q.integ(Q.simpson(Q.u(f, 0, 1000)), 2^15) Code: 4 865.1840001860048 299.21141073191774 col 1 = subintervals col 2 = extrapolated trapezoid areas col 3 = extrapolated rectangle areas, height = midpoint col 3 are less good, but it cost nothing to generate, and useful to cross check col 2 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)