Learn R Programming

pracma (version 0.4-0)

agm: Arithmetic-geometric Mean

Description

The arithmetic-geometric mean of positive numbers.

Usage

agm(a, b, maxiter = 25, tol = .Machine$double.eps^(1/2))

Arguments

a, b
Positive numbers.
maxiter
Maximum number of iterations.
tol
tolerance; stops when abs(a-b) < tol.

Value

  • Returnes one value, the mean of the last two values a, b.

Details

The arithmetic-geometric mean is defined as the common limit of the two sequences $a_{n+1} = (a_n + b_n)/2$ and $b_{n+1} = \sqrt(a_n b_n)$.

References

http://mathworld.wolfram.com/Arithmetic-GeometricMean.html

See Also

Arithmetic, geometric, and harmonic mean.

Examples

Run this code
##  Gauss constant
1 / agm(1, sqrt(2), tol = 1e-15)$agm  # 0.834626841674073

Run the code above in your browser using DataLab