连分式

Author

李 辉

Published

April 2, 2026

连分式

a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{ \ddots + \frac{1}{a_n} }}} A (finite) continued fraction, where n is a non-negative integer, a_0 is an integer, and a_i is a positive integer, for i=1,\cdots,n. [a_0,a_1,\cdots,a_n] —

Example 1 \frac{415}{93}=4 + \frac{1}{2 + \frac{1}{6 + \frac{1}{7}}}

[4,2,6,7]

Exercise 1 Try to convert \frac{1999}{233} to form of continued fraction.


Relation to Euclid’s Algorithm

415=4\times 93+43

93=2\times 43+7

43=6\times 7+1

7=7\times 1

[4,2,6,7] —

Represention of Numbers

  • Golden Ratio \phi: [1,1,1,\cdots]

Proof. \phi=\frac{1}{\phi-1},\,\,\,\phi=\frac{1+\sqrt{5}}{2}\approx 1.618 So, \phi=1+(\phi-1)=1+\frac{1}{\frac{1}{\phi-1}}=1+\frac{1}{\phi}\square


  • \sqrt{2}: [1,2,2,2,\cdots]

Proof. 1+\sqrt{2}=2+(\sqrt{2}-1)=2+\frac{1}{\frac{1}{\sqrt{2}-1}}=2+\frac{1}{1+\sqrt{2}}=[2,2,2,2,\cdots] So, \sqrt{2}=[1,2,2,2,\cdots]\square


Definition 1 [a_0,a_1,\cdots,a_k] is convergent to [a_0 ,a_1 ,\cdots,a_n], for 0\leq k\leq n.

Example 2 The first four convergents are \left\{\frac{a_0}{1}, \frac{a_1a_0 + 1}{a_1},\frac{a_2(a_1a_0 + 1) + a_0}{a_2a_1 + 1},\right.\left.\frac{a_3(a_2(a_1a_0 + 1) + a_0) + (a_1a_0 + 1)}{a_3(a_2a_1 + 1) + a_1}\right\}   \{p_0,p_1,p_2,p_3\}=\left\{a_0,\,{a_1a_0 + 1},\,{a_2(a_1a_0 + 1) + a_0},\,{a_3(a_2(a_1a_0 + 1) + a_0) + (a_1a_0 + 1)}\right\}

\{q_0,q_1,q_2,q_3\}=\left\{1, {a_1}, {a_2a_1 + 1}, {a_3(a_2a_1 + 1) + a_1}\right\}

p_k=a_kp_{k-1}+p_{k-2}

q_k=a_kq_{k-1}+q_{k-2}


^ 0 1 2 3
a 4 2 6 7
p 4 9 58 415
q 1 2 13 93
p/q 4/1 9/2 58/13 415/93

^ -2 -1 0 1 2 3
a ^ ^ 4 2 6 7
p 0 1 4 9 58 415
q 1 0 1 2 13 93

Theorem 1 [a_0,a_1,\cdots,a_k]=\frac{p_k}{q_k}

Proof. \frac{p_0}{q_0}=\frac{a_0p_{-1}+p_{-2}}{a_0q_{-1}+q_{-2}}=\frac{a_0\cdot 1}{1}=a_0. Suppose it holds for all k. [a_0,a_1,\cdots,a_{k+1}]=[a_0,a_1,\cdots,a_{k-1},a_k+\frac{1}{a_{k+1}}]=\frac{p_k^\prime}{q_k^\prime}


=\frac{\left(a_k+\frac{1}{a_{k+1}}\right)p_{k-1}^\prime+p_{k-2}^\prime}{\left(a_k+\frac{1}{a_{k+1}}\right)q_{k-1}^\prime+q_{k-2}^\prime}=\frac{(a_ka_{k+1}+1)p_{k-1}^\prime+a_{k+1}p_{k-2}^\prime}{(a_ka_{k+1}+1)q_{k-1}^\prime+a_{k+1}q_{k-2}^\prime}

=\frac{a_{k+1}(a_kp_{k-1}^\prime+p_{k-2}^\prime)+p_{k-1}^\prime}{a_{k+1}(a_kq_{k-1}^\prime+q_{k-2}^\prime)+q_{k-1}^\prime}=\frac{a_{k+1}(a_kp_{k-1}+p_{k-2})+p_{k-1}}{a_{k+1}(a_kq_{k-1}+q_{k-2})+q_{k-1}}=\frac{a_{k+1}p_k+p_{k-1}}{a_{k+1}q_k+q_{k-1}}=\frac{p_{k+1}}{q_{k+1}}

(p_{k-2}^\prime=p_{k-2},p_{k-1}^\prime=p_{k-1},\,\,\,q_{k-2}^\prime=q_{k-2},q_{k-1}^\prime=q_{k-1})\square


Real number x, compute integers a_0,a_1,\cdots, such that a_0=\lfloor x \rfloor. x=a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{ \ddots + \frac{1}{a_n} }}} x_1=\frac{1}{x-a_0}, then a_1=\lfloor x_1 \rfloor,

x_2=\frac{1}{x_1-a_1}, then a_2=\lfloor x_2 \rfloor, \cdots


Theorem 2 p_{k-1}q_k-q_{k-1}p_k=(-1)^k.

Proof. (By PMI) p_{-2}q_{-1}-q_{-2}p_{-1}=(-1)^{-1}. Assume it holds for k. p_{k}q_{k+1}-q_{k}p_{k+1}=p_k(a_{k+1}q_k+q_{k-1})-q_k(a_{k+1}p_k+p_{k-1})=p_kq_{k-1}-q_kp_{k-1}=-(q_kp_{k-1}-p_kq_{k-1})=(-1)(-1)^k=(-1)^{k+1}\square

Corollary 1 \frac{p_{k-1}}{q_{k-1}}-\frac{p_{k}}{q_{k}}=\frac{(-1)^k}{q_{k}q_{k-1}}


Corollary 2 gcd(p_k,q_k)=1

If p_k and q_k had a nontrivial common divisor it would divide p_kq_{k-1}-q_kp_{k-1}, which is impossible.

Corollary 3 p_{k-2}q_k-q_{k-2}p_k=(-1)^{k-1}a_k

Proof. p_{k-1}q_k-q_{k-1}p_k=(-1)^k

a_kp_{k-1}q_k-a_kq_{k-1}p_k=(-1)^ka_k

(p_k-p_{k-2})q_k-(q_k-q_{k-2})p_k=(-1)^ka_k

p_{k-2}q_k-q_{k-2}p_k=(-1)^{k+1}a_k


\frac{p_{k-2}}{q_{k-2}}-\frac{p_{k}}{q_{k}}=\frac{(-1)^{k-1}a_k}{q_{k-2}{q_k}}\Rightarrow\left\{ \begin{matrix} >0& k\text{ is odd}\\ <0& k\text{ is even}\\ \end{matrix}\right.

\Rightarrow \frac{p_0}{q_0}<\frac{p_2}{q_2}<\frac{p_4}{q_4}\cdots

\Rightarrow \frac{p_1}{q_1}>\frac{p_3}{q_3}>\frac{p_5}{q_5}\cdots


Even terms increasing, bounded above by odd terms, odd terms decreasing, bounded below by even terms, so they both converge and get arbitrarily close.

So both even and odd sequences converge to the same real number x, namely,

\frac{p_n}{q_n}\rightarrow x as n\rightarrow \infty. \frac{p_0}{q_0}<\frac{p_2}{q_2}<\frac{p_4}{q_4}<\cdots<x<\cdots<\frac{p_3}{q_3}<\frac{p_1}{q_1}

\left| \frac{p_n}{q_n}- \frac{p_{n+1}}{q_{n+1}}\right|=\frac{1}{q_nq_{n+1}}\rightarrow 0\,as\,n\rightarrow \infty

\left| x-\frac{p_n}{q_n}\right|\leq \left|\frac{p_n}{q_n}-\frac{p_{n+1}}{q_{n+1}}\right|=\frac{1}{q_nq_{n+1}}\leq \frac{1}{q_n^2}.\square —

Theorem 3 ^{\star\star\star} One of every 2 consecutive convergents satisfies \left|x-\frac{p_k}{q_k}\right| \leq \frac{1}{2q_k^2}

Proof. ^{\star\star\star}. \left| \frac{p_n}{q_n}- \frac{p_{n+1}}{q_{n+1}}\right|=\frac{1}{q_nq_{n+1}}\leq \frac{1}{2q_n^2}+\frac{1}{2q_{n+1}^2}

\left|x-\frac{p_n}{q_n}\right|+\left|x-\frac{p_{n+1}}{q_{n+1}}\right|=\left| \frac{p_n}{q_n}- \frac{p_{n+1}}{q_{n+1}}\right|\leq \frac{1}{2q_n^2}+\frac{1}{2q_{n+1}^2}

\Rightarrow\left|x-\frac{p_n}{q_n}\right|\leq \frac{1}{2q_n^2}\,or\,\left|x-\frac{p_{n+1}}{q_{n+1}}\right|\leq \frac{1}{2q_{n+1}^2}\square


Theorem 4 ^{\star\star\star} One of every 3 consecutive convergents satisfies \left|x-\frac{p_k}{q_k}\right| \leq \frac{1}{\sqrt{5}q_k^2}

Proof. ^{\star\star\star} Suppose it is not. \left|x-\frac{p_k}{q_k}\right| > \frac{1}{\sqrt{5}q_k^2} for n,n+1,n+2. \left|x-\frac{p_n}{q_n}\right|+\left|x-\frac{p_{n+1}}{q_{n+1}}\right|=\left| \frac{p_n}{q_n}- \frac{p_{n+1}}{q_{n+1}}\right|=\frac{1}{q_nq_{n+1}}>\frac{1}{\sqrt{5}q_n^2}+\frac{1}{\sqrt{5}q_{n+1}^2}

\Rightarrow \sqrt{5}>\frac{q_{n+1}}{q_{n}}+\frac{q_{n}}{q_{n+1}}\,\,\Rightarrow \frac{q_{n+1}}{q_{n}}<\frac{\sqrt{5}+1}{2}


f(x)=x+\frac{1}{x} is strictly increasing on (1,\infty), so \frac{q_{n}}{q_{n+1}}=\frac{1}{\frac{q_{n+1}}{q_{n}}}>\frac{\sqrt{5}-1}{2} Likewise, \frac{q_{n+2}}{q_{n+1}}<\frac{\sqrt{5}+1}{2}, but \frac{q_{n+2}}{q_{n+1}}=\frac{a_{n+2}q_{n+1}+q_n}{q_{n+1}}=a_{n+2}+\frac{q_n}{q_{n+1}}\geq 1+\frac{\sqrt{5}-1}{2}=\frac{\sqrt{5}+1}{2} Contradiction. \square


Why are continued fractions useful?

  • Gives good approximations to real numbers

  • \pi = [3,7,15,1,292,1,1,1,2,1,3,1,\cdots]

  • e = [2,1,2,1,1,4,1,1,6,1,1,8,1,1,10,\cdots]

  • Useful in number theory for study of quadratic fields, Diophantine equations

  • A real number x is a quadratic surd \left( \frac{P + \sqrt{D}}{Q}\right) if and only if its continued fraction is periodic [a_0;a_1,a_2,\dots,a_k,\overline{a_{k+1},a_{k+2},\dots,a_{k+m}}].


Exercise 2 Please write \sqrt{71} into the form of continued fraction.