Post Reply 
HP42s first major program (Double Integral) Best way to approach?
06-13-2020, 10:16 PM (This post was last modified: 06-14-2020 10:20 PM by Albert Chan.)
Post: #58
RE: HP42s first major program (Double Integral) Best way to approach?
Inspired by Werner's AGM code thread, I fixed my AGM2 convergence issue.

It now test convergence of sucessive GM's, eliminated convergence issue of AGM(x,0).
Test for EK(m) for abs(m-1)=0 is now shifted to test returns of AGM2.

To simplify further , I make this version dimensionless, m = (d/D)^2

→ HV(d,D) = HV1(m) * D³

Code:
00 { 128-Byte Prgm }
01▸LBL "HV1"    ; HV1(m) = (m(e+k) + (e-k))/3
02 LSTO "m"     ; m = (d/D)^2
03 XEQ "EK"
04 RCL- ST Y
05 X<>Y
06 LASTX
07 +
08 RCL× "m"
09 +
10 3
11 ÷
12 RTN
13 ▸LBL "EK"    ; (m) -> E(m), K(m)
14 1
15 -
16 LASTX
17 X<>Y
18 +/-          ; 1-m   1
19 SQRT
20 STO+ ST Y
21 SQRT
22 STO+ ST X
23 XEQ "AGM"    ; x     y
24 ABS
25 X=0?
26 GTO 00
27 PI
28 LASTX        ; x     pi    abs(x)  y
29 ÷
30 STO× ST T
31 R↑
32 4
33 ÷
34 RTN
35▸LBL 00       ; K(1) assumed 99
36 99
37 1
38 RTN
39▸LBL "AGM"    ; (a,b) -> (agm, acc)
40 X<>Y
41 LSTO "A"
42 X↑2
43 LSTO "S"
44 1
45 LSTO "T"
46 X<> ST Z
47▸LBL 02       ; b
48 ENTER
49 RCL× "A"     ; ab    b
50 LASTX
51 RCL- "A"     ; b-a   ab    b
52 2
53 STO× "T"
54 ÷            ; k     ab    b     b
55 STO+ "A"
56 X↑2
57 RCL× "T"
58 STO- "S"
59 R↓
60 SQRT         ; GM    b     b     tkk
61 X≠Y?
62 GTO 02
63 RCL "S"
64 X<>Y         ; GM    S     b     b
65 END
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? - Albert Chan - 06-13-2020 10:16 PM



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