Post Reply 
(42S) GAUSS LEGENDRE 16 POINT INTEGRATION
06-29-2014, 11:30 AM (This post was last modified: 11-02-2017 05:14 PM by Gerald H.)
Post: #1
(42S) GAUSS LEGENDRE 16 POINT INTEGRATION
"Func name" should be the name of a programme taking one argument from the X register & returning a real value to the X register.

Func name → 00
Lower lim → 01
Upper lim → 02
# division → 03

Code:
0.    { 379-Byte Prgm }
1.    LBL “GL16”
2.    CLX
3.    STO 04
4.    RCL 02
5.    RCL 01
6.    STO 07
7.    –
8.    RCL 03
9.    STO 05
10.    STO+ ST X
11.    /
12.    STO 06
13.    LBL 17
14.    STO+ 07
15.    16
16.    STO 08
17.    LBL 18
18.    RCL 07
19.    XEQ IND 08
20.    RCL* 06
21.    STO 09
22.    –
23.    XEQ IND 00
24.    STO 10
25.    RCL 07
26.    RCL+ 09
27.    XEQ IND 00
28.    RCL+ 10
29.    DSE 08
30.    XEQ IND 08
31.    *
32.    STO+ 04
33.    DSE 08
34.    GTO 18
35.    RCL 06
36.    STO+ 07
37.    DSE 05
38.    GTO 17
39.    STO* 04
40.    RCL 04
41.    RTN
42.    LBL 01
43.    271524594118E-13
44.    RTN
45.    LBL 02 
46.    989400934992E-12
47.    RTN
48.    LBL 03
49.    622535239386E-13
50.    RTN
51.    LBL 04
52.    944575023073E-12
53.    RTN
54.    LBL 05
55.    951585116825E-13
56.    RTN
57.    LBL 06
58.    865631202388E-12
59.    RTN
60.    LBL 07
61.    124628971256E-12
62.    RTN
63.    LBL 08
64.    755404408355E-12
65.    RTN
66.    LBL 09
67.    149595988817E-12
68.    RTN
69.    LBL 10
70.    617876244403E-12
71.    RTN
72.    LBL 11
73.    169156519395E-12
74.    RTN
75.    LBL 12
76.    458016777657E-12
77.    RTN
78.    LBL 13
79.    182603415045E-12
80.    RTN
81.    LBL 14
82.    281603550779E-12
83.    RTN
84.    LBL 15
85.    189450610455E-12
86.    RTN
87.    LBL 16
88.    950125098376E-13
89.    END
Find all posts by this user
Quote this message in a reply
05-03-2015, 04:51 PM (This post was last modified: 05-03-2015 04:53 PM by pito.)
Post: #2
RE: HP 42S GAUSS LEGENDRE 16 POINT INTEGRATION
Hi, I put the listing into .42s (for the 42s Code Editor) and raw format for free42 (see attached).
However it loops forever.
As the function to integrate I used for example:

Code:
LBL "FX"
LN
END

and I stored it to 00 (so RCL 00 returns me "FX").
Not sure that is the way how it should be done, though..


Attached File(s)
.zip  gl16.zip (Size: 866 bytes / Downloads: 10)
Find all posts by this user
Quote this message in a reply
05-03-2015, 05:17 PM
Post: #3
RE: HP 42S GAUSS LEGENDRE 16 POINT INTEGRATION
Your programme is well formed. Limits in 01 & 02, divisions in 03 & it should work.
Find all posts by this user
Quote this message in a reply
05-03-2015, 05:38 PM (This post was last modified: 05-03-2015 05:56 PM by pito.)
Post: #4
RE: HP 42S GAUSS LEGENDRE 16 POINT INTEGRATION
Thanks! I messed something with the limits before..
Test:
Integrate ln(x) from 0 to 2
100divs:
-6.13659225325e-1
100kdivs:
-6.13705592467e-1
-6.13705638880109e-1 w.alfa says
42s Int (1e-7 acc):
-6.13705307013e-1
Find all posts by this user
Quote this message in a reply
05-17-2015, 09:35 AM (This post was last modified: 11-02-2017 05:14 PM by Gerald H.)
Post: #5
RE: HP 42S GAUSS LEGENDRE 16 POINT INTEGRATION
I note that some members (pito) have used the programme in some emulator contrary to my wish that we remain true to the original & exclusively use the programmes in the 42S.

However, recognising the scarcity & cost of a 42S I relent & permit usage in emulators.

go42S emulates very nicely using the original ROM, sadly incorporating the possibility of accelerating calculation speed by a factor of up to 32.

Free42 operates to a much higher level of accuracy & cannot operate at original speed - a sad comment on our times.

The following programme is adapted for Free42 - it will run on the original 42S, just at a slightly slower speed than the above programme - to make use of abscissae & weights of greater accuracy.

I would be pleased to hear of any actual improvement in calculating accuracy.

Code:
00 { 607-Byte Prgm }
01>LBL "GL16"
02 CLX
03 STO 04
04 RCL 02
05 RCL 01
06 STO 07
07 -
08 RCL 03
09 STO 05
10 STO+ ST X
11 ÷
12 STO 06
13>LBL 17
14 STO+ 07
15 16
16 STO 08
17>LBL 18
18 RCL 07
19 XEQ IND 08
20 RCL× 06
21 STO 09
22 -
23 XEQ IND 00
24 STO 10
25 RCL 07
26 RCL+ 09
27 XEQ IND 00
28 RCL+ 10
29 DSE 08
30 XEQ IND 08
31 ×
32 STO+ 04
33 DSE 08
34 GTO 18
35 RCL 06
36 STO+ 07
37 DSE 05
38 GTO 17
39 STO× 04
40 RCL 04
41 RTN
42>LBL 01
43 2.71524594117E-2
44 54094852E-21
45 +
46 RTN
47>LBL 02
48 9.89400934991E-1
49 649932596E-21
50 +
51 RTN
52>LBL 03
53 6.22535239386E-2
54 47892863E-21
55 +
56 RTN
57>LBL 04
58 9.44575023073E-1
59 232576078E-21
60 +
61 RTN
62>LBL 05
63 9.5158511682E-2
64 49278481E-20
65 +
66 RTN
67>LBL 06
68 8.65631202387E-1
69 83174388E-20
70 +
71 RTN
72>LBL 07
73 1.24628971255E-1
74 533872052E-21
75 +
76 RTN
77>LBL 08
78 7.55404408355E-1
79 3033895E-21
80 +
81 RTN
82>LBL 09
83 1.49595988816E-1
84 576732081E-21
85 +
86 RTN
87>LBL 10
88 6.17876244402E-1
89 643748447E-21
90 +
91 RTN
92>LBL 11
93 1.69156519395E-1
94 2538189E-21
95 +
96 RTN
97>LBL 12
98 4.58016777657E-1
99 227386342E-21
100 +
101 RTN
102>LBL 13
103 1.82603415044E-1
104 923588867E-21
105 +
106 RTN
107>LBL 14
108 2.81603550779E-1
109 25891323E-20
110 +
111 RTN
112>LBL 15
113 1.89450610455E-1
114 68496285E-21
115 +
116 RTN
117>LBL 16
118 9.50125098376E-2
119 37440185E-21
120 +
121 .END.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)