# New way to obtain partial continued fractions of square roots?

Some background: I was working on a problem that asked for the sum of the cubes of the roots of a cubic, $$x^3 - 5x^2 + 5x - 1$$. I found that this factored into $$(x-1)(x^2 - 4x + 1)$$, meaning that its roots are $$1$$ and $$2 \pm \sqrt{3}$$. After finding the sum of the cubes of them, I re-checked my work by manually cubing the roots and adding them together. While I was looking at the powers of $$2 + \sqrt{3}$$, I noticed that the integer component of the sum approached the same value as the irrational component. For example, $$(2 + \sqrt{3})^3 = 26 + 15\sqrt{3} = \sqrt{676} + \sqrt{675}$$, which is way closer than $$2$$ and $$\sqrt{3}$$ are. Moreover, when I looked at the powers of more expressions of the form $$a + \sqrt{b}$$, where $$a$$ and $$b$$ were integers and $$b$$ was not a perfect square, I noticed that when $$a = \lfloor \sqrt{b} \rfloor$$, the quotient of the coefficients of the rational and irrational terms after simplification is equal to a partial sum of the infinite fraction of $$\sqrt{b}$$. For example, the continued fraction of $$\sqrt{2}$$ is $$1 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{1}{2 + \cfrac{1}{2 + \cdots}}}}$$and the first few partial fractions are $$1, \frac{3}{2}, \frac{7}{5}, \frac{17}{12}, \frac{41}{29}, \cdots$$Let $$p_{a\sqrt{b}}$$ denote the $$a^{\text{th}}$$ partial sum of the infinite fraction of $$\sqrt{b}$$. Looking at the powers of $$1 + \sqrt{2}$$, and letting $$r_{c}$$ be the ratio of the coefficients of the rational and irrational terms (i.e. $$r_{c} = \frac{\text{coefficient}_{\text{rational}}}{\text{coefficient}_{\text{irrational}}}$$), we find\begin{align*}&(1 + \sqrt{2})^1 = 1 + 1\sqrt{2} \Rightarrow r_{c} = \frac{1}{1} = 1 = p_{1\sqrt{2}}\\ &(1 + \sqrt{2})^2 = 3 + 2\sqrt{2} \Rightarrow r_{c} = \frac{3}{2} = p_{2\sqrt{2}} \\ &(1 + \sqrt{2})^3 = 7 + 5\sqrt{2} \Rightarrow r_{c} = \frac{7}{5} = p_{3\sqrt{2}} \end{align*}etc. This pattern also appears to hold for other values of $$b$$, as long as $$a = \lfloor \sqrt{b} \rfloor$$. For example, the continued fraction of $$\sqrt{5}$$ is $$2 + \cfrac{1}{4 + \cfrac{1}{4 + \cfrac{1}{4 + \cfrac{1}{4 + \cdots}}}}$$and the first few partial fractions are $$2, \frac{9}{4}, \frac{38}{17}, \frac{161}{72}, \frac{682}{305}, \cdots$$ Looking at the powers of $$2 + \sqrt{5}$$, we have\begin{align*}&(2 + \sqrt{5})^1 = 2 + 1\sqrt{5} \Rightarrow r_{c} = \frac{2}{1} = 2 = p_{1\sqrt{5}}\\ &(2 + \sqrt{5})^2 = 9 + 4\sqrt{2} \Rightarrow r_{c} = \frac{9}{4} = p_{2\sqrt{5}} \\ &(2 + \sqrt{5})^3 = 38 + 17\sqrt{5} \Rightarrow r_{c} = \frac{38}{17} = p_{3\sqrt{5}} \end{align*}Does this method actually work for all possible $$b$$, and if so, has anyone else catalogued this yet? As someone who pursues math for fun, I find this to be a very interesting result! Also, would there be an elegant way to prove that $$r_c$$ approaches $$\sqrt{b}$$ as $$n$$, the exponent, increases to infinity? I think that the binomial theorem would be very helpful, especially the fact that $$\binom{n}{0} + \binom{n}{2} + \cdots = \binom{n}{1} + \binom{n}{3} + \cdots$$. Thank you for taking the time to read this exceptionally long post, and any help would be appreciated!

Edit: Some of the comments are mentioning that the aforementioned process fits some patterns. Could someone explain how those patterns work/are generated?

Very nice observation! We consider positive integers $$D$$ which are not perfect squares. OPs relationship can be written as \begin{align*} \color{blue}{\left(p_0+q_0\sqrt{D}\right)^{n+1}=p_n+q_n\sqrt{D}\qquad\qquad n\geq 0}\tag{1} \end{align*} with $$q_0:=1, p_0:=\left\lfloor{\sqrt{D}}\right\rfloor$$.

We obtain from (1) \begin{align*} \left(p_0+q_0\sqrt{D}\right)^{n+1}&=\left(p_0+q_0\sqrt{D}\right)^{n}\left(p_0+q_0\sqrt{D}\right)\\ &=\left(p_{n-1}+q_{n-1}\sqrt{D}\right)\left(p_0+q_0\sqrt{D}\right)\\ &=\left(p_0p_{n-1}+q_0q_{n-1}D\right)+\left(q_0p_{n-1}+p_0q_{n-1}\right)\sqrt{D} \end{align*} and derive the recurrence relation \begin{align*} \color{blue}{p_n}&\color{blue}{=p_0p_{n-1}+q_0q_{n-1}D\qquad\qquad n\geq 1}\tag{2}\\ \color{blue}{q_n}&\color{blue}{=q_0p_{n-1}+p_0q_{n-1}} \end{align*} We want to determine $$p_n,q_n$$, so that they are convergents of continued fractions. \begin{align*} \frac{p_n}{q_n}&=[a_0;a_1,\ldots,a_n]\\ &=a_0+\frac{1}{[a_1;a_2,\ldots,a_n]}\\ &=a_0+\frac{1}{a_1+\frac{1}{[a_2;a_3,\ldots,a_n]}}\\ &=a_0+\frac{1}{a_1+\frac{1}{a_2+\frac{1}{{a_3+}_{\ddots+\frac{1}{a_n}}}}}\\ \end{align*}

We recall the Key lemma from the theory of continued fractions (stated e.g. as Lemma 2.8 in Neverending Fractions by Alf van der Poorten, et al.): For each $$n\geq 1$$, we have the relation \begin{align*} \begin{pmatrix}p_n&p_{n-1}\\q_n&q_{n-1}\end{pmatrix} &=\prod_{j=0}^n\begin{pmatrix}a_j&1\\1&0\end{pmatrix}\tag{3} \end{align*}

From (3) we find by taking the determinants \begin{align*} \color{blue}{p_nq_{n-1}-p_{n-1}q_n}&=\det\begin{pmatrix}p_n&p_{n-1}\\q_n&q_{n-1}\end{pmatrix}\\ &=\det\left(\prod_{j=0}^n\begin{pmatrix}a_j&1\\1&0\end{pmatrix}\right) =\prod_{j=0}^n\det\begin{pmatrix}a_j&1\\1&0\end{pmatrix}\\ &\,\,\color{blue}{=(-1)^{n+1}}\tag{4} \end{align*}

From (2) and (4) we find the following condition which the convergents have to fulfill in order to also fulfill relation (1): \begin{align*} (-1)^{n-1}&=p_nq_{n-1}-p_{n-1}q_n\\ &=\left(p_0p_{n-1}+q_0q_{n-1}D\right)q_{n-1}-p_{n-1}\left(q_0p_{n-1}+p_0q_{n-1}\right)\\ &=p_0p_{n-1}q_{n-1}+q_0Dq_{n-1}^2-q_0p_{n-1}^2-p_0p_{n-1}q_{n-1}\\ &=q_0\left(Dq_{n-1}^2-p_{n-1}\right)\qquad\qquad n\geq 1 \end{align*} and we obtain the following relationship for $$n\geq 0$$ for the convergents: \begin{align*} \color{blue}{p_n^2-Dq_n^2=(-1)^{n-1}}\tag{5} \end{align*}

Example: Convergents of $$\sqrt{5}$$:

Taking for instance the convergents of $$\sqrt{5}$$ according to OPs calculation above: \begin{align*} \frac{2}{1},\frac{9}{4},\frac{38}{17},\frac{161}{72},\frac{682}{305} \end{align*} we find \begin{align*} \begin{array}{c|rrrrr} p_n&2&9&38&161&682\\ q_n&1&4&17&72&305\\ \color{blue}{p_n^2-5q_n^2}&\color{blue}{-1}&\color{blue}{1}&\color{blue}{-1}&\color{blue}{1}&\color{blue}{-1} \end{array} \end{align*} in accordance with the claim (5).

Norms and units in real quadratic fields

The relation (5) is essential to get more information. Given a nonsquare positive integer $$D$$ we consider the real quadratic field $$\mathbb{Q(\sqrt{D})}$$ and the ring $$\mathbb{Z[\sqrt{D}]}$$ \begin{align*} \mathbb{Q(\sqrt{D})}&=\{a+b\sqrt{D}:a,b,\in\mathbb{Q}\}\\ \mathbb{Z[\sqrt{D}]}&=\{a+b\sqrt{D}:a,b,\in\mathbb{Z}\} \end{align*}

The mapping (5) \begin{align*} &\color{blue}{N:\mathbb{Q(\sqrt{D})}^{*}\to\mathbb{Q}^{*}}\\ &\color{blue}{N\left(a+b\sqrt{D}\right)} =\left(a+b\sqrt{D}\right)\left(a-b\sqrt{D}\right)\color{blue}{=a^2-Db^2} \end{align*} is an abelian homomorphism called norm. We also note that elements \begin{align*} u=a+b\sqrt{D}\in\mathbb{Z[\sqrt{D}]} \end{align*} which are units, i.e. which fulfil $$uu^{-1}=1$$, have norm $$N(u)=N(u^{-1})=\pm 1$$. The following theorem holds:

Theorem: Given a square free number $$D$$ we consider the continued fraction representation of $$\sqrt{D}$$. This representation has a period with length $$m$$. If $$m$$ is even we take $$n:=m-1$$, if $$m$$ is odd we take $$n:=2m-1$$.

• The following is valid: The convergent $$\color{blue}{\frac{p_n}{q_n}}$$ has norm \begin{align*} p_n^2-Dq_n^2=1 \end{align*} and each number \begin{align*} \color{blue}{\left(p_n+q_n\sqrt{D}\right)^k=p_n^{(k)}+q_n^{(k)}\sqrt{D}} \end{align*} has norm $$N\left(p_n^{(k)}+q_n^{(k)}\sqrt{D}\right)=1$$.

• In fact $$p_n+q_n\sqrt{D}$$ is the generator for all solutions of Pell's equation \begin{align*} x^2-Dy^2=1 \end{align*} with given $$D$$.

Let's have a short look at this theorem in action.

Example: $$D=13$$

We have the continued fraction representation \begin{align*} \sqrt{13}=[3;\overline{1,1,1,1,6}] \end{align*} The period $$m=5$$ and we set $$n=2m-1=9$$. We calculate the convergents up to $$\frac{p_9}{q_9}$$: \begin{align*} \left(\frac{p_k}{q_k}\right)_{0\leq k\leq 9} =\left(3,4,\frac{7}{2},\frac{11}{3},\frac{18}{5},\frac{119}{33},\frac{137}{38},\frac{256}{71}, \frac{393}{169},\color{blue}{\frac{649}{180}}\right) \end{align*}

We have \begin{align*} \color{blue}{(649+180\sqrt{13})^1}\\ \color{blue}{(649+180\sqrt{13})^2}&=842\,401+233\,640\sqrt{13}\\ \color{blue}{(649+180\sqrt{13})^3}&=1\,093\,435\,849+303\,264\,540\sqrt{13} \end{align*} with \begin{align*} 649^2-13\cdot 180^2&=1\\ 842\,401^2-13\cdot 233\,640^2&=1\\ 1\,093\,435\,849^2-13\cdot 303\,264\,540^2&=1 \end{align*}

Example: $$D=31$$

We have the continued fraction representation \begin{align*} \sqrt{31}=[5;\overline{1,1,3,5,3,1,1,10}] \end{align*} The period $$m=8$$ and we set $$n=m-1=7$$. We calculate the convergents up to $$\frac{p_7}{q_7}$$: \begin{align*} \left(\frac{p_k}{q_k}\right)_{0\leq k\leq 7} =\left(5,6,\frac{11}{2},\frac{39}{7},\frac{206}{37},\frac{657}{118}, \frac{863}{15},\color{blue}{\frac{1\,520}{273}}\right) \end{align*}

We have \begin{align*} \color{blue}{(1\,520+273\sqrt{31})^1}\\ \color{blue}{(1\,520+273\sqrt{31})^2}&=4\,620\,799+829\,920\sqrt{31}\\ \color{blue}{(1\,520+273\sqrt{31})^3}&=14\,047\,227\,440+2\,522\,956\,527\sqrt{31} \end{align*} with \begin{align*} 1\,520^2-31\cdot273^2&=1\\ 4\,620\,799^2-31\cdot 829\,920^2&=1\\ 14\,047\,227\,440^2-31\cdot 2\,522\,956\,527^2&=1 \end{align*}

Note: The following information was helpful

• Thank you so much for the thourough, in-depth explanation! Sep 18, 2021 at 21:41
• @CogentCoder: You're welcome! :-) Sep 19, 2021 at 2:33