the
agm
of
(
expression ,
expression )
Expression yields an integer
, a number
, or a complex
.
put agm(steve, bill) into andy
The agm
function returns the arithmetic-geometric mean of its arguments.
The following function handler mimics the behavior of this built-in function for valid arguments:
function agm a,b repeat while a is not b put (a+b)/2 into arithmeticMean put sqrt(a*b) into geometricMean put arithmeticMean into a put geometricMean into b end repeat return a end agm
The agm
function is faster and more accurate than using the above handler.
If both arguments are integer
s or number
s, a number
is returned. If either argument is negative, NaN
is returned. To get a complex
result, convert the arguments to complex
es.
If either argument is a complex
, a complex
is returned.
To use this function with more than two arguments, use this construction: