HP Forums
[WP34S] Numeric Integrator Has Max Iterations Set? - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: [WP34S] Numeric Integrator Has Max Iterations Set? (/thread-205380.html)



[WP34S] Numeric Integrator Has Max Iterations Set? - Les Wright - 11-23-2011

The subject-line query says it all.

I was fiddling around with numeric integration, and the first integral I usually attempt is the one discussed in Kahan's 1980 paper on the 34C integration (on the MoHPC DVD). Namely, we are talking the integral of the following between w=0 and w=1:

2*w^2/((w-1)*(w+1)) - w/ln(w)

The WP34S emulator is fast but it seems to top out at 7 accurate significant digits even if one sets the display to the max possible (i.e., ALL 11, FIX 11, or SCI 11).

My HP15C LE is pretty fast and gets more like 8 or 9 digits even if I use something as low as SCI 6 or SCI 7. My 35S is much slower but, still, does better than the best attainable with the 34s.

This is admittedly a challenging integral (Kahan presents it as a potentially pathological example in the aforementioned paper), but I was wondering if the programmers here limited the number of function computations in the Romberg Integration or whatever other algorithm was used.

I note that Thomas Okken, via Hugh Steers, uses Romberg Integration in Free42. Free42 gets all 12 displayed digits correct for this integral, and quickly at that.

I am very interested in numerical integration and wondering if anyone could tell me about the innards of the algorithm.

Les

P.S. I am working with 2.2, not the version 3 beta. Indeed, I don't know where to get the latter.

Edited: 23 Nov 2011, 4:01 a.m.


Re: [WP34S] Numeric Integrator Has Max Iterations Set? - Paul Dale - 11-23-2011

The 34S does not use an adaptive integration method. It doesn't deal with the difficult cases at all well.

There is a wrapper somewhere to provide some degree of adaption over the top and I've thought about implementing Romberg but haven't done it yet and might never get to it.


- Pauli

Edited: 23 Nov 2011, 5:33 a.m.


Re: [WP34S] Numeric Integrator Has Max Iterations Set? - Paul Dale - 11-23-2011

Quote:
I am very interested in numerical integration and wondering if anyone could tell me about the innards of the algorithm.

The 34S uses a 10/21 point Gauss/Kronrod quadrature. The source code is in xrom.wp34s in trunk in the source tree.

Also see pages 99 and 100 of the 2.2 manual.


- Pauli

Edited: 23 Nov 2011, 5:48 a.m.


Re: [WP34S] Numeric Integrator Has Max Iterations Set? - Les Wright - 11-23-2011

Well, Pauli, that explains perfectly the speed and the fact that the accuracy stays put irrespective of how many digits I choose to display. The algorithm only samples 31 points no matter what.

The 90 step Romberg Integration routine in the PPC module I am sure is easily adapted to the 34s, since it looks like 34s has all of the functions of the 41C series and then some. I could work on that eventually.

BTW, I recall that the TI-83 and TI-84 actually use Gauss-Kronrod but may sample more points according to desired accuracy? I can't remember--haven't touched my Tis forever.

Les


Re: [WP34S] Numeric Integrator Has Max Iterations Set? - Paul Dale - 11-23-2011

It only performs 21 function evaluations. Gauss/Kronrod quadratures share the points between the two methods. A major aspect of their appeal.

The PPC Romberg routine would port easily -- when I wrote the integration code several years ago, I had exactly five registers to work with. Romberg was simply not possible in so few. This is a limitation of the internal keystroke programming model. Thus, the 2.x firmware will never get an adaptive built in integrator. However, check out Miguel Toro's integration wrapper for a way to use the internal integration somewhat adaptively.

With the 3.x firmware, we have dynamically allocated local registers and it would be possible to use the PPC routine as the basis of the internal integration function. It will still need quite some reworking to make it behave exactly like the built in command must (near enough isn't acceptable for this unfortunately).

Time is my issue :-( The current integrator works okay mostly, I've better things to do at the moment than recode it. Maybe eventually.


- Pauli


Re: [WP34S] Numeric Integrator Has Max Iterations Set? - Miguel Toro - 11-23-2011

Hi,

The wrapper is in the Article section.

Regards,

Miguel


Re: [WP34S] Numeric Integrator Has Max Iterations Set? - Les Wright - 11-23-2011

Quote:
Hi,

The wrapper is in the Article section.

Regards,

Miguel


Miguel, this is a great routine. I may tweak it a bit so that the desired accuracy can be entered directly, like we do with the 42s or Free42, rather than inferred from the number of digits in SCI, FIX, ALL, etc.

It isn't an adaptive routine like Richardson extrapolation, but it still is quite fast on what is a very fast calculator. I like it just fine. Thank you!

Les