▼
Posts: 3,283
Threads: 104
Joined: Jul 2005
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?
▼
Posts: 203
Threads: 29
Joined: Nov 2009
50g seems to hang although I only waited about a minute on
'Integral(0,0,INV(X),X)'
From inside equation writer, entered the integral, highlighted the whole thing and got + Infinity very quickly.
▼
Posts: 3,283
Threads: 104
Joined: Jul 2005
Quote:
Integral(0,0,INV(X),X)
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.
▼
Posts: 1,830
Threads: 113
Joined: Aug 2005
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?
▼
Posts: 3,229
Threads: 42
Joined: Jul 2006
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
Posts: 325
Threads: 18
Joined: Jul 2006
My 50g hits the limit of 65535 function evaluations and returns a result of 22.8202972649 with IERR of 2.22365339103E10 .
I don't have my 15C+ with me, but I believe it will hit its limit at 16383 function evaluations.
▼
Posts: 3,283
Threads: 104
Joined: Jul 2005
From a recent mail from Pauli:
Quote:
The integrator does 8191 function evaluations maximum now.
▼
Posts: 3,229
Threads: 42
Joined: Jul 2006
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
▼
Posts: 3,283
Threads: 104
Joined: Jul 2005
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 crystalless 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.
Posts: 97
Threads: 9
Joined: Nov 2011
Hello folks,
my hp 50g shows an astonishing behavier:
If I start in exact mode with:
for example
4: 192E14
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.
Sincerely
peacecalc
Edited: 19 Jan 2012, 4:45 p.m.
Posts: 97
Threads: 9
Joined: Nov 2011
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.
Sincerely
peacecalc
▼
Posts: 325
Threads: 18
Joined: Jul 2006
Quote:
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
<< 'C' INCR DROP INV >>
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
LBL A
1
STO+ 0
x<>y
/
RTN
▼
Posts: 97
Threads: 9
Joined: Nov 2011
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.
Sincerely
peacecalc
Edited: 20 Jan 2012, 8:29 a.m.
Posts: 325
Threads: 18
Joined: Jul 2006
The 15C+ takes about an hour and a half to hit its limit of 65535 evaluations.
Posts: 239
Threads: 9
Joined: Dec 2010
ND1: << 0 1 '1/x' 'x' Integral >> => bad argument [no wait time]
WA: integrate 1/x from 0 to 1 => (integral does not converge)
Edited: 19 Jan 2012, 1:33 p.m.
▼
Posts: 3,283
Threads: 104
Joined: Jul 2005
Has ND1 a CAS of some sort?
▼
Posts: 239
Threads: 9
Joined: Dec 2010
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 12 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...
▼
Posts: 3,283
Threads: 104
Joined: Jul 2005
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?
▼
Posts: 239
Threads: 9
Joined: Dec 2010
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).
Posts: 2,761
Threads: 100
Joined: Jul 2005
HP42S: 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.92e12).
Posts: 1,755
Threads: 112
Joined: Jan 2005
Hi, Marcus:
For the HP71B, you get in a short while:
> INTEGRAL(0,1,0,1/IVAR)
22.8202902142
> IBOUND
2.22365339102E11
where the negative IBOUND means the specified precision (1E12) wasn't achieved. Conversely:
> INTEGRAL(1,2,0,1/IVAR)
.69314718056
> LN(2)
.69314718056
>IBOUND
6.93146313016E13
in a few seconds (positive IBOUND, so 12 digits were indeed achieved).
Best regards from V.
▼
Posts: 3,229
Threads: 42
Joined: Jul 2006
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
▼
Posts: 1,755
Threads: 112
Joined: Jan 2005
Quote:
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 HP71B does a maximum of 65,535 function evaluations, which can be simply demonstrated like this:
>LIST
10 DEF FNF(X) @ N=N+1 @ FNF=1/X @ END DEF
20 N=0 @ DISP INTEGRAL(0,1,0,FNF(IVAR)),N
>RUN
22.8202902142 65535
Best regards from V.
Posts: 256
Threads: 4
Joined: Sep 2007
Marcus, my TI83+SE gives the error message "TOL NOT MET" within 10 seconds.
Regards,
John
Posts: 125
Threads: 5
Joined: Jun 2008
TINSpire CX CAS gave infinity immediately.
▼
Posts: 3,283
Threads: 104
Joined: Jul 2005
Can you try in approximate mode again?
▼
Posts: 125
Threads: 5
Joined: Jun 2008
I'll try and get back to you soon.
TI85 and TI86 gave "ERROR 33 TOL NOT MET" after about 40 seconds.
FX4500P returned "Ma ERROR" immediately.
Edited: 20 Jan 2012, 5:00 a.m.
Posts: 125
Threads: 5
Joined: Jun 2008
It gave the same result immediately.
Edited: 20 Jan 2012, 5:08 a.m.
