Post Reply 
Arithmetic-Geometric Mean (HP-15C, HP-67)
05-31-2016, 04:54 PM
Post: #1
Arithmetic-Geometric Mean (HP-15C, HP-67)
Arithmetic-Geometric Mean

HP-15C

Code:

001- f  LBL A   42 21 11
002-    ENTER         36
003- f  LBL 0   42 21  0
004-       R↓         33
005-    STO I      44 25
006-      X≷Y         34
007-       +          40
008- g   LSTx      43 36
009-   RCL× I   45 20 25
010-       √x         11
011-      X≷Y         34
012-        2          2
013-       ÷          10
014-      X≷Y         34
015-    RCL I      45 25
016- g TEST 6   43 30  6
017-    GTO 0      22  0
018- g     R↑      43 33
019-      X≷Y         34
020- g    RTN      43 32

Code:

001- f  LBL A   42 21 11
002- g     R↑      43 33
003- f  LBL 0   42 21 00
004-       R↓         33
005-    ENTER         36
006- f   X≷ 0   42  4  0
007-       R↓         33
008-      X≷Y         34
009-       +          40
010-       .          48
011-       5           5
012-      X≷Y         34
013-       ×          20
014- g   LSTx      43 36
015-   RCL- 0   45 30  0
016-   RCL× 0   45 20  0
017-       √x         11
018- g     R↑      43 33
019- f   X≷ 0   42  4  0
020- g TEST 6   43 30  6
021-    GTO 0      22  0
022- g     R↑      43 33
023-      X≷Y         34
024- g    RTN      43 32

HP-67

Code:

001  *LBLA   31 25 11
002   ENT↑         41
003  *LBL0   31 25 00
004     R↓      35 53
005   STOI      35 33
006    X≷Y      35 52
007     +          61
008   LSTX      35 82
009   RCLI      35 34
010     ×          71
011     √X      31 54
012    X≷Y      35 52
013      2         02
014     ÷          81
015    X≷Y      35 52
016   RCLI      35 34
017   X≠Y?      32 61
018   GTO0      22 00
019     R↑      35 54
020    X≷Y      35 52
021    RTN      35 22

Examples:

1) AGM(3,4)

3 ENTER 4 f A -> 3.482027677 (6)


2) AGM(12345,6789)

12345 ENTER 6789 f A -> 9359.761031 (2)


3) √(2* π*√(2* π)/AGM(1,√(2))) = Γ(1/4)

2 π * √x g LASTx * 2 √x 1 f A / √x --> 3.625609909 (8)

4 1/x 1 - f x! --> 3.625609908

Notes:

1) Examples above on the HP-15C, first version program;

2) The second HP-15C program version uses the numbered register 0, but preserves its original content;

3) All versions preserve the original stack-register X;

4) The programs are based on an HP-41C program by Jean-Marc Baillard:

Code:

01 LBL "AGM"
02 ENTER^
03 LBL 01
04 CLX
05 RCL Z
06 RCL Y
07 +
08 2
09 /
10 RCL Y
11 SQRT
12 R^
13 SQRT
14 *
15 R^
16 X#Y?
17 GTO 01
18 END

Optimization suggestions welcome.

Gerson.
Find all posts by this user
Quote this message in a reply
Post Reply 




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