The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

WP-34S Integration
Message #1 Posted by Richard Berler on 6 Mar 2013, 12:46 p.m.

Just curious (I love the 34S). When integrating a definite integral from 0 to pi the function (3/(2-cos(x))^2 , the 34S takes a long time to converge on ~10.88. On my HP 15C Limited Edition, the same integral produces the correct result almost immediately.

f LBL 1 3 ENTER 2 Roll up COS - / 2 Y^x RTN

Why is this?

By the way, thanks for the answer concerning setting "dx" interval from default value!

      
Re: WP-34S Integration
Message #2 Posted by Walter B on 6 Mar 2013, 1:31 p.m.,
in response to message #1 by Richard Berler

Quote:
When integrating a definite integral from 0 to pi the function (3/(2-cos(x))^2 , the 34S takes a long time to converge on ~10.88. On my HP 15C Limited Edition, the same integral produces the correct result almost immediately.
f LBL 1
3
ENTER
2
Roll up
COS
-
/
2
Y^x
RTN
Why is this?
First, the formatting is due to the "preformatted" button here ;-)

Second, with ALL 00 set, your integral takes some seconds to return 10.8827961854 on my WP 34S v3.2 build 3363. When I replace the last three steps by x^2 RTN, it runs a bit faster. When I replace build 3363 with v2.2 build 2738, it runs significantly faster (<2s). Seems the price for having a lot of free space in flash memory.

d:-/

            
Re: WP-34S Integration
Message #3 Posted by Gerson W. Barbosa on 6 Mar 2013, 11:09 p.m.,
in response to message #2 by Walter B

ALL 00   RAD

f LBL 01 3 ENTER 2 Roll up COS - / x^2 RTN / 0 pi g | 01 --> 9.19705925621 (after 25 minutes) /

V3.2r3371 here. The exact result is 2*pi*sqrt(3) = 10.8827961854. I wonder what I'm doing wrong.

                  
Re: WP-34S Integration
Message #4 Posted by Walter B on 7 Mar 2013, 2:32 a.m.,
in response to message #3 by Gerson W. Barbosa

Olá Gerson,

my WP 34S v3.2 b3363 takes ~15s for the integral using the program you listed and returns the correct result. The emulator b3371 returns the result you got. This points to a bug introduced recently! We'll take care of it.

d:-/

                        
Re: WP-34S Integration
Message #5 Posted by Paul Dale on 7 Mar 2013, 3:47 a.m.,
in response to message #4 by Walter B

Found the problem and committed the fix. Build will have to wait for Marcus since I can't access the build server at present. In the meantime, begin your routine with FILL and all will be happy again.

- Pauli

                              
Re: WP-34S Integration
Message #6 Posted by Gerson W. Barbosa on 7 Mar 2013, 5:04 a.m.,
in response to message #5 by Paul Dale

Thank you, Walter and Paul. I remember the built-in FILL was missing in SSIZE8, but not in SSIZE4 mode, according to a recent discussion. With the workaround I get a result correct to 15 digits in about 10 seconds.
Amazing Bug-fixing Department! :-)

Gerson.

                                    
Re: WP-34S Integration
Message #7 Posted by Paul Dale on 7 Mar 2013, 5:05 a.m.,
in response to message #6 by Gerson W. Barbosa

The built in fill went missing for all stack sizes :-(

- Pauli

                              
Re: WP-34S Integration
Message #8 Posted by Richard Berler on 7 Mar 2013, 2:19 p.m.,
in response to message #5 by Paul Dale

Thanks for the "FILL"! Now the integration is fast!

                                    
Re: WP-34S Integration
Message #9 Posted by Paul Dale on 7 Mar 2013, 2:48 p.m.,
in response to message #8 by Richard Berler

I'd be more concerned that the integration is again correct.

- Pauli

                                          
Re: WP-34S Integration
Message #10 Posted by Richard Berler on 7 Mar 2013, 3:17 p.m.,
in response to message #9 by Paul Dale

Correct and fast!

Do any other built in functions require the FILL command?

This forum is quite a neat resource!

                                                
Re: WP-34S Integration
Message #11 Posted by Paul Dale on 7 Mar 2013, 3:52 p.m.,
in response to message #10 by Richard Berler

Solve, f', f", product and sum will require the workaround. At least until the latest firmware is installed.

- Pauli

                                                      
Re: WP-34S Integration
Message #12 Posted by Walter B on 8 Mar 2013, 2:32 a.m.,
in response to message #11 by Paul Dale

Said workaround is required no longer - build 3376 works as advertised.

d:-)

            
Re: WP-34S Integration
Message #13 Posted by Paul Dale on 6 Mar 2013, 11:19 p.m.,
in response to message #2 by Walter B

Quote:
When I replace build 3363 with v2.2 build 2738, it runs significantly faster (<2s). Seems the price for having a lot of free space in flash memory.

This is not the reason at all. The algorithms used by the two different integration routines are completely different. Version 2.2 firmware uses a non-adaptive Gauss-Kronrod quadrature. Version 3 uses an adaptive Romberg method. The former makes exactly 21 function evaluations and returns its result. The latter can do hundreds or thousands of function evaluations.

For well behaved, relatively smooth functions the Gauss-Kronrod method is better -- it is exact for polynomials of degree 20 or less (forget the precise order). For less well behaved functions, Romberg is better. As usual things are a trade off.

The space saving changes essential to version 3 firmware have not created orders of magnitude of performance loss. Sure, they slow things down but not nearly by as much as you see here.

- Pauli

Edited: 7 Mar 2013, 5:09 a.m.

                  
Re: WP-34S Integration
Message #14 Posted by Marcus von Cube, Germany on 7 Mar 2013, 12:56 p.m.,
in response to message #13 by Paul Dale

Built and released...

                        
Re: WP-34S Integration
Message #15 Posted by Gerson W. Barbosa on 7 Mar 2013, 9:01 p.m.,
in response to message #14 by Marcus von Cube, Germany

The emulator says release 3375, yet calculator shows it's still 3371 (using calc_ir_full.bin here).

                              
Re: WP-34S Integration
Message #16 Posted by Walter B on 8 Mar 2013, 2:29 a.m.,
in response to message #15 by Gerson W. Barbosa

Works now with build 3376.

d:-)


[ Return to Index | Top of Index ]

Go back to the main exhibit hall