WP34S: An integration wrapper



#12

Another week-end little project.

As suggested by the WP34s team on a older post, I tried to make a wrapper to improve accuracy for the integration function.

A test with sqrt(abs(x-1)), from 0 to 2, gives:

WP 34s : 1.30929962
WP 34s with the wrapper (fix 5) : 1.33333672

Expected : 4/3

Using this program:

LBL 10
1
-
ABS
[sqrt]
RTN

Any comment to improve it as always very welcome.

Miguel


Edited: 9 Oct 2011, 11:04 p.m.


#13

Hi Miguel!

Try it on these expressions from the PPC ROM examples:

Dropbox link to IG results


#14

Hi Gene,

Here are the results. Not so bad, I think. Function 10, takes too long, so I ran it with FIX 3. Against my own advice, the others where done with FIX 6, getting decent running times.

1:	3.141593
2: 0.666667
3: 0.636620
4: -0.999984
6: 3.141594
8: 0.499995
9: 1.991321
10: 0.785399 FIX 3 (too slow otherwise)
12: 2.203347

#15

Nice compact routine.

- Pauli

#16

A few minor remarks:

In your instructions, "cumulatif" should spelled "cumulative". (Neither of us is a native speaker, I assume, so we need to help each other. :-))

Why do you set the stack size to 4? I haven't checked your code but if you don't need A to D for other purposes or rely on the duplication of T just leave the setting alone. If you really need it, use STOM/RCLM to save and restore the mode.

The iteration uses the approximate comparison operator which relies on the display setting (Am I right, Pauli?). Just put a comment in that explains how this affects accuracy of the integral.

I'd like to see some // comments at the end of the lines. This would help to understand your code and it will not disturb the assembler.


Edited: 10 Oct 2011, 2:39 a.m.


#17

Quote:
The iteration uses the approximate comparison operator which relies on the display setting (I'm I right, Pauli?).

Please see page 58/102. You are :-)
#18

Got it! I will do the changes.

Thanks,

Miguel


Done!

Note: The possibility of using complex instruction makes the code more compact, so i need a four register stack to take advantage of that, so I followed your advice and stored and restored modes.


Edited: 10 Oct 2011, 8:23 a.m.


#19

Quote:
so i need a four register stack to take advantage of that

Only if you rely on the duplication of z/t when doing a complex drop or an operation that drops the stack.

The way it is now it works and that's fine. You should note in the instructions that J is used for saving the mode.

Maybe a limit should be set on the number of iterations. Do you do the halving of intervals over the complete range over and over or do you have a check for each subinterval and divide only if a subinterval is outside the accuracy bounds? The latter would probably need some kind of backtracking which is obviously not possible without recursive programming.


#20

Yes. I will think about setting a limit on the number of iteration.

Thank you Marcus,

Miguel


#21

An iteration limit would be a good idea. I tried integrating LN(x) from 0 to 1 and gave up after my laptop had been crunching away for over half an hour. I was using ALL mode sound rounding was to 12 digits not a fixed number of decimals.


- Pauli


#22

With an iteration limit of 15, LN gives -0.999973 in six seconds. I will leave this limit in the routine.


Possibly Related Threads...
Thread Author Replies Views Last Post
  Integration question and "RPN" mode comment Craig Thomas 16 2,021 12-05-2013, 02:32 AM
Last Post: Nick_S
  WP34s integration trapped in infinite loop Bernd Grubert 25 2,130 10-17-2013, 08:50 AM
Last Post: Dieter
  HP Prime integration Richard Berler 1 401 10-06-2013, 10:52 PM
Last Post: Helge Gabert
  integration on 39gII emulator Wes Loewer 29 2,380 06-07-2013, 05:58 PM
Last Post: Chris Smith
  WP-34S Integration Richard Berler 15 1,355 03-08-2013, 02:29 AM
Last Post: Walter B
  HP 34S integration Richard Berler 16 1,262 02-18-2013, 04:42 PM
Last Post: Marcus von Cube, Germany
  [WP34S] WP34S firmware on the AT91SAM7L-STK dev kit? jerome ibanes 1 404 10-04-2012, 04:59 PM
Last Post: Paul Dale
  [WP34S] Speeding up the Romberg Integration Les Wright 14 1,108 05-31-2012, 03:39 PM
Last Post: Marcus von Cube, Germany
  New variant for the Romberg Integration Method Namir 8 856 04-18-2012, 07:47 AM
Last Post: Nick_S
  Romberg Integration for 33s, 35s Matt Agajanian 9 854 03-26-2012, 10:00 AM
Last Post: Nick_S

Forum Jump: