This site is supported by donations to The OEIS Foundation.

# Continued fractions

(Redirected from Continued fraction)

The unqualified term continued fraction implies simple continued fraction (also called regular continued fraction).

## Simple continued fractions

### Finite simple continued fractions

A finite simple continued fraction is an expression of the form

${\displaystyle c=a_{0}+{\underset {k=1}{\overset {n}{\rm {K}}}}~{\frac {1}{a_{k}}}:=a_{0}+{\cfrac {1}{a_{1}+{\cfrac {1}{a_{2}+{\cfrac {1}{\ddots {\cfrac {\ddots }{a_{n-1}+{\cfrac {1}{a_{n}}}}}}}}}}},\,}$
where
 a0
is the integer part of the continued fraction, the partial quotients
 ak , 1   ≤   k   ≤   n
, are positive integers, and
 n
is a positive integer. (See Gauss’ Kettenbruch notation for the continued fraction operator
 K
.)

Finite simple continued fractions obviously represent rational numbers, and every rational number can be represented in precisely one way as a finite simple continued fraction.

### Infinite simple continued fractions

A infinite simple continued fraction is an expression of the form

${\displaystyle c=a_{0}+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {1}{a_{k}}}:=a_{0}+{\cfrac {1}{a_{1}+{\cfrac {1}{a_{2}+{\cfrac {1}{a_{3}+{\cfrac {1}{a_{4}+{\cfrac {1}{\ddots }}}}}}}}}},\,}$
where
 a0
is the integer part of the continued fraction and the partial denominators
 ak , k   ≥   1
, are positive integers, all the partial numerators being 1. (See Gauss’ Kettenbruch notation for the continued fraction operator
 K
.)

A compact representation is

${\displaystyle c=a_{0}+1/(a_{1}+1/(a_{2}+1/(a_{3}+1/(a_{4}+1/(a_{5}+1/(a_{6}+\ldots ))))))\,}$

A compact notation is

${\displaystyle c=[a_{0};a_{1},a_{2},a_{3},a_{4},a_{5},a_{6},\ldots ]\,}$

A sequence representation is

${\displaystyle \{a_{0},a_{1},a_{2},a_{3},a_{4},a_{5},a_{6},\ldots \}\,}$

Every infinite simple continued fraction represent an irrational number, and every irrational number can be represented in precisely one way as an infinite simple continued fraction.

#### Eventually periodic infinite simple continued fractions

Every eventually periodic infinite simple continued fraction represent an irrational quadratic number (root of an irreducible quadratic polynomial with integer coefficients), and every irrational quadratic number can be represented in precisely one way as an eventually periodic infinite simple continued fraction, i.e.

${\displaystyle c=[a_{0};a_{1},a_{2},a_{3},a_{4},a_{5},a_{6},\ldots ]\,}$
and, for some integer
 m
and some integer
 k > 0
, we have
 a n = a n  + k
for all
 n   ≥   m
.

All non-quadratic irrational numbers have non-periodic infinite simple continued fractions.

### Simple continued fractions convergents

An infinite simple continued fraction representation for an irrational number is mainly useful because its initial segments provide excellent rational approximations to the number. These rational numbers are called the convergents of the continued fraction. Even-numbered convergents are smaller than the original number, while odd-numbered ones are bigger.

The first few convergents (numbered from 0) are

${\displaystyle c_{0}={\frac {p_{0}}{q_{0}}}={\frac {a_{0}}{1}},\ c_{1}={\frac {p_{1}}{q_{1}}}={\frac {a_{1}a_{0}+1}{a_{1}}},\ c_{2}={\frac {p_{2}}{q_{2}}}={\frac {a_{2}(a_{1}a_{0}+1)+a_{0}}{a_{2}a_{1}+1}},\ c_{3}={\frac {p_{3}}{q_{3}}}={\frac {a_{3}(a_{2}(a_{1}a_{0}+1)+a_{0})+(a_{1}a_{0}+1)}{a_{3}(a_{2}a_{1}+1)+a_{1}}},\ \ldots \,}$

or equivalently

${\displaystyle c_{0}={\frac {p_{0}}{q_{0}}}={\frac {a_{0}p_{-1}+p_{-2}}{a_{0}q_{-1}+q_{-2}}}={\frac {a_{0}}{1}},\ c_{1}={\frac {p_{1}}{q_{1}}}={\frac {a_{1}p_{0}+p_{-1}}{a_{1}q_{0}+q_{-1}}},\ c_{2}={\frac {p_{2}}{q_{2}}}={\frac {a_{2}p_{1}+p_{0}}{a_{2}q_{1}+q_{0}}},\ c_{3}={\frac {p_{3}}{q_{3}}}={\frac {a_{3}p_{2}+p_{1}}{a_{3}q_{2}+q_{1}}},\ \ldots \,}$

with

${\displaystyle p_{-2}=0,\,q_{-2}=1,\,}$ i.e. ${\displaystyle c_{-2}={\frac {p_{-2}}{q_{-2}}}={\frac {0}{1}}=0\,}$
${\displaystyle p_{-1}=1,\,q_{-1}=0,\,}$ i.e. ${\displaystyle c_{-1}={\frac {p_{-1}}{q_{-1}}}={\frac {1}{0}}=\infty \,}$

giving

${\displaystyle p_{n}=a_{n}p_{n-1}+p_{n-2}\,}$
${\displaystyle q_{n}=a_{n}q_{n-1}+q_{n-2}\,}$

with

${\displaystyle p_{-2}=0,\,q_{-2}=1,\,}$ i.e. ${\displaystyle c_{-2}={\frac {p_{-2}}{q_{-2}}}={\frac {0}{1}}=0\,}$
${\displaystyle p_{-1}=1,\,q_{-1}=0,\,}$ i.e. ${\displaystyle c_{-1}={\frac {p_{-1}}{q_{-1}}}={\frac {1}{0}}=\infty \,}$

where

${\displaystyle c_{n}={\frac {p_{n}}{q_{n}}},\,n\geq -2.\,}$
${\displaystyle \lim _{n\to \infty }c_{n}=c\quad {\rm {iff}}\quad \lim _{n\to \infty }\sum _{k=0}^{n}a_{k}\to \infty \,}$

These recurrence relations (a special case of generalized continued fractions convergents) are due to John Wallis.

Table of nice simple continued fractions
Continued fraction Closed form Decimal expansion A-number
${\displaystyle 1+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {1}{1}}=1+{\cfrac {1}{1+{\cfrac {1}{1+{\cfrac {1}{1+{\cfrac {1}{\ddots }}}}}}}}\,}$

{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...}

Phi
Golden ratio

${\displaystyle \varphi ={\frac {1+{\sqrt {5}}}{2}}\,}$

1.618033988749894848204586834...

CF:
A000012

Conv. nums:

 pn =
A000045
 (n + 2), n   ≥   0

Conv. dens:

 qn =
A000045
 (n + 1), n   ≥   0

Base 10:
A001622

${\displaystyle 0+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {1}{1+({\frac {2k}{3}}-1)\cdot 0^{(k{\bmod {3}})}}}={\textbf {0}}+{\cfrac {1}{1+{\cfrac {1}{1+{\cfrac {1}{{\textbf {2}}+{\cfrac {1}{1+{\cfrac {1}{1+{\cfrac {1}{{\textbf {4}}+{\cfrac {1}{1+{\cfrac {1}{\ddots }}}}}}}}}}}}}}}}\,}$

{0, 1, 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1, 1, 14, ...}

1/(e-1)

${\displaystyle {\frac {1}{e-1}}=\sum _{n=1}^{\infty }e^{-n}}$

0.5819767068693264243850020051...

CF:

 a (n) =
A005131
 (n + 1), n   ≥   0

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A073333

${\displaystyle 1+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {1}{1+{\frac {4k}{3}}\cdot 0^{(k{\bmod {3}})}}}={\textbf {1}}+{\cfrac {1}{1+{\cfrac {1}{1+{\cfrac {1}{{\textbf {5}}+{\cfrac {1}{1+{\cfrac {1}{1+{\cfrac {1}{{\textbf {9}}+{\cfrac {1}{1+{\cfrac {1}{\ddots }}}}}}}}}}}}}}}}\,}$

{1, 1, 1, 5, 1, 1, 9, 1, 1, 13, 1, 1, 17, 1, 1, 21, 1, 1, 25, 1, 1, 29, ...}

1/(sqrt(e)-1)

${\displaystyle {\frac {1}{{\sqrt {e}}-1}}\,}$

1.54149408253679828413110344447...

CF:

 a (n) =
A058281
 (n + 1), n   ≥   0

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A113011

${\displaystyle 0+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {1}{2(2k-1)}}=0+{\cfrac {1}{2+{\cfrac {1}{6+{\cfrac {1}{10+{\cfrac {1}{14+{\cfrac {1}{18+{\cfrac {1}{22+{\cfrac {1}{26+{\cfrac {1}{\ddots }}}}}}}}}}}}}}}}\,}$

{0, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, ...}

tanh(1/2) = (e-1)/(e+1)

${\displaystyle \tanh({\tfrac {1}{2}})={\frac {e-1}{e+1}}\,}$

0.46211715726000975850231848364...

CF:

 a (n) =
A016825
 (n  −  1), n   ≥   1

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A160327

${\displaystyle 0+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {1}{k}}=0+{\cfrac {1}{1+{\cfrac {1}{2+{\cfrac {1}{3+{\cfrac {1}{4+{\cfrac {1}{5+{\cfrac {1}{6+{\cfrac {1}{7+{\cfrac {1}{\ddots }}}}}}}}}}}}}}}}\,}$

{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ...}

BesselI[1, 2]/BesselI[0, 2]

${\displaystyle {\frac {I_{1}(2)}{I_{0}(2)}}\,}$

0.697774657964007982006790592...

CF:
A001477

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A052119

${\displaystyle 1+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {1}{k+1}}=1+{\cfrac {1}{2+{\cfrac {1}{3+{\cfrac {1}{4+{\cfrac {1}{5+{\cfrac {1}{6+{\cfrac {1}{7+{\cfrac {1}{8+{\cfrac {1}{\ddots }}}}}}}}}}}}}}}}\,}$

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ...}

BesselI[0, 2]/BesselI[1, 2]

${\displaystyle {\frac {I_{0}(2)}{I_{1}(2)}}\,}$

1.433127426722311758317183455...

CF:
A000027

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A060997

${\displaystyle p_{1}+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {1}{p_{k+1}}}=2+{\cfrac {1}{3+{\cfrac {1}{5+{\cfrac {1}{7+{\cfrac {1}{11+{\cfrac {1}{13+{\cfrac {1}{17+{\cfrac {1}{19+{\cfrac {1}{\ddots }}}}}}}}}}}}}}}}\,}$

{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, ...}

?

${\displaystyle ?\,}$

2.3130367364335829063839516...

CF:
A000040

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A064442

## Generalized continued fractions

Generalized continued fractions are also called general continued fractions.

### Finite generalized continued fractions

A finite generalized continued fraction is an expression of the form

${\displaystyle c=a_{0}+{\underset {k=1}{\overset {n}{\rm {K}}}}~{\frac {b_{k}}{a_{k}}}:=a_{0}+{\cfrac {b_{1}}{a_{1}+{\cfrac {b_{2}}{a_{2}+{\cfrac {b_{3}}{\ddots {\cfrac {\ddots }{a_{n-1}+{\cfrac {b_{n}}{a_{n}}}}}}}}}}},\,}$
where
 a 0
is the integer part of the continued fraction, the
 bk , 1   ≤   k   ≤   n,
are the partial numerators, the
 ak , 1   ≤   k   ≤   n,
are the partial denominators, and
 n
is a positive integer. (See Gauss’ Kettenbruch notation for the continued fraction operator
 K
.)

Finite generalized continued fractions obviously represent rational numbers, although rational numbers can be represented in many (finitely many?) ways as a finite generalized continued fraction.

### Infinite generalized continued fractions

A infinite generalized continued fraction is an expression of the form

${\displaystyle c=a_{0}+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {b_{k}}{a_{k}}}:=a_{0}+{\cfrac {b_{1}}{a_{1}+{\cfrac {b_{2}}{a_{2}+{\cfrac {b_{3}}{a_{3}+{\cfrac {b_{4}}{a_{4}+{\cfrac {b_{5}}{\ddots }}}}}}}}}},\,}$
where
 a0
is the integer part of the continued fraction, the
 bk , k   ≥   1,
are the partial numerators, the
 ak , k   ≥   1,
are the partial denominators. (See Gauss’ Kettenbruch notation for the continued fraction operator
 K
.)

A compact representation is

${\displaystyle c=a_{0}+b_{1}/(a_{1}+b_{2}/(a_{2}+b_{3}/(a_{3}+b_{4}/(a_{4}+b_{5}/(a_{5}+b_{6}/(a_{6}+\ldots ))))))\,}$

A compact notation could be

${\displaystyle c=[a_{0};b_{1}/a_{1},b_{2}/a_{2},b_{3}/a_{3},b_{4}/a_{4},b_{5}/a_{5},b_{6}/a_{6},\ldots ]\,}$

A sequence representation could be

${\displaystyle \{a_{0},b_{1},a_{1},b_{2},a_{2},b_{3},a_{3},b_{4},a_{4},b_{5},a_{5},b_{6},a_{6},\ldots \}\,}$

Every infinite generalized continued fraction represent an irrational number, although irrational numbers can be represented in many (infinitely many?) ways as an infinite generalized continued fraction.

#### ??? Eventually periodic infinite generalized continued fractions ???

The numbers having at least one eventually periodic infinite generalized continued fraction representation are... ?????

where

${\displaystyle c=[a_{0};b_{1}/a_{1},b_{2}/a_{2},b_{3}/a_{3},b_{4}/a_{4},b_{5}/a_{5},b_{6}/a_{6},\ldots ]\,}$
and, for some integer
 m
and some integer
 k > 0
, we have
 bn an
=
 bn +k an +k
for all
 n   ≥   m
.

The numbers with only non-periodic infinite generalized continued fraction representations are ?????. (Are there such numbers...?)

### Generalized continued fractions convergents

The first few convergents (numbered from 0) are

${\displaystyle c_{0}={\frac {p_{0}}{q_{0}}}={\frac {a_{0}}{1}},\ c_{1}={\frac {p_{1}}{q_{1}}}={\frac {a_{1}a_{0}+b_{1}}{a_{1}}},\ c_{2}={\frac {p_{2}}{q_{2}}}={\frac {a_{2}(a_{1}a_{0}+b_{1})+b_{2}a_{0}}{a_{2}a_{1}+b_{2}}},\ c_{3}={\frac {p_{3}}{q_{3}}}={\frac {a_{3}(a_{2}(a_{1}a_{0}+b_{1})+b_{2}a_{0})+b_{3}(a_{1}a_{0}+b_{1})}{a_{3}(a_{2}a_{1}+b_{2})+b_{3}a_{1}}},\ \ldots \,}$

or equivalently

${\displaystyle c_{0}={\frac {p_{0}}{q_{0}}}={\frac {a_{0}p_{-1}+b_{0}p_{-2}}{a_{0}q_{-1}+b_{0}q_{-2}}}={\frac {a_{0}}{1}},\,c_{1}={\frac {p_{1}}{q_{1}}}={\frac {a_{1}p_{0}+b_{1}p_{-1}}{a_{1}q_{0}+b_{1}q_{-1}}},\,c_{2}={\frac {p_{2}}{q_{2}}}={\frac {a_{2}p_{1}+b_{2}p_{0}}{a_{2}q_{1}+b_{2}q_{0}}},\,c_{3}={\frac {p_{3}}{q_{3}}}={\frac {a_{3}p_{2}+b_{3}p_{1}}{a_{3}q_{2}+b_{3}q_{1}}},\,\ldots \,}$

with

${\displaystyle b_{0}\equiv 1\,}$
${\displaystyle p_{-2}\equiv ,\,q_{-2}\equiv 1,\,}$ i.e. ${\displaystyle c_{-2}\equiv {\frac {p_{-2}}{q_{-2}}}={\frac {0}{1}}=0\,}$
${\displaystyle p_{-1}\equiv ,\,q_{-1}\equiv 0,\,}$ i.e. ${\displaystyle c_{-1}\equiv {\frac {p_{-1}}{q_{-1}}}={\frac {1}{0}}=\infty \,}$

giving

${\displaystyle p_{n}=a_{n}p_{n-1}+b_{n}p_{n-2}\,}$
${\displaystyle q_{n}=a_{n}q_{n-1}+b_{n}q_{n-2}\,}$

with

${\displaystyle b_{0}\equiv 1\,}$
${\displaystyle p_{-2}\equiv ,\,q_{-2}\equiv 1,\,}$ i.e. ${\displaystyle c_{-2}\equiv {\frac {p_{-2}}{q_{-2}}}={\frac {0}{1}}=0\,}$
${\displaystyle p_{-1}\equiv ,\,q_{-1}\equiv 0,\,}$ i.e. ${\displaystyle c_{-1}\equiv {\frac {p_{-1}}{q_{-1}}}={\frac {1}{0}}=\infty \,}$

where

${\displaystyle c_{n}={\frac {p_{n}}{q_{n}}},\,n\geq -2.\,}$
${\displaystyle c=\lim _{n\to \infty }c_{n}\,}$

These recurrence relations are due to John Wallis.

Table of nice generalized continued fractions
Continued fraction Closed form Decimal expansion A-number
${\displaystyle 1+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {k}{1}}=1+{\cfrac {1}{1+{\cfrac {2}{1+{\cfrac {3}{1+{\cfrac {4}{\ddots }}}}}}}}\,}$

{1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, ...}

sqrt(2/(pi*e))/erfc(1/sqrt(2))

${\displaystyle {\sqrt {\frac {2}{\pi e}}}{\frac {1}{{\rm {~erfc}}({\tfrac {1}{\sqrt {2}}})}}\,}$

1.525135276160981209089090536...

CF:

 a (n) =
A057979
 (n + 2), n   ≥   0

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A111129

${\displaystyle 0+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {k}{k}}=0+{\cfrac {1}{1+{\cfrac {2}{2+{\cfrac {3}{3+{\cfrac {4}{\ddots }}}}}}}}\,}$

{0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, ...}

1/(e-1)

${\displaystyle {\frac {1}{e-1}}=\sum _{n=1}^{\infty }e^{-n}\,}$

0.5819767068693264243850020051...

CF:
A110654

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A073333

${\displaystyle 1+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {2k}{2k+1}}=1+{\cfrac {2}{3+{\cfrac {4}{5+{\cfrac {6}{7+{\cfrac {8}{\ddots }}}}}}}}\,}$

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ...}

1/(sqrt(e)-1)

${\displaystyle {\frac {1}{{\sqrt {e}}-1}}\,}$

1.54149408253679828413110344447...

CF:
A000027

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A113011

${\displaystyle 1+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {k^{2}}{2k+1}}=1+{\cfrac {1}{3+{\cfrac {4}{5+{\cfrac {9}{7+{\cfrac {16}{\ddots }}}}}}}}\,}$

{1, 1, 3, 4, 5, 9, 7, 16, 9, 25, 11, 36, 13, 49, 15, 64, 17, 81, ...}

4/pi

${\displaystyle {\frac {4}{\pi }}\,}$

1.27323954473516268615107010698...

CF:
A079097

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A088538

${\displaystyle p_{1}+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {p_{2k}}{p_{2k+1}}}=2+{\cfrac {3}{5+{\cfrac {7}{11+{\cfrac {13}{17+{\cfrac {19}{\ddots }}}}}}}}\,}$

{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, ...}

Herkommer number

${\displaystyle ?\,}$

2.5360270816893383923069490821...

CF:
A000040

Conv. nums:
A??????

Conv. dens:
A??????

Base 10:
A085825

## Gauss’ Kettenbruch notation

Karl Friedrich Gauss evoked the more familiar product operator
 Π
when he devised his notation for the continued fraction (Kettenbruch in german) operator
${\displaystyle x=a_{0}+{\underset {k=1}{\overset {\infty }{\rm {K}}}}~{\frac {b_{k}}{a_{k}}}:=a_{0}+{\cfrac {b_{1}}{a_{1}+{\cfrac {b_{2}}{a_{2}+{\cfrac {b_{3}}{a_{3}+{\cfrac {b_{4}}{a_{4}+{\cfrac {b_{5}}{\ddots }}}}}}}}}}.\,}$
Here the
 K
stands for Kettenbruch, the German word for “continued fraction.” This is probably the most compact and convenient way to express continued fractions; however, it is not widely used by English typesetters.