ContinuedFraction

ContinuedFraction[x,n]

generates a list of the first n terms in the continued fraction representation of x.

ContinuedFraction[x]

generates a list of all terms that can be obtained given the precision of x.

Details

  • The continued fraction representation {a1,a2,a3,} corresponds to the expression a1+1/(a2+1/(a3+)).
  • x can be either an exact or an inexact number.
  • For exact numbers, ContinuedFraction[x] can be used if x is rational, or is a quadratic irrational.
  • For quadratic irrationals, ContinuedFraction[x] returns a result of the form {a1,a2,,{b1,b2,}}, corresponding to an infinite sequence of terms, starting with the ai, and followed by cyclic repetitions of the bi. »
  • Since the continued fraction representation for a rational number has only a limited number of terms, ContinuedFraction[x,n] may yield a list with less than n elements in this case.
  • For terminating continued fractions, {,k} is always equivalent to {,k-1,1}; ContinuedFraction returns the first of these forms.
  • FromContinuedFraction[list] reconstructs a number from the result of ContinuedFraction.

Examples

open allclose all

Basic Examples  (1)

20 terms in the continued fraction for :

In[1]:=
Click for copyable input
Out[1]=

Scope  (2)

Generalizations & Extensions  (1)

Applications  (3)

Properties & Relations  (2)

Neat Examples  (1)

See Also

Convergents  FromContinuedFraction  QuadraticIrrationalQ  IntegerDigits  Rationalize  Khinchin  RealDigits  ContinuedFractionK

Tutorials

Introduced in 1999
(4.0)