Post Reply 
(41C) and (42S) Arithmetic-Geometric Mean
07-27-2020, 07:26 AM (This post was last modified: 07-27-2020 09:38 AM by Werner.)
Post: #2
RE: (41C) and (42S) Arithmetic-Geometric Mean
In a lengthy thread about bore hole volumes not so long ago, I came up with the following, thanks to Albert Chan and Gerson W. Barbosa (stack-only, 41/42 compatible and reg Z preserved):

Code:
00 { 27-Byte Prgm } @   X       Y       Z       T
01▸LBL 02
02 X<>Y
03 X<> ST T
04 2
05 ÷
06▸LBL "AGM" @          a       b       z
07 STO ST T @           a       b       z       a
08 X<>Y
09 STO+ ST T @          b       a       z       2AM
10 STO× ST Y
11 X<>Y
12 SQRT @               GM      b       z       2AM
13 X≠Y?
14 GTO 02
15 R↓
16 END

I you want to show "AGM=.." at the end, for Free42 and DM42 there's a way that does not use the Alpha register: just add

LSTO "AGM"
VIEW "AGM"

at the end.

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: (41C) and (42S) Arithmetic-Geometric Mean - Werner - 07-27-2020 07:26 AM



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