## Convergents(n, [mode=0], [terms])

n
Real number or [numerator, denominator] of a real number or [continued fraction] of a real number

[mode=0]
mode = 0 returns the maximum number of convergents MathStudio can calculate. The result is displayed in a matrix with the top row = numerator and the bottom row = denominator of the convergent.
mode = 1 returns the same as above, but the result is displayed as a fraction (less accurate compared to above...)
mode = -1 returns only the largest convergent it can find with both numerator and denominator < 15 digits

[terms]
Number of convergents to return (default = maximum, and limited by machine precision)

## Description

The Convergent of a given number or a given continued fraction is the rational number obtained by keeping only a limited number of terms in the continued fraction (or the continued fraction of the number).

## Examples

Convergents([3, 7, 15, 1, 292, 1, 1])
Convergents([3, 7, 15, 1, 292, 1, 1], 1)
Convergents(2/@pi, -1)
Convergents(@pi, 1, 10)
Convergents([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], -2)

## References

http://mathworld.wolfram.com/Convergent.html

## Related Functions

AlternatingSeries, cFrac