# Continued fraction representation of quadratic irrationals

I just learned Continued Fractions and I was asked to evaluate the simple continued fractions $$[\bar{1}]$$ , $$[\bar{2}]$$ , and $$[1,\bar{2}]$$

so far all I know about Quadratic Irrationalities and Infinite Continued Fractions is this excerpt from Elementary Number Theory, by Charles Vanden Eynden:

" If the irrational number $$S$$ is of the form $$A\sqrt{d}+B$$, where $$A$$ and $$B$$ are rational numbers and $$d$$ is a positive integer, then we can find its (infinite) continued fraction expansion explicitly. In fact, although we will not prove it here, it turns out that such numbers are exactly those having expansions that repeat past some point.

DEFINITION. periodic continued fraction

An infinite continued fraction $$[q_1,q_2,...]$$ is said to be periodic if it repeats from some point on, that is, if there exist positive integers $$m$$ and $$r$$ such that $$q_n=q_{n+r}$$ for $$n>m$$. "

For the homework assignment I wrote $$[\bar{1}]=\frac{1+\sqrt{5}}{2}, [\bar{2}]=1+\sqrt{2},$$ and then I deduced that $$[1,\bar{2}]$$ must be $$\sqrt{2}$$. I doubled checked these before handing in my assignment...

I used the methods provided in the book to find the above answers, expect for the last one, I just subtracted $$1$$ because the first entry is $$1$$ instead of $$2$$, thus I thought $$[\bar{2}]=1+\sqrt{2} \Longrightarrow [1,\bar{2}]=\sqrt{2}$$

Let $$R_n = \underbrace{[1,1,...,1]}_{n-terms}$$, then for $$[\bar{1}]$$, we compute some values of $$R_i$$ and find a pattern

$$1, 1+\frac{1}{1}, 1+\frac{1}{1+\frac{1}{1}},..., R_{2n+2}=1+\frac{1}{1+\frac{1}{R_{2n}}}$$

Theorem 6.14 Let $$q_1,q_2,...$$ be an infinite sequence of integers, with $$q_i>0$$ for $$i>1$$. Then $$\lim\limits_{r\rightarrow \infty}[q_1,q_2,...,q_r]$$ exists, and is an irrational number.

Let $$n\rightarrow \infty$$ then $$R=1+\frac{1}{1+\frac{1}{R}}$$ because a subsequence must converge to same limit, and we have $$R^2-R-1=0$$ through some manipulation. Take $$R=\frac{1+\sqrt{5}}{2}$$, the positive root because every element of the sequence is positive.

Similarly I deduced that $$[\bar{2}]=1+\sqrt{2}$$.

But then I received a comment that yes my answers were right, but to note that some continued fractions may not converge at all, and so convergence may be an issue for other, not so simple continued fractions.

I'm wondering what this comment refers to? Is the comment useful? Given the limited information I have, it seems like the exercises were simple enough to just get my foot in the door, should I heed the warning? At least how the book explains it, it looks like there's a one-to-one correspondence between quadratic irrationals and periodic continued fractions? However, I wouldn’t know due to the standard write-off “although we will not prove it here” in many introductory books. So why worry about periodic continued fractions then? Obviously in general I should heed the warning, maybe for more complicated continued fractions, sure they do not converge in general.

All in all I wish Vanden Eynden would just go into more detail! So I could have a better idea as to usefulness of the comment.

• Maybe helpful: continued fraction of a square root
– MJD
Commented Apr 22, 2021 at 15:05
• You are (essentially) right about periodic continued fractions. You have not provided enough context for us to help with the comment on your paper. If you can edit the question to provide more, please do. If that's all there is, you should ask your instructor. Commented Apr 22, 2021 at 15:43
• It sounds, at first glance, like you gave the values but didn't evaluate the continued fractions. How did you determine that $[\overline{1}]=\frac12(\sqrt{5}+1)$ and was that part of what you handed in? Commented Apr 22, 2021 at 15:57
• @StevenStadnicki I included the process provided by the book that I used to evaluate the continued fractions, I wasn’t sure if I should of included the calculations or not but since you’ve asked for them I’ve gladly provided them, I only included the calculations for $[\bar{1}]$ because the calculations for $[\bar{2}]$ are very similar to the patterns noticed for the first example, as for $[1,\bar{2}]$ I included my thoughts on how I evaluated this problem. These were calculations I handed in as well! Hope this helps! Commented Apr 22, 2021 at 16:24

I will take a stab at interpreting that comment.

I assume you went about calculating $$[\bar 2]$$ by assuming that it converged to some number $$c$$, writing

$$c = 2 + \frac{1}{c}$$

and solving that quadratic equation for $$c$$.

In this case the convergence you assumed (but did not prove) is correct. But for more general continued fractions you need to prove convergence.

This is an argument you have to be careful with when you consider calculations that look like infinite processes but are really defined as limits. To see the problem consider $$1 + 2 + 4 + 8 + \cdots$$

Assume that converges to a number $$c$$. Then

$$c - 1 = 2 + 4 + 8 + \cdots = 2c$$ so $$c = -1$$ which is clearly nonsense.

• Your equation for $c$ is wrong — the numerators in simple CFs are always taken to be 1. It should be $c=2+\frac1c$. Commented Apr 22, 2021 at 16:21
• It might also be worth mentioning that the Seidel-Stern theorem means that all simple continued fractions with positive integer partial denominators do converge.
– MJD
Commented Apr 22, 2021 at 16:45
• @StevenStadnicki Fixed thanks. You could have edited. Commented Apr 22, 2021 at 17:51
• Mea culpa — I'm always hesitant to edit others' posts for math content. Commented Apr 22, 2021 at 18:00
• @EthanBolker Your result for c is not complete nonsense. The expression is the series expansion of 1/(1-x) for x=2, which is indeed equal to -1. Such tricks are not rigorous and have its hazards, but often ok. Commented Jul 31, 2021 at 19:49

I can't speak to your instructor's mindset, but as others have noted it's relatively straightforward that all simple continued fractions with positive (integer) coefficients converge, so their pedantry seems misplaced.

I can try and fill in the blanks on the correspondence between (eventually) periodic continued fractions and quadratics irrationals, though. There are two parts: showing that every periodic continued fraction corresponds to a quadratic irrational (i.e., a number of the form $$a+b\sqrt{d}$$, with $$a,b\in\mathbb{Q}$$ and $$d\in\mathbb{N}$$), and showing that every quadratic irrational yields a periodic continued fraction.

The former comes down to a relatively straightforward lemma:

The value of a simple continued fraction $$[a_0, a_1, \ldots a_n, x]$$ as a function of $$x$$ is a rational function: $$[a_0, a_1, \ldots a_n, x] = \dfrac{c+dx}{f+gx}$$ for some $$c, d, f, g\in\mathbb{Z}$$, and we have $$cg-df=1$$.

You should be able to prove this by induction; there are very close ties here to the modular group $$PSL_2(\mathbb{Z})$$. Then to evaluate a purely periodic continued fraction $$[\overline{a_0, a_1, \ldots, a_n}]$$, we can note that — letting $$x$$ be the value — $$x=[a_0, a_1, \ldots, a_n, x]$$, so we have $$x=\dfrac{c+dx}{f+gx}$$, or $$gx^2+(f-d)x-c=0$$; the solution to this is obviously a quadratic irrational. Similarly, by using the fact that a linear fractional transformation of a quadratic irrational is also a quadratic irrational (convince yourself of this!), we get the result that any eventually periodic CF corresponds to a quadratic irrational.

Going the other way is a bit more complicated; the best way I know to think of it is that if we have a quadratic irrational $$x$$ of the form $$\frac{r+s\sqrt{d}}{t}$$, then $$\frac1x=\frac{t}{r+s\sqrt{d}} = \frac{rt-st\sqrt{d}}{r^2-s^2d}$$, so when running the continued fraction algorithm for $$x$$ every term that we get will be of this same form. By careful analysis we can keep bounds on the sizes of $$r, s, t$$ that can appear while following the algorithm; once we've established those bounds then it implies that there must be a cycle eventually (since there are only finitely many combinations of $$\langle r,s,t\rangle$$) and therefore that the continued fraction for $$x$$ is eventually periodic (since once we reach a given $$\langle r,s,t\rangle$$ set for the second time, the computation will repeat identically to before).

• +1, thank you for the insight, can $d\in\mathbb{Z}$ be $<0$? It is certainly not rational, but can we really include complex numbers? Commented Apr 22, 2021 at 18:49
• It can't because all of the quantities involved are real; that's a good catch, thank you. Commented Apr 22, 2021 at 19:00
• aw now I’m disappointed:( no cfs for complex numbers, too bad Commented Apr 22, 2021 at 19:02
• @nolemonnomelon You can actually define continued fractions over complex numbers, and there are somewhat comparable ways of handling convergence, but things get distinctly more complicated, and the various claims about quadratic irrationals in particular don't necessarily hold. Commented Apr 22, 2021 at 22:50
• hopefully sometime in the near future I will stumble upon such a subject Commented Apr 22, 2021 at 22:59

If you have a single-digit simple continued fraction, repeated coefficient $$B,$$ the value is $$\frac{B+ \sqrt{4+B^2} \;}{2}$$

Indeed, a quadratic irrational $$\frac{E + \sqrt F}{G}$$ is called "reduced" when it is positive and its "conjugate" $$\frac{E - \sqrt F}{G}$$ lies between $$-1$$ and $$0.$$ Such a number has a purely periodic s.c.f. which may have several "digits," sometimes called "partial quotients."

for example, $$\frac{1+\sqrt{13}}{3}$$ has repeated $$[1,1,1,6,1,1,1,1,6,1]$$ There is a method of Lagrange and Gauss that does not require high decimal accuracy when finding the fraction of a quadratic irrational, just integer operations.

Related example, $$\frac{3+\sqrt{13}}{4}$$ has repeated $$[1,1,1,1,6,1,1,1,1,6]$$ which can be shortened to $$[1,1,1,1,6].$$ Notice how the length ten version is simply a shift of that in the previous paragraph.