Continued Fractions

Introduction

When we approximate π pi by 227 22 over 7 or 355113 355 over 113 we are using remarkably good rational approximations to an irrational number. These approximations do not arise by accident—they come from the theory of continued fractions, one of the most elegant and powerful tools in number theory.

A continued fraction represents a number as a sequence of integer quotients obtained through repeated division. Unlike decimal expansions, continued fractions provide optimal rational approximations at each step. They reveal the arithmetic structure of real numbers in ways that decimals cannot, showing why some irrationals (like the golden ratio) are harder to approximate by rationals than others.

Continued fractions connect to the Euclidean algorithm, Diophantine equations, Pell equations, and the theory of quadratic irrationals. They appear in calendar calculations, gear ratios, musical tuning systems, and the analysis of algorithms. Understanding continued fractions means understanding the deepest properties of rational approximation.

Formal Definition

A simple continued fraction is an expression of the form:

a0+1a1+1a2+1a3+1⋱ a sub 0 plus the fraction with numerator 1 and denominator a sub 1 plus the fraction with numerator 1 and denominator a sub 2 plus the fraction with numerator 1 and denominator a sub 3 plus the fraction with numerator 1 and denominator down right diagonal ellipsis

where a0 a sub 0 is an integer (possibly negative or zero) and a1,a2,a3,… a sub 1 comma a sub 2 comma a sub 3 comma dot dot dot are positive integers called the partial quotients. We use the compact notation:

[a0;a1,a2,a3,…] open bracket a sub 0 semicolon a sub 1 comma a sub 2 comma a sub 3 comma dot dot dot close bracket

For a finite continued fraction [a0;a1,…,an] open bracket a sub 0 semicolon a sub 1 comma dot dot dot comma a sub n close bracket the expression terminates and represents a rational number. For an infinite continued fraction [a0;a1,a2,…] open bracket a sub 0 semicolon a sub 1 comma a sub 2 comma dot dot dot close bracket the expression continues indefinitely and represents an irrational number.

Computing Continued Fractions

To find the continued fraction expansion of a positive real number x x we use an iterative process. Let x0=x x sub 0 equals x At each step:

an=⌊xn⌋,xn+1=1xn−an a sub n equals floor of x sub n comma x sub n plus 1 equals the fraction with numerator 1 and denominator x sub n minus a sub n

The process terminates when xn x sub n is an integer (for rational x x or continues forever (for irrational x x. This algorithm is equivalent to the Euclidean algorithm when applied to the numerator and denominator of a rational number.

Convergents

The convergents of a continued fraction are the rational numbers obtained by truncating the expansion. The n nth convergent is:

pnqn=[a0;a1,a2,…,an] the fraction with numerator p sub n and denominator q sub n equals open bracket a sub 0 semicolon a sub 1 comma a sub 2 comma dot dot dot comma a sub n close bracket

The numerators pn p sub n and denominators qn q sub n satisfy the recurrence relations:

pn=an⁢pn−1+pn−2,qn=an⁢qn−1+qn−2 p sub n equals a sub n p sub n minus 1 plus p sub n minus 2 comma q sub n equals a sub n q sub n minus 1 plus q sub n minus 2

with initial values p−1=1,p0=a0 p sub negative 1 equals 1 comma p sub 0 equals a sub 0 and q−1=0,q0=1 q sub negative 1 equals 0 comma q sub 0 equals 1 These recurrences allow efficient computation of convergents without evaluating nested fractions.

Fundamental Properties

Best Rational Approximations

The convergents of a continued fraction are the best rational approximations in a precise sense. If pnqn the fraction with numerator p sub n and denominator q sub n is a convergent to x x then for any fraction ab a over b with 0<b≤qn 0 is less than b is less than or equal to q sub n:

|x−pnqn|≤|x−ab| the absolute value of x minus the fraction with numerator p sub n and denominator q sub n is less than or equal to the absolute value of x minus a over b

No fraction with smaller or equal denominator can be closer to x x This optimality property makes convergents invaluable for approximation problems.

Alternating Approximations

Successive convergents alternate between being less than and greater than the target value. The even convergents p0q0,p2q2,p4q4,… the fraction with numerator p sub 0 and denominator q sub 0 comma the fraction with numerator p sub 2 and denominator q sub 2 comma the fraction with numerator p sub 4 and denominator q sub 4 comma dot dot dot form an increasing sequence approaching x x from below, while odd convergents p1q1,p3q3,… the fraction with numerator p sub 1 and denominator q sub 1 comma the fraction with numerator p sub 3 and denominator q sub 3 comma dot dot dot decrease toward x x from above.

Error Bounds

The error in approximating x x by its n nth convergent satisfies:

1qn⁢(qn+1+qn)<|x−pnqn|<1qn⁢qn+1 1 over q sub n times open paren q sub n plus 1 plus q sub n close paren is less than the absolute value of x minus the fraction with numerator p sub n and denominator q sub n is less than 1 over q sub n q sub n plus 1

Since qn q sub n grows at least exponentially fast for most numbers, convergents provide extremely accurate approximations.

Worked Examples

Example 1: A Rational Number

Find the continued fraction expansion of 4319 43 over 19

We apply the algorithm iteratively:

x0=4319=2.263…⇒a0=2,x1=143/19−2=195 x sub 0 equals 43 over 19 equals 2.263 dot dot dot right double arrow a sub 0 equals 2 comma x sub 1 equals the fraction with numerator 1 and denominator 43 divided by 19 minus 2 equals nineteen fifths

x1=195=3.8⇒a1=3,x2=119/5−3=54 x sub 1 equals nineteen fifths equals 3.8 right double arrow a sub 1 equals 3 comma x sub 2 equals the fraction with numerator 1 and denominator 19 divided by 5 minus 3 equals five fourths

x2=54=1.25⇒a2=1,x3=15/4−1=4 x sub 2 equals five fourths equals 1.25 right double arrow a sub 2 equals 1 comma x sub 3 equals the fraction with numerator 1 and denominator 5 divided by 4 minus 1 equals 4

x3=4⇒a3=4 x sub 3 equals 4 right double arrow a sub 3 equals 4 (terminates)

Therefore 4319=[2;3,1,4] 43 over 19 equals open bracket 2 semicolon 3 comma 1 comma 4 close bracket.

We can verify:
2+13+11+14=2+13+45=2+519=4319 2 plus the fraction with numerator 1 and denominator 3 plus the fraction with numerator 1 and denominator 1 plus one fourth equals 2 plus the fraction with numerator 1 and denominator 3 plus four fifths equals 2 plus 5 over 19 equals 43 over 19.

Example 2: The Golden Ratio

The golden ratio ϕ=1+52≈1.618 phi equals the fraction with numerator 1 plus the square root of 5 and denominator 2 almost equals 1.618 has the remarkable property that ϕ=1+1ϕ phi equals 1 plus 1 over phi This means:

ϕ=1+11+11+11+⋱=[1;1,1,1,…] phi equals 1 plus the fraction with numerator 1 and denominator 1 plus the fraction with numerator 1 and denominator 1 plus the fraction with numerator 1 and denominator 1 plus down right diagonal ellipsis equals open bracket 1 semicolon 1 comma 1 comma 1 comma dot dot dot close bracket

All partial quotients equal 1, making ϕ phi the simplest possible infinite continued fraction. The convergents are ratios of consecutive Fibonacci numbers: 11,21,32,53,85,… one oneth comma two oneths comma three halves comma five thirds comma eight fifths comma dot dot dot Since the partial quotients are as small as possible, these convergents converge slowly, making ϕ phi the most poorly approximable irrational number.

Example 3: Square Root of 2

For 2≈1.414 the square root of 2 almost equals 1.414 we compute:

a0=1,x1=12−1=2+11=2+1≈2.414 a sub 0 equals 1 comma x sub 1 equals the fraction with numerator 1 and denominator the square root of 2 minus 1 equals the fraction with numerator the square root of 2 plus 1 and denominator 1 equals the square root of 2 plus 1 almost equals 2.414

a1=2,x2=1(2+1)−2=12−1=2+1 a sub 1 equals 2 comma x sub 2 equals the fraction with numerator 1 and denominator open paren the square root of 2 plus 1 close paren minus 2 equals the fraction with numerator 1 and denominator the square root of 2 minus 1 equals the square root of 2 plus 1

The pattern repeats! Therefore 2=[1;2―]=[1;2,2,2,…] the square root of 2 equals open bracket 1 semicolon 2 horizontal bar close bracket equals open bracket 1 semicolon 2 comma 2 comma 2 comma dot dot dot close bracket The convergents 11,32,75,1712,4129,… one oneth comma three halves comma seven fifths comma 17 over 12 comma 41 over 29 comma dot dot dot give increasingly accurate approximations. Note that 75=1.4 seven fifths equals 1.4 and 1712≈1.4167 17 over 12 almost equals 1.4167

Quadratic Irrationals

A fundamental theorem states that a real number has an eventually periodic continued fraction expansion if and only if it is a quadratic irrational—a root of a quadratic polynomial with integer coefficients. Thus d the square root of d for any non-square integer d d has a periodic expansion, but π pi e e and 23 the cube root of 2 do not.

Connection to Other Concepts

The Euclidean algorithm for computing gcd⁡(a,b) the gcd of open paren a comma b close paren is equivalent to computing the continued fraction of ab a over b The sequence of quotients in the Euclidean algorithm gives exactly the partial quotients of the continued fraction.

Continued fractions provide the complete solution to Pell equations x2−dy2=1 x squared minus d y squared equals 1 The convergents of d the square root of d yield all solutions, with the fundamental solution coming from the convergent just before the periodic part repeats.

Dirichlet approximation theorem guarantees that for any irrational α alpha and any N N there exists a rational pq p over q with q≤N q is less than or equal to N such that |α−pq|<1q⁢N the absolute value of alpha minus p over q is less than 1 over q N Continued fractions make this theorem constructive by providing the actual approximations.

Summary

Continued fractions express numbers as nested divisions [a0;a1,a2,…] open bracket a sub 0 semicolon a sub 1 comma a sub 2 comma dot dot dot close bracket with integer partial quotients. Rational numbers have finite expansions; irrationals have infinite ones. Quadratic irrationals have eventually periodic expansions.

The convergents pnqn the fraction with numerator p sub n and denominator q sub n are computed via the recurrence pn=an⁢pn−1+pn−2 p sub n equals a sub n p sub n minus 1 plus p sub n minus 2 and provide the best rational approximations with bounded denominators. They alternate above and below the target value, converging rapidly.

Continued fractions unite the Euclidean algorithm, Pell equations, Diophantine approximation, and the theory of quadratic fields. They reveal the arithmetic essence of real numbers in ways that decimal expansions cannot, showing that numbers like ϕ phi and 2 the square root of 2 have fundamentally different approximation properties.