Post Reply 
HP42s first major program (Double Integral) Best way to approach?
06-02-2020, 08:23 AM
Post: #40
RE: HP42s first major program (Double Integral) Best way to approach?
Continuous improvement.. when I rewrite agm as

function agm2(a, b)
local t = -1
local s1 = a*a
do
local s = s1
local k = (b-a)/2
t = t + t
b = sqrt(a*b)
a = a + k
s1 = s + t*k*k
until s == s1
return a, s
end

and I switch the order of the arguments in hv, I get

Code:
00 { 192-Byte Prgm }
01▸LBL "BORE"
02 MVAR "a"
03 MVAR "b"
04 MVAR "c"
05▸LBL 10
06 VARMENU "BORE"
07 RTN
08 RCL "a"
09 XEQ 03
10 LSTO "t"
11 RCL "b"
12 XEQ 03
13 RCL- "t"
14 GTO 10
15▸LBL 03
16 RCL "c"
17▸LBL "HV"
18 LSTO "d"
19 X<>Y
20 LSTO "D"
21 ÷
22 XEQ "EK"
23 RCL- ST Y
24 X<>Y
25 LASTX
26 +
27 RCL "d"
28 X↑2
29 ×
30 X<>Y
31 RCL "D"
32 X↑2
33 ×
34 +
35 RCL× "D"
36 3
37 ÷
38 RTN
39▸LBL "EK"
40 X↑2
41 1
42 -
43 +/-
44 SQRT
45 1
46 X<>Y
47 STO+ ST Y
48 SQRT
49 STO+ ST X
50 XEQ "AGM2"
51 PI
52 X<>Y
53 ÷
54 STO× ST Y
55 X<>Y
56 4
57 ÷
58 RTN
59▸LBL "AGM2"
60 LSTO "B"
61 R↓
62 LSTO "A"
63 X↑2
64 LSTO "S"
65 SIGN
66 +/-
67 LSTO "T"
68▸LBL 02
69 RCL "A"
70 RCL× "B"
71 SQRT
72 X<> "B"
73 RCL- "A"
74 2
75 STO× "T"
76 ÷
77 STO+ "A"
78 X↑2
79 RCL× "T"
80 RCL+ "S"
81 ENTER
82 X<> "S"
83 X≠Y?
84 GTO 02
85 RCL "A"
86 END

Of course, if you don't need the alpa labels AGM2, EK and HV, you can replace them with numeric ones ( leave out LBL "HV" entirely), saving another 22 bytes, I think.

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP42s first major program (Double Integral) Best way to approach? - Werner - 06-02-2020 08:23 AM



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