Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
agm:y
|
||||
"return the arithmetic-geometric mean agm(x, y)
|
||||
of the receiver (x) and the argument, y.
|
||||
See https://en.wikipedia.org/wiki/Arithmetic-geometric_mean"
|
||||
|
||||
|ai an gi gn epsilon delta|
|
||||
|
||||
ai := (self + y) / 2.
|
||||
gi := (self * y) sqrt.
|
||||
epsilon := self ulp.
|
||||
|
||||
[
|
||||
an := (ai + gi) / 2.
|
||||
gn := (ai * gi) sqrt.
|
||||
delta := (an - ai) abs.
|
||||
ai := an.
|
||||
gi := gn.
|
||||
] doUntil:[ delta < epsilon ].
|
||||
^ ai
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Transcript showCR: (24 agm:6).
|
||||
Transcript showCR: ( (1/2) agm:(1/6) ).
|
||||
Transcript showCR: (1 agm:(1 / 2 sqrt)).
|
||||
Loading…
Add table
Add a link
Reference in a new issue