The Museum of HP Calculators

HP Articles Forum

WP 34S: Integration wrapper

Posted by Miguel Toro on 9 Oct 2011, 10:26 p.m.

This is a wrapper for the integration function of the WP34s for improving accuracy. It integrates by intervals and cumulates the result, comparing a new result with a previous one, until the desired accuracy is reached using the '[approx]?' instruction, so controlling convergence with the display format. FIX 4 and FIX 5 gives good result with relatively fast execution, depending on the function.

- There is now an iteration limit that can be changed in the program

- It is always possible to control time and accuray with the display format

```Usage
1. Place a numeric label for the function to be integrated in I. Example: 10 [STO] I
2. Enter inferior limit [ENTER] superior limit
3. [XEQ][ENTER]'INW'
Results:
x: integration result
y: previous result
z: superior limit
t: inferior limit
Resources
Flags
none
Registers
I: function label. It has to be numeric
J: iteration limit
r10-r11: limits
r12: cumulative result
r13: previous cumulative result
r14: interval of integration
r15: interval divider
Label
01,02,03,04,05
Instructions
001 LBL'INW'
002 1                // Iteration limit
003 5                //
004 STO J            //
005 R[v]
006 0
007 STO 12            // init. result registers
008 STO 13
009 2
010 STO 15            // init. interval divider, begining with 2
011 [cmplx]x[<->] Z
012 [cmplx]STO 10
013 LBL 01            // integration iteration
014 -
015 ABS                  // create first interval
016 RCL/ 15
017 STO 14
018 RCL+ 11
019 RCL 11
020 x[<->] Y
021 LBL 02               // integrate interval
022 x>? 10                  // check if all intervals calculated
023 GTO 03
024 [integral][->]I
025 STO+ 12                 // cumulative result of intervals
026 [cmplx]x[<->] Z         // prepare next interval
027 ENTER[^]
028 RCL+ 14
029 GTO 02
030 LBL 03
031 DSZ J                // Tests iteration limit
032 GTO 05
033 GTO 04
034 LBL 05
035 RCL 12               // compare new and previous result
036 x[approx]? 13        // accuracy controled by FIX
037 GTO 04
038 STO 13               // prepare shorter intervals
039 2
040 STO+ 15
041 CLx
042 STO 12
043 [cmplx]RCL 10
044 GTO 01
045 LBL 04               // shows results
046 [cmplx]RCL 10
047 [cmplx]RCL 12
048 RTN
```

Edited: 1 Nov 2011, 9:50 a.m.

 Password: