I've stumbled across a problem with the Romberg integrator in WP 34S. Just as a test if I had made a mess of the firmware again - quite a common situation in the last few weeks - I started with the integral from 0 to 1 of 1/x. This is infinite but the poor calculator was busily trying to approximate the result until the algorithm failed with a programming error (register limit exceeded).

We tackled the problem by limiting the number of iterations and now the device gives up after a few minutes (a few seconds on the emulator).

I then tried the same with my 15C LE in FIX 4 mode: After 15 minutes or more the display still showed "running" and I stopped it to save on the batteries. My question is, how do other incarnations of the integrate function fare on this task?


50g seems to hang although I only waited about a minute on

From inside equation writer, entered the integral, highlighted the whole thing and got + Infinity very quickly.



I assume you mean Integral(0,1,INV(X),X).

The immediate return with +infinity may be a result of the CAS knowing that the indefinite integral of 1/x is lnx which evaluates to infinity on the lower bound.


If you are gong to special case the integral for the purpose of limiting the iterations, why not do what the 50G does and shortcut the processing up front? Am I misunderstanding what's happening in your code?


We don't and won't do symbolic integration. It looks like the 50G knows that the integral of 1/x dx is Ln(x) and it is using that to short cut the evaluation.

- Pauli


My 50g hits the limit of 65535 function evaluations and returns a result of 22.8202972649 with IERR of -2.22365339103E-10 .

I don't have my 15C+ with me, but I believe it will hit its limit at 16383 function evaluations.


From a recent mail from Pauli:

The integrator does 8191 function evaluations maximum now.


This is more a bug on my part -- it does 8191 evaluations but only the first 4096 are actually used. The "we've been going too long and need to stop test" is done too late.

We can set this iteration limit to any power of two we want and I will look into the earlier termination.

- Pauli


I can't see the bug Pauli mentioned but I have increased the limit to 16383 again which is good for just below 5 minutes of execution time for 1/x (timed on my crystal-less 20b with TICKS). When the integrator is called from the keyboard it will show a progress message.

In a prior version I had added an exit similar to SLV ("Solution not Found") and a skip next instruction return. It's back to how it was. Convergence can be easily tested with an x[approx]? Y test in a program or by manually comparing the values in x and y.

Edited for typos.

Edited: 20 Jan 2012, 12:00 p.m.


Hello folks,

my hp 50g shows an astonishing behavier:

If I start in exact mode with:
for example

4: 192E-14

3: 1

2: '1/X'

1: X

Start with the integration symbol (RS Integral symbol), I get the question: approx. mode on? I answer: yes and I get immediatly the
integration value: 2,6979E1

If I start within the approximation mode with the "same" (of course they are not interpretated as exact values) input numbers, I have to wait for the result some minutes.

This looks like a good work around against a long integration duration: just start in exact mode.


Edited: 19 Jan 2012, 4:45 p.m.


Hello Kiyoshi Akima,

where on the calc hp 50g you can see how many times the function is calculated for the integration? The "IERR" variable I've already found.



where on the calc hp 50g you can see how many times the function is calculated for the integration? The "IERR" variable I've already found.

Rather than integrating the program

<< INV >>
I merely integrate the program
with the global variable 'C' set to some known initial value.

The same thing can be done on RPN machines by including something along the lines of ISG 0 in the function, followed by a NOP if necessary. For this particular problem, another possible coding would be

STO+ 0


Hello Kiyoshi Akima,

thanx for your fast reply. The little proggie only works in approxmation mode.

I have a theory why the calculation works better in exact mode.
The calc find the antiderivate, but cannot express it with the boundaries, so the calc forced the user to switch to approximation mode. That is shurly faster then the pure approximation.


Edited: 20 Jan 2012, 8:29 a.m.


The 15C+ takes about an hour and a half to hit its limit of 65535 evaluations.


ND1: << 0 1 '1/x' 'x' Integral >> => bad argument [no wait time]

W|A: integrate 1/x from 0 to 1 => (integral does not converge)

Edited: 19 Jan 2012, 1:33 p.m.


Has ND1 a CAS of some sort?


The currently released version has no CAS.

ND1 (and ND0, the free version) can do numeric integration, deal with algebraic expressions (by themselves or in vectors/matrices), has PEVAL, can use OBJ-> to "unpeel" expressions, and can do some things like prime factorization, BigInts, and other stuff listed by the 50g AUR in CAS section.

The last couple of months, I've been working on integrating with a commercial CAS, which will become available within 1-2 months. (Beta testers wanted.)

Details are being finalized, but I'll be very excited when I can make the announcement. It's not just any CAS...


How does ND1 then find out about the integral being infinite? Or is this just a failure because it attempts to evaluate the function at its endpoints?


Sorry, I didn't pick up on your question.

To avoid singularities, the endpoints are never evaluated.

In this specific case, an overflow in the interior of the interval is causing NaN values, which leads to the reported error (which should be changed to something more appropriate).


HP-42S: It was still 'Integrating' when I stopped it after thirty minutes. (ACC=0.0001)

Free42 Decimal v1.4.62: 26.97737115553 (ACC<=0.0001). (This corresponds to a lower limit of about 1.92e-12).


Hi, Marcus:

For the HP-71B, you get in a short while:

> INTEGRAL(0,1,0,1/IVAR)




where the negative IBOUND means the specified precision (1E-12) wasn't achieved. Conversely:
> INTEGRAL(1,2,0,1/IVAR)


> LN(2)




in a few seconds (positive IBOUND, so 12 digits were indeed achieved).

Best regards from V.


I think we can work out the maximum number of iterations each integrator uses based on the result of this integral. At least the results being mentioned look rather close to some of those I got with larger iteration limits.

- Pauli


I think we can work out the maximum number of iterations each integrator uses based on the result of this integral.

It's well known that the modified iterative Romberg algorithm as implemented in the HP-71B does a maximum of 65,535 function evaluations, which can be simply demonstrated like this:


10 DEF FNF(X) @ N=N+1 @ FNF=1/X @ END DEF


22.8202902142 65535

Best regards from V.


Marcus, my TI83+SE gives the error message "TOL NOT MET" within 10 seconds.




TI-NSpire CX CAS gave infinity immediately.


Can you try in approximate mode again?


I'll try and get back to you soon.

TI-85 and TI-86 gave "ERROR 33 TOL NOT MET" after about 40 seconds.

FX-4500P returned "Ma ERROR" immediately.

Edited: 20 Jan 2012, 5:00 a.m.


It gave the same result immediately.

Edited: 20 Jan 2012, 5:08 a.m.

Possibly Related Threads...
Thread Author Replies Views Last Post
  Integration question and "RPN" mode comment Craig Thomas 16 4,024 12-05-2013, 02:32 AM
Last Post: Nick_S
  WP34s integration trapped in infinite loop Bernd Grubert 25 4,744 10-17-2013, 08:50 AM
Last Post: Dieter
  HP Prime integration Richard Berler 1 895 10-06-2013, 10:52 PM
Last Post: Helge Gabert
  integration on 39gII emulator Wes Loewer 29 5,130 06-07-2013, 05:58 PM
Last Post: Chris Smith
  WP-34S Integration Richard Berler 15 2,722 03-08-2013, 02:29 AM
Last Post: Walter B
  HP 34S integration Richard Berler 16 2,852 02-18-2013, 04:42 PM
Last Post: Marcus von Cube, Germany
  [WP34S] Speeding up the Romberg Integration Les Wright 14 2,720 05-31-2012, 03:39 PM
Last Post: Marcus von Cube, Germany
  New variant for the Romberg Integration Method Namir 8 1,947 04-18-2012, 07:47 AM
Last Post: Nick_S
  Romberg Integration for 33s, 35s Matt Agajanian 9 1,880 03-26-2012, 10:00 AM
Last Post: Nick_S
  HP 32sII Integration Error of Standard Normal Curve Anthony (USA) 4 1,133 03-14-2012, 03:18 AM
Last Post: Nick_S

Forum Jump: