# On the Structure of the Continued Fraction of $\sqrt{d}$

Amrik Singh Nimbran  B3-304, Palm Grove Heights, Ardee City, Gurugram,
Haryana, India 122003<EMAIL_ADDRESS>
###### Abstract.

We examine the structure of the continued fraction of $\sqrt{d}$, and give
formulae for the repeated partial quotients in its period.

###### Key words and phrases:

Continued fraction, quadratic irrational, Fibonacci number, linear recurrence,
unimodular matrix, Chebyshev polynomial of the second kind

###### 1991 Mathematics Subject Classification:

11A55, 11Y65

Motivated by discussion in Kraitchik’s book [13, Ch.III], I examined the
period of the continued fraction expansion of $\sqrt{d}$ with $d$ a non-square
positive integer. The aim was to seek patterns in the structure of its period.
My investigation resulted in some new formulas relating to the structure of
$\sqrt{d}$’s period: its _central term_ when the period-length is even, and
the _repeated partial quotients_. The paper is primarily a discussion of the
methods used in obtaining these formulas. We will use linear recurrences and
$2\times 2$ _unimodular_ matrices whose determinant equals $\pm 1.$ A ‘cousin’
of Chebyshev polynomial of the second kind will also be introduced in the
paper.

##  1\. Introduction

Irrational square roots entered into mathematics with the Pythagorean theorem
which led to the discovery of the irrationality of $\sqrt{2}$. R. Bombelli
(_Algebra_ , 1572) and P. Cataldi (_Trattato del modo brevissimo di trouare la
Radici quadra delli numeri_ , 1613), both from Bologna (Italy), introduced
continued fractions for square roots.

For a real number $\alpha$, an expression of the form

$\alpha=a_{0}+\cfrac{1}{a_{1}+\cfrac{1}{a_{2}+\cfrac{1}{a_{3}+\dotsb}}}$

with $a_{i}\in\mathbb{N}$ for $i\geq 1,$ is called a _simple continued
fraction_ (scf) of $\alpha$. It is generally denoted by a space-saving
symbolism: $\left[a_{0};a_{1},a_{2},a_{3},\dots\right].$ The integers
$a_{i}$’s are called _partial quotients_. The rational number represented by
the truncated continued fraction
$\left[a_{0};a_{1},a_{2},a_{3},\dots,a_{n}\right]$, having initial $n+1$ terms
from $a_{0}$ up to and including $a_{n}$, is called the $n$th _convergent_
($c_{n}$) of $\alpha$. (The calculation is carried out in reverse order
beginning from tail.)

Define the sequences $\\{p_{k}\\}$, $\\{q_{k}\\}$:

$\displaystyle p_{-2}=0,\quad p_{-1}=1,\quad
p_{k}=a_{k}~{}p_{k-1}+p_{k-2}\;\text{for}\;k\geq 0,$ (1.1) $\displaystyle
q_{-2}=1,\quad q_{-1}=0,\quad q_{k}=a_{k}~{}q_{k-1}+q_{k-2}\;\text{for}\;k\geq
0.$ (1.2)

Then $\displaystyle[a_{0};a_{1},\dots,a_{k}]=\frac{p_{k}}{q_{k}}.$

If the quotients repeat from a point $r$ onward, i.e.,
$a_{m\ell+r+k}=a_{r+k},\,m\in\mathbb{N},\,0\leq k\leq\ell$, with period’s
length $\ell$, then the scf is said to be _periodic_ and written as
$\displaystyle\left[a_{0};a_{1},a_{2},\dots
a_{r-1},\overline{a_{r},a_{r+1},a_{r+2},\dots,a_{\ell+r-1}}\right].$ Euler [7]
proved that the value of every periodic scf is a quadratic irrational of the
form $\frac{P+\sqrt{d}}{Q}$ with $P,Q\in\mathbb{Z},~{}Q\neq 0$ and
$d\in\mathbb{Z}^{+}$ not a perfect square. It is a solution of some quadratic
equation having integral coefficients: $ax^{2}+bx+c=0$ ($a\neq 0$) whose
_discriminant_ $d:=b^{2}-4ac$ is not a perfect square. In 1770, Lagrange
proved the converse of Euler’s theorem that each quadratic irrational has a
periodic scf expansion. If the scf repeats from the beginning,
$[\overline{a_{0},a_{1},\dots,a_{n}}]$, it is called _purely_ periodic. Galois
proved in 1828 that the scf of $x=\frac{P+\sqrt{d}}{Q}$ is purely periodic if
and only if $x>1$ and its conjugate $\bar{x}=\frac{P-\sqrt{d}}{Q}$ satisfies
$-1<\bar{x}<0$.

We describe here the continued fraction algorithm for $\sqrt{d}$ for the sake
of completeness. (See [22, Ch 8.4] for more details.) To begin with, we put
$a_{0}=\left[\sqrt{d}\right]=P_{1}$, the greatest integer $<\sqrt{d}$, and
$d-a_{0}^{2}=Q_{1}$. Then

$\displaystyle\sqrt{d}=a_{0}+(\sqrt{d}-a_{0})=a_{0}+\frac{{d-a_{0}^{2}}}{\sqrt{d}+a_{0}}=a_{0}+\cfrac{1}{\frac{\sqrt{d}+P_{1}}{Q_{1}}}.$

Now add to and subtract from $\sqrt{d}+P_{1}$ a positive integer $P_{2}$, the
greatest integer $<\sqrt{d}$, such that $Q_{1}$ divides $P_{1}+P_{2}$ to get:
$a_{1}=\frac{P_{1}+P_{2}}{Q_{1}}$. So we have

$\frac{\sqrt{d}+P_{1}}{Q_{1}}=a_{1}+\frac{\sqrt{d}-P_{2}}{Q_{1}}=a_{1}+\frac{d-P^{2}_{2}}{Q_{1}(\sqrt{d}+P_{2})};\quad\text{thus}\;a_{1}=\left[\frac{1}{\sqrt{d}-a_{0}}\right].$

Again add to and subtract from $\sqrt{d}+P_{2}$ a positive integer $P_{3}$,
the greatest integer $<\sqrt{d}$, such that $Q_{2}$ divides $P_{2}+P_{3}$ to
get: $a_{2}=\frac{P_{2}+P_{3}}{Q_{2}}$. So we have

$\frac{\sqrt{d}+P_{2}}{Q_{2}}=a_{2}+\frac{\sqrt{d}-P_{3}}{Q_{2}}=a_{2}+\frac{d-P^{2}_{3}}{Q_{2}(\sqrt{d}+P_{3})};\quad\text{thus}\;a_{2}=\left[\frac{1}{\frac{1}{\sqrt{d}-a_{0}}-a_{1}}\right].$

We repeat the process until we get $Q_{n}=1$ for some $n$ when the partial
quotients will begin to repeat themselves. Since $1\leq P_{i}\leq[\sqrt{d}]$,
$P_{i}$ can take on only a limited number of integral values. Consequently,
$Q_{i}$ too assumes the same number of associated values as we have:
$Q_{n}Q_{n-1}=d-P_{n}^{2};\,a_{n}Q_{n}=P_{n}+P_{n+1}.$ (See Theorem 8.1 in
[10, pp.262-263].)

The period of the scf of $\sqrt{d}$, with $d$ not a square, is symmetrical and
for period length $\ell$ its form is:
$\sqrt{d}=\left[a_{0};~{}\overline{a_{1},a_{2},a_{3},\dots,a_{\ell-3},a_{\ell-2},a_{\ell-1},2a_{0}}\right]$
with $a_{1}=a_{\ell-1},\,a_{2}=a_{\ell-2},\dots$ So,
$a_{1},a_{2},\dots,a_{\ell-1}$ form a palindrome. The palindrome may or may
not have a central term. When $\ell(d)=2n$, the period is symmetric around
$a_{n}$ with $a_{n+1}=a_{n-1},\,a_{n+2}=a_{n-2}$ and so on. If $\ell(d)=2n+1$,
then $a_{n+1}=a_{n},\,a_{n+2}=a_{n-1}$ and so on. $\ell(d)$ is odd if and only
if $d=a^{2}+b^{2},\,(a,b)=1$.[2, 20] In the scf of $\sqrt{d}$ with period
length $\ell$, each partial quotient $a_{k}$ for $0\leq k<\ell$ satisfies
$a_{k}<\sqrt{d}$. [14, p.245, 3(f)]

##  2\. Tools and preliminary results

###  2.1. Linear recurrences

The general form of linear recurrences is: $u_{n+1}=a~{}u_{n}+b~{}u_{n-1}$
where $a\in\mathbb{Z}^{+},\;b\in\mathbb{Z}\setminus\\{0\\}$, and two initial
values $u_{0},\,u_{1}$ are given. Its characteristic equation is:
$x^{2}-ax-b=0.$ If $\alpha>0,\,\beta<0$ are its roots, then
$\alpha+\beta=a,\;\alpha\cdot\beta=-b,\;\alpha-\beta=\sqrt{a^{2}+4b}.$ If two
numbers $\lambda,\,\mu$ can be chosen which satisfy
$\lambda+\mu=u_{0};\;\alpha\lambda+\beta\mu=u_{1},$ then
$u_{n}=\lambda\alpha^{n}+\mu\beta^{n}$ for $n=0,1,2,\dots$ [16, p.199,
Th.4.10, eq(4.5)]

The recurrences appearing in this paper mostly have $u_{0}=0,\,u_{1}=1$ and:
(i). $a=2,b=1$; (ii). $a=4,b=-1$; (iii). $a=2m+1\,(m\in\mathbb{N}_{0}),\,b=1$
and (iv). $a=m,\,b=1;\;a=4m,\,b=m\,(m\in\mathbb{N}).$

###  2.2. Two useful expansions

Consider the quadratic equation:

$x^{2}-(2m+1)x-1=0,$ (2.1)

whose two roots are given by

$x=\frac{2m+1\pm\sqrt{(2m+1)^{2}+4}}{2}.$ (2.2)

Now the equation (2.1) can be written as

$x=(2m+1)+\frac{1}{x}.$ (2.3)

Putting the RHS of (2.3) for $x$ repeatedly, and the positive root from (2.2)
on the LHS of the preceding equation leads to:

$\frac{2m+1+\sqrt{(2m+1)^{2}+4}}{2}=2m+1+\cfrac{1}{2m+1+\cfrac{1}{2m+1+\cfrac{1}{2m+1+\dotsb}}}$

which is usually denoted by $[2m+1;\overline{2m+1}]$. The convergents of this
continued fraction are given by

$\frac{u_{2}}{u_{1}},\,\frac{u_{3}}{u_{2}},\dots,\frac{u_{n+1}}{u_{n}},\dots$

where $u_{n}$ ($n=0,1,2,\dots)$ has the closed form:

$u_{n}=\frac{\left(2m+1+\sqrt{(2m+1)^{2}+4}\right)^{n}-\left(2m+1-\sqrt{(2m+1)^{2}+4}\right)^{n}}{2^{n}~{}\sqrt{(2m+1)^{2}+4}}.$
(2.4)

Note that $u_{n}$ is even when $n=3r$, and odd when $n=3r+1,\,3r+2.$

$m=0$ yields a purely periodic scf for the _golden ratio_ :

$\varphi:=\frac{1+\sqrt{5}}{2}=1+\cfrac{1}{1+\cfrac{1}{1+\cfrac{1}{1+\dotsb}}}$

$\varphi$’s convergents are:

$\frac{1}{1},\frac{2}{1},\frac{3}{2},\frac{5}{3},\frac{8}{5},\frac{13}{8},\frac{21}{13},\dots,\frac{F_{n+1}}{F_{n}},\dots$

where $F_{n}$ being the $n$-th the Fibonacci number. The Fibonacci sequence
$\left(F_{n}\right)_{n\geq 0}$ is given by the recurrence relation:
$\displaystyle F_{n+1}=F_{n}+F_{n-1}$ for $n\geq 1$ and $F_{0}=0,\;F_{1}=1.$
With $\displaystyle
a=b=1,\alpha=\frac{1+\sqrt{5}}{2},\,\beta=\frac{1-\sqrt{5}}{2},\lambda=\frac{1}{\sqrt{5}},\mu=-\frac{1}{\sqrt{5}}$,
we get the formula given by Euler[8, §5] and later by Binet[3, p.563]:

$F_{n}=\frac{1}{\sqrt{5}}\left[\left(\frac{1+\sqrt{5}}{2}\right)^{n}-\left(\frac{1-\sqrt{5}}{2}\right)^{n}\right].$

Lucas[15, (21)] recorded this representation ($n\geq 1$):

$\frac{1}{2}\frac{(1+\sqrt{5})^{n+1}-(1-\sqrt{5})^{n+1}}{(1+\sqrt{5})^{n}-(1-\sqrt{5})^{n}}=1+\cfrac{1}{1+\cfrac{1}{1+\cfrac{1}{1+\dotsb}}}$

It is obvious that $x^{2}-2mx-k=0$ ($m\in\mathbb{N},\,1\leq k\leq m$) yields
the quadratic irrational $m\pm\sqrt{m^{2}+k}.$ The equation: $\displaystyle
x^{2}-2x-1=0$, having roots: $1\pm\sqrt{2},$ can be rewritten as:

$x^{2}=2x+1\Longrightarrow x=2+\frac{1}{x}.$

Substituting $2+\frac{1}{x}$ for $x$ repeatedly on the RHS with the positive
root on the LHS yields

$1+\sqrt{2}=2+\cfrac{1}{2+\cfrac{1}{2+\cfrac{1}{2+\dotsb}}}\Longrightarrow\sqrt{2}=1+\cfrac{1}{2+\cfrac{1}{2+\cfrac{1}{2+\dotsb}}}$

where the left scf is purely periodic unlike the right one. In general, the
scf of $\sqrt{d}$ is not purely periodic while that of $[\sqrt{d}]+\sqrt{d}$,
where $[\sqrt{d}]$ denotes the greatest integer less than $\sqrt{d},$ is
purely periodic.

The convergents of $\sqrt{2}=[1;\overline{2}]$ are given by
$\displaystyle\frac{p_{n+1}}{q_{n+1}}=\frac{2p_{n}+p_{n-1}}{2q_{n}+q_{n-1}}$
for $n\geq 1,\,p_{0}=1,q_{0}=0,p_{1}=1,q_{1}=1$:

$\frac{1}{1},\;\frac{3}{2},\;\frac{7}{5},\;\frac{17}{12},\;\frac{41}{29},\;\frac{99}{70},\;\frac{239}{169},\dots$

The numerators and denominators occur in https://oeis.org/A001333 and
https://oeis.org/A000129 with the closed forms:

$p_{k}=\frac{(1+\sqrt{2})^{k}+(1-\sqrt{2})^{k}}{2};\quad
q_{k}=\frac{(1+\sqrt{2})^{k}-(1-\sqrt{2})^{k}}{2\sqrt{2}}.$

from these two closed forms we obtain

$p_{k}+q_{k}=\frac{(1+\sqrt{2})^{k+1}-(1-\sqrt{2})^{k+1}}{2\sqrt{2}}=q_{k+1},$
(2.5)

and

$p_{k}+2q_{k}=\frac{(1+\sqrt{2})^{k+1}+(1-\sqrt{2})^{k+1}}{2}=p_{k+1}.$ (2.6)

###  2.3. Matrix method in continued fractions

####  2.3.1. A correspondence between matrices and convergents

Given a sequence $a_{0},a_{1},a_{2},\dots,$ and defining
$A_{k}:=\begin{bmatrix}a_{k}&1\\\ 1&0\end{bmatrix},$ we have this
correspondence:

$\prod_{k=0}^{n}A_{k}=\begin{bmatrix}p_{n}&p_{n-1}\\\
q_{n}&q_{n-1}\end{bmatrix}\quad\text{for}\;n=0,1,2,\dots,$ (2.7)

if and only if $\displaystyle\frac{p_{n}}{q_{n}}=[a_{0};a_{1},\dots,a_{n}]$
for $n=0,1,2,\dots.$ This sets up a correspondence between certain products of
$2\times 2$ matrices and continued fractions. (see [5, p.28] [9] [11, p.244]
[18, p.99] [19, p.87]). Note that all the matrices occurring in the product
are unimodular with $\det\begin{vmatrix}p_{n}&p_{n-1}\\\
q_{n}&q_{n-1}\end{vmatrix}=p_{n}q_{n-1}-q_{n}p_{n-1}=(-1)^{n-1}.$ Writing
$\alpha=a_{0}+\frac{1}{\alpha_{1}}\;(\alpha_{1}>1),\,\alpha_{1}=a_{1}+\frac{1}{\alpha_{2}}\;(\alpha_{2}>1)$
and $\alpha_{n}=a_{n}+\frac{1}{\alpha_{n+1}}\;(\alpha_{n+1}>1)$, Davenport [6,
80, eq(14)] obtained his “most serviceable formula” expressing $\alpha$ in
terms of the _complete quotient_ $\alpha_{n+1}$ and the two convergents
$\frac{A_{n}}{B_{n}}$ & $\frac{A_{n-1}}{B_{n-1}}$

$\alpha=\frac{\alpha_{n+1}A_{n}+A_{n-1}}{\alpha_{n+1}B_{n}+B_{n-1}}$ (2.8)

Using (2.8) for period length $\ell,$ Rippon and Taylor deduced for
$\sqrt{d}=\sqrt{a^{2}+b}$ their Lemma 1(a) which we will use in our proofs:

######  Lemma 1.

$a=a_{0};\qquad b=\frac{2a_{0}B+C}{A}$ (2.9)

$A,B,C$ being the elements of $\begin{bmatrix}A&B\\\
B&C\end{bmatrix}=\begin{bmatrix}p_{\ell-1}&p_{\ell-2}\\\
q_{\ell-1}&q_{\ell-2}\end{bmatrix}.$

Two irrational numbers $\alpha$ and $\beta$ are said to be _equivalent_ if
$A\alpha=\beta$ for some $A=\begin{bmatrix}a_{11}&a_{12}\\\
a_{21}&a_{22}\end{bmatrix}$ with integer elements and $\det A=\pm 1.$ It is
defined by the rule:
$A\alpha=\displaystyle\frac{a_{11}\alpha+a_{12}}{a_{21}\alpha+a_{22}}.$ [5,
p.37]

####  2.3.2. Powers of a matrix associated with convergents of $\sqrt{2}$

As Khovanskii [12, p.292, Ex.20] states, the matrix $\begin{bmatrix}1&2\\\
1&1\end{bmatrix}=\begin{bmatrix}p_{1}&2q_{1}\\\ q_{1}&p_{1}\end{bmatrix}$
leads to $\sqrt{2}=[1;\overline{2}]$.

######  Lemma 2.

$\begin{bmatrix}1&2\\\ 1&1\end{bmatrix}^{k}=\begin{bmatrix}p_{k}&2q_{k}\\\
q_{k}&p_{k}\end{bmatrix}.$ (2.10)

###### Proof.

The statement is obviously true for $k=1.$ Assume it to be true $k=m$ so that

$\begin{bmatrix}1&2\\\ 1&1\end{bmatrix}^{m}=\begin{bmatrix}p_{m}&2q_{m}\\\
q_{m}&p_{m}\end{bmatrix}.$

Now

$\begin{bmatrix}p_{m}&2q_{m}\\\
q_{m}&p_{m}\end{bmatrix}.\cdot\begin{bmatrix}1&2\\\
1&1\end{bmatrix}=\begin{bmatrix}p_{m}+2q_{m}&2p_{m}+2q_{m}\\\
p_{m}+q_{m}&p_{m}+2q_{m}\end{bmatrix}=\begin{bmatrix}p_{m+1}&2q_{m+1}\\\
q_{m+1}&p_{m+1}\end{bmatrix},$

by using (2.5) and (2.5). Thus we get

$\begin{bmatrix}1&2\\\
1&1\end{bmatrix}^{m+1}=\begin{bmatrix}p_{m+1}&2q_{m+1}\\\
q_{m+1}&p_{m+1}\end{bmatrix}$

The statement is thus true for $k=m+1$ also; hence for all $k.$ ∎

####  2.3.3. Matrix associated with $\sqrt{3}$

The convergents $\displaystyle\frac{p_{k}}{q_{k}}$ of
$\sqrt{3}=[1;\overline{1,2}]$ are:

$\frac{2}{1},\,\frac{5}{3},\,\frac{7}{4},\,\frac{19}{11},\,\frac{26}{15},\,\frac{71}{41},\,\frac{97}{56},\,\frac{265}{153},\dots$

whose numerators occur appear in sequence A048788 at https://oeis.org/A048788
and denominators in sequence A002530 at https://oeis.org/A002530. Note these
relations:

$\displaystyle p_{2n-1}=q_{2n}-q_{2n-1};\;p_{2n+1}=q_{2n}+q_{2n+1};$ (2.11)
$\displaystyle 3q_{2n}+2q_{2n-1}=q_{2n+2};\;3q_{2n-1}+q_{2n-2}=q_{2n+1}.$
(2.12)

The closed forms are:

$\displaystyle
p_{2n-1}=\frac{(1+\sqrt{3})^{2n}+(1-\sqrt{3})^{2n}}{2^{n+1}};\;q_{2n-1}=\frac{(1+\sqrt{3})^{2n}+(1-\sqrt{3})^{2n}}{2^{n+1}\sqrt{3}},$
$\displaystyle
p_{2n}=\frac{(1+\sqrt{3})^{2n+1}+(1-\sqrt{3})^{2n+1}}{2^{n+1}};\;q_{2n}=\frac{(1+\sqrt{3})^{2n+1}+(1-\sqrt{3})^{2n+1}}{2^{n+1}\sqrt{3}}.$

Convergents of $\displaystyle\frac{p^{\prime}_{k}}{q^{\prime}_{k}}$ of
$1+\sqrt{3}$ can be obtained by adding 1 to convergents of $\sqrt{3}$. By
using the relations (2.11) and (2.12), we can prove by induction:

######  Lemma 3.

$\begin{bmatrix}3&2\\\ 1&1\end{bmatrix}^{k}=\begin{bmatrix}q_{2k}&2q_{2k-1}\\\
q_{2k-1}&q_{2k-2}\end{bmatrix}=\begin{bmatrix}p^{\prime}_{2k-1}&2q^{\prime}_{2k-1}\\\
q^{\prime}_{2k-1}&p^{\prime}_{2k-3}\end{bmatrix},\qquad k\geq 1.$ (2.13)

####  2.3.4. Powers of a general matrix

We take up a matrix to be used later.

######  Lemma 4.

$\begin{bmatrix}2m+1&1\\\ 1&0\end{bmatrix}^{n}=\begin{bmatrix}u_{n+1}&u_{n}\\\
u_{n}&u_{n-1}\end{bmatrix},$ (2.14)

where $u_{n}$ satisfies the recurrence relation:

$u_{n+1}=(2m+1)~{}u_{n}+u_{n-1};\;\text{with}\;u_{1}=1,\,u_{0}=0.$ (2.15)

###### Proof.

The statement is obviously true for $n=1$ in view of (2.15). Assume the
statement to be true for $n=m$ so that

$\begin{bmatrix}2m+1&1\\\ 1&0\end{bmatrix}^{m}=\begin{bmatrix}u_{m+1}&u_{m}\\\
u_{m}&u_{m-1}\end{bmatrix}.$

Then

$\displaystyle\begin{bmatrix}2m+1&1\\\ 1&0\end{bmatrix}^{m+1}$
$\displaystyle=\begin{bmatrix}u_{m+1}&u_{m}\\\
u_{m}&u_{m-1}\end{bmatrix}\begin{bmatrix}2m+1&1\\\ 1&0\end{bmatrix}$
$\displaystyle=\begin{bmatrix}(2m+1)u_{m+1}+u_{m}&u_{m+1}\\\
(2m+1)u_{m}+u_{m-1}&u_{m}\end{bmatrix}$
$\displaystyle=\begin{bmatrix}u_{m+2}&u_{m+1}\\\
u_{m+1}&u_{m}\end{bmatrix}\qquad\text{by using \eqref{recurrence}}.$

So the statement is true for $n=m+1$ also. Hence true for all $n$. ∎

####  2.3.5. Proof using Chebyshev polynomials

Let $M=\begin{bmatrix}m_{11}&m_{12}\\\ m_{21}&m_{22}\end{bmatrix}$ be a
unimodular matrix. Then [4, pp.70–71]

$M^{n}=\begin{bmatrix}m_{11}~{}U_{n-1}(a)-U_{n-2}(a)&m_{12}~{}U_{n-1}(a)\\\
m_{21}~{}U_{n-1}(a)&m_{22}~{}U_{n-1}(a)-U_{n-2}(a)\end{bmatrix}$ (2.16)

where $\displaystyle a=\frac{m_{11}+m_{22}}{2}$ and $\displaystyle U_{n}$ are
the _Chebyshev polynomials of the second kind_ whose generating function is:
$\displaystyle
g(x,t)=\frac{1}{1-2xt+t^{2}}=\sum_{n=0}^{\infty}U_{n}(x)~{}t^{n}$ with
$|t|<1,\,|x|\leq 1.$ We have $U_{n}(x)$ [1, p.229, (5.98)]:

$U_{n}(x)=\sum_{k=0}^{[\frac{n}{2}]}(-1)^{k}\binom{n-k}{k}(2x)^{n-2k}.$

A first few polynomials are given below.

$\displaystyle
U_{0}(x)=1,\;U_{1}(x)=2x,\;U_{2}(x)=(2x)^{2}-1,\;U_{3}(x)=(2x)^{3}-2(2x),$
$\displaystyle
U_{4}(x)=(2x)^{4}-3(2x)^{2}+1,\;U_{5}(x)=(2x)^{5}-4(2x)^{3}+3(2x).$

They satisfy the recurrence relation: $U_{n+1}(x)=2x~{}U_{n}(x)-U_{n-1}(x).$
[1, p.230, (5.100)] Note that $a=2x,\,b=-1$ in the recurrence.

Careful examination of the polynomial with all $[\frac{n}{2}]+1$ positive
terms (in descending order of the powers of $x$) generated by

$U^{\prime}_{n}(x):=\frac{\left(x+\sqrt{1+x^{2}}\right)^{n+1}-\left(x-\sqrt{1+x^{2}}\right)^{n+1}}{2~{}\sqrt{1+x^{2}}},\;n=0,1,2,\dots$
(2.17)

shows that the introduction of the sign scheme ($+~{}-$) in
$U^{\prime}_{n}(x)$ transforms it into $U_{n}(x)$. $U^{\prime}_{n}(x)$ comes
from $t^{2}\rightarrow-t^{2}$ in the generating function.

With $m_{11}=2m+1,\,m_{22}=0\Rightarrow\displaystyle a=\frac{2m+1}{2}$, we
get:

$\begin{bmatrix}2m+1&1\\\
1&0\end{bmatrix}^{n}=\begin{bmatrix}(2m+1)~{}U_{n-1}(\frac{2m+1}{2})-U_{n-2}(\frac{2m+1}{2})&U_{n-1}(\frac{2m+1}{2})\\\
U_{n-1}(\frac{2m+1}{2})&-U_{n-2}(\frac{2m+1}{2})\end{bmatrix}$

and on using the recurrence relation for these polynomials:

$\begin{bmatrix}2m+1&1\\\
1&0\end{bmatrix}^{n}=\begin{bmatrix}U_{n}(\frac{2m+1}{2})&U_{n-1}(\frac{2m+1}{2})\\\
U_{n-1}(\frac{2m+1}{2})&-U_{n-2}(\frac{2m+1}{2})\end{bmatrix}=\begin{bmatrix}u_{n+1}&u_{n}\\\
u_{n}&u_{n-1}\end{bmatrix}$ (2.18)

changing the subscript from $n$ to $n+1$ as $U_{0}=u_{1}=1$. $u_{n}$ is
obtained by setting $x=\frac{2m+1}{2}$ in (2.17) and was given earlier in
(2.4).

##  3\. Formulas without a central term or the central term $<a_{0}$

###  3.1. Formulas without central term or central term $<a_{0}-1$

####  3.1.1. Formulas with $\ell(d)=1$

The only formula was noted by Euler:

$\sqrt{n^{2}+1}=[n;\overline{2n}];\quad n\geq 1.$ (3.1)

####  3.1.2. Formulas with $\ell(d)=2$

These two formulas can be easily established.

$\sqrt{(mn)^{2}+n}=[mn;\overline{2m,2mn}];\quad m,n\geq 1.$ (3.2)
$\sqrt{(mn)^{2}+2n}=[mn;\overline{m,2mn}];\quad m,n\geq 1.$ (3.3)

It can be shown without difficulty that these are the only possibilities.

####  3.1.3. Formula with $\ell(d)=3$

For the most general case with period 3, we have
$\sqrt{d}=[a;b,b,2a,b,b,2a,\dots].$ Then $\sqrt{d}=a+y$ with
$y=[0;b,b,2a,b,b,2a,\dots].$ So we get

$y=\cfrac{1}{b+\cfrac{1}{b+\cfrac{1}{2a+y}}}=\frac{2ab+by+1}{2ab^{2}+2a+by^{2}+b+y}$

or

$y^{2}+2ay-\frac{2ab+1}{b^{2}+1}=0.$

Solving the resultant quadratic equation, we get the positive root:
$y\displaystyle=-a+\sqrt{a^{2}+\frac{2ab+1}{b^{2}+1}}$. Combining with the
leading $a$, we obtain $d\displaystyle=a^{2}+\frac{2ab+1}{b^{2}+1}$. For $d$
to be an integer, $b^{2}+1$ must divide $2ab+1$. Let
$\displaystyle\frac{2ab+1}{b^{2}+1}=k.$ _WolframAlpha_ gives its general
solution over the integers:

$b=2c_{1},~{}a=4c_{2}c_{1}^{2}+c_{1}+c_{2},~{}k=4c_{1}c_{2}+1;\quad
c_{1},c_{2}\in\mathbb{Z}.$

This leads, on setting $c_{1}=m,~{}c_{2}=n,$ to Perron’s formula [17, p.100]:

$\displaystyle\sqrt{\\{(4m^{2}+1)n+m\\}^{2}+4mn+1}=[(4m^{2}+1)n+m;$
$\displaystyle\overline{2m,2m,2\\{(4m^{2}+1)n+m\\}}].$ (3.4)

####  3.1.4. Formula with $\ell(d)=5$

This formula will be used in a later section:

$\sqrt{(2n+1)^{2}+4}=[2n+1;~{}\overline{n,1,1,n,4n+2}].$ (3.5)

The same procedure applied to $y=[0;\frac{a-1}{2},1,1,\frac{a-1}{2},2a+y$
gives equation $y^{2}+2ay-4=0$ which yields $y=-a\pm\sqrt{a^{2}+4}$
establishing the formula.

###### Proof.

We prove it by the continued fraction algorithm outlined above.

$\sqrt{(2n+1)^{2}+4}=(2n+1)+\frac{1}{\displaystyle\frac{\sqrt{(2n+1)^{2}+4}+(2n+1)}{4}};\;a_{0}=2n+1.$

Next

$\frac{\sqrt{(2n+1)^{2}+4}+(2n+1)}{4}=n+\frac{\sqrt{(2n+1)^{2}+4}-(2n-1)}{4}.$

So $a_{1}=n$ and the expression on the extreme right becomes

$\frac{(2n+1)^{2}+4-(2n-1)^{2}}{4[\sqrt{(2n+1)^{2}+4}+(2n-1)]}=\frac{2n+1}{\sqrt{(2n+1)^{2}+4}+(2n-1)}$

which on being inverted becomes

$\frac{\sqrt{(2n+1)^{2}+4}+(2n-1)}{2n+1}=1+\frac{\sqrt{(2n+1)^{2}+4}-2}{2n+1}.$

So $a_{2}=1$ and the expression on the extreme right becomes

$\frac{(2n+1)^{2}}{(2n+1)[\sqrt{(2n+1)^{2}+4}+2)]}=\frac{2n+1}{\sqrt{(2n+1)^{2}+4}+2}$

which on being inverted becomes

$\frac{\sqrt{(2n+1)^{2}+4}+2+2n-2n}{2n+1}=1+\frac{\sqrt{(2n+1)^{2}+4}-(2n-1)}{2n+1}.$

So $a_{3}=1$ and the expression on the extreme right becomes

$\frac{4}{\sqrt{(2n+1)^{2}+4}+(2n-1)}$

which on being inverted becomes

$\frac{\sqrt{(2n+1)^{2}+4}+(2n-1)}{4}=n+\frac{\sqrt{(2n+1)^{2}+4}-(2n+1)}{4}.$

So $a_{4}=n$ and the expression on the extreme right becomes

$\frac{1}{\sqrt{(2n+1)^{2}+4}+(2n+1)}=\frac{1}{(4n+2)+\sqrt{(2n+1)^{2}+4}-(2n+1)}.$

Thus $a_{5}=4n+2$ and the loop starts again. ∎

######  Proposition 1.

Let $1\leq a_{n}<a_{0}-1$ be a central term of the period of the scf of
$\sqrt{d}=\sqrt{a^{2}+b}$. Then

$\displaystyle a_{n}\equiv 1\pmod{2}\Longleftrightarrow a\equiv b\equiv
0\pmod{2},$ $\displaystyle a_{n}\equiv 0\pmod{2}\Longleftrightarrow a\equiv
b\equiv 1\pmod{2}.$

####  3.1.5. Formula with $\ell(d)=6$

This formula is provable by the algorithm:

$\sqrt{(2n+2)^{2}+(4n+1)}=[2n+2;~{}\overline{1,n,2,n,1,4n+4}];\quad
n\in\mathbb{N}.$ (3.6)

We now list formulas with particular values for $n=0,1,2,\dots$ (except the
second which holds for $n\geq 1$):

$\displaystyle\sqrt{(45n+14)^{2}+(38n+12)}$
$\displaystyle=[45n+14;~{}\overline{2,2,{\bf 1},2,2,2(45n+14)}],$
$\displaystyle\sqrt{(35n+1)^{2}+(29n+1)}$
$\displaystyle=\left[35n+1;\overline{2,2,2,{\bf 2},2,2(35n+1)}\right],$
$\displaystyle\sqrt{(95n+68)^{2}+(78n+56)}$
$\displaystyle=[95n+68;~{}\overline{2,2,{\bf 3},2,2,2(95n+68)}],$
$\displaystyle\sqrt{(60n+50)^{2}+(49n+41)}$
$\displaystyle=[60n+50;~{}\overline{2,2,{\bf 4},2,2,2(60n+50)}],$
$\displaystyle\sqrt{(145n+17)^{2}+(2(59n+7))}$
$\displaystyle=[145n+17;~{}\overline{2,2,{\bf 5},2,2,2(145n+17)}],$
$\displaystyle\sqrt{(85n+54)^{2}+(69n+44)}$
$\displaystyle=[85n+54;~{}\overline{2,2,{\bf 6},2,2,2(85n+54)}],$
$\displaystyle\sqrt{(195n+101)^{2}+(158n+82)}$
$\displaystyle=[195n+101;~{}\overline{2,2,{\bf 7},2,2,2(195n+101)}],$
$\displaystyle\sqrt{(110n+48)^{2}+(89n+39)}$
$\displaystyle=[110n+48;~{}\overline{2,2,{\bf 8},2,2,2(110n+48)}].$

When the middle term is odd, the coefficient of $n$ in square quantity goes up
by 50 and that of $n$ in linear quantity rises by 40 when we step up to the
next odd number. If the middle term is even, the first term increases by 25
and the second by 20 while going to the next even number.

####  3.1.6. Formulas with $\ell(d)=7$

We have for $n=0,1,2,\dots,$ these formulae

$\displaystyle\sqrt{(13n+7)^{2}+(16n+8)}$
$\displaystyle=[13n+7;~{}\overline{1,1,1,1,1,1,2(13n+7)}],$
$\displaystyle\sqrt{(29n+27)^{2}+(34n+32)}$
$\displaystyle=[29n+27;~{}\overline{1,1,2,2,1,1,2(29n+27)}],$
$\displaystyle\sqrt{(53n+43)^{2}+(60n+49)}$
$\displaystyle=[53n+43;~{}\overline{1,1,3,3,1,1,2(53n+43)}],$
$\displaystyle\sqrt{(85n+16)^{2}+(94n+18)}$
$\displaystyle=[85n+16;~{}\overline{1,1,4,4,1,1,2(85n+16)}],$
$\displaystyle\sqrt{(125n+8)^{2}+(136n+9)}$
$\displaystyle=[125n+8;~{}\overline{1,1,5,5,1,1,2(125n+8)}].$

We see that the coefficient of the $n$ term in the square part equals
$(2m+1)^{2}+4$, if we denote the two identical middle terms by $m$, and the
coefficient of $n$ in the linear term is $(2m+1)^{2}+2m+5.$ However, the
constant terms do not exhibit any pattern.

The following formulas form another group.

$\displaystyle\sqrt{(25n+17)^{2}+(36n+25)}$
$\displaystyle=[25n+17;~{}\overline{1,2,1,1,2,1,2(25n+17)}],$
$\displaystyle\sqrt{(109n+52)^{2}+(152n+73)}$
$\displaystyle=[109n+52;~{}\overline{1,2,3,3,2,1,2(109n+52)}],$
$\displaystyle\sqrt{\\{5(53n+49)\\}^{2}+(364n+337)}$
$\displaystyle=[5(53n+49);~{}\overline{1,2,5,5,2,1,10(53n+49)}],$
$\displaystyle\sqrt{(493n+18)^{2}+(672n+25)}$
$\displaystyle=[493n+18;~{}\overline{1,2,7,7,2,1,2(493n+18)}].$

No formula exists with pattern: $1,2,2m,2m,2,1$.

####  3.1.7. Formula with $\ell(d)=8$

This formula with three general terms can be proved by the algorithm:

$\sqrt{(4n+5)^{2}+(8n+3)}=[4n+5;~{}\overline{1,n,2,2n+2,2,n,1,2(4n+5)}];\;n\in\mathbb{N}.$
(3.7)

####  3.1.8. Formula with $\ell(d)=9$

The following formulas with particular values are valid for $n=0,1,2,\dots$

$\displaystyle\sqrt{(73n+10)^{2}+(92n+13)}$
$\displaystyle=[73n+10;~{}\overline{1,1,1,2,2,1,1,1,2(73n+10)}],$
$\displaystyle\sqrt{(509n+321)^{2}+(602n+380)}$
$\displaystyle=[509n+321;~{}\overline{1,1,2,4,4,2,1,1,2(509n+321)}],$
$\displaystyle\sqrt{(1985n+254)^{2}+(2256n+289)}$
$\displaystyle=[1985n+254;~{}\overline{1,1,3,6,6,3,1,1,2(1985n+254)}].$

We also have:

$\sqrt{(1949n+201)^{2}+(720n+281)}=[1949n+201;~{}\overline{1,2,3,4,4,3,2,1,2(1949n+201)}].$

####  3.1.9. Formula with $\ell(d)=10$

We have ($n=0,1,2,\dots$) this nice pattern:

$\displaystyle\sqrt{\\{5(2021n+965)\\}^{2}+(14102n+6734)}$
$\displaystyle=[5(2021n+965);~{}\overline{1,2,3,4,5,4,3,2,1,10(2021n+965)}].$

###  3.2. Formulas with central term $=a_{0}-1$

####  3.2.1. Formula with $\ell(d)=4$

It is easy to establish by the algorithm that [17, p.110]:

$\sqrt{n^{2}+(2n-1)}=[n;\overline{1,n-1,1,2n}],n\geq 2.$ (3.8)

For period length $\ell(d)>4,$ we have

######  Proposition 2.

Let $a_{n}=a_{0}-1$ be the central term of the period of the scf of
$\sqrt{d}=\sqrt{a^{2}+b}$. Then $a\equiv 1\pmod{2}\Longleftrightarrow b\equiv
1\pmod{4}$ and $a\equiv 0\pmod{2}\Longleftrightarrow b\equiv 3\pmod{4}$.

It implies that $b$ is always odd.

####  3.2.2. Formula with $\ell(d)=10$

Kraitchik [13, p.49] gives for $n=0,1,2,\dots$

$\sqrt{(9n+6)^{2}+(10n+7)}=[9n+6;~{}\overline{1,1,3,1,9n+5,1,3,1,1,18n+12}].$

We have:

$\sqrt{(11n+9)^{2}+(6n+5)}=[11n+9;~{}\overline{3,1,1,1,11n+8,1,1,1,3,2(11n+9)}].$
(3.9)

$\sqrt{(27n+8)^{2}+(10n+3)}=[27n+8;~{}\overline{5,2,1,1,27n+7,1,1,2,5,2(27n+8)}].$
(3.10)

####  3.2.3. Formula with $\ell(d)=12$

I discovered, for $n=0,1,2,\dots$, this formula:

$\displaystyle\sqrt{(47n+10)\\}^{2}+(14n+3)}$
$\displaystyle=[47n+10;~{}\overline{6,1,2,1,1,47n+9,1,1,2,1,6,2(47n+10)}].$
(3.11)

####  3.2.4. Formula with $\ell(d)=14$

I also discovered, for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(33n+11)^{2}+(38n+13)}$
$\displaystyle=[(33n+11;~{}\overline{1,1,2,1,3,1,(33n+10,1,3,1,2,1,1,2((33n+11)}].$
(3.12)

####  3.2.5. Formula with $\ell(d)=16$

Further, I discovered, for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(151n+9)^{2}+(210n+13)}$
$\displaystyle=[151n+9;~{}\overline{1,2,3,1,1,5,1,151n+8,1,5,1,1,3,2,12(151n+9)}].$
(3.13)

####  3.2.6. Formula with $\ell(d)=18$

Furthermore, we have for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(627n+12)^{2}+(962n+19)}$
$\displaystyle=[627n+12;~{}\overline{1,3,3,2,1,1,7,1,627n+11,1,7,1,1,2,3,3,1,2(627n+12)}].$
(3.14)

####  3.2.7. Formula with $\ell(d)=20$

Furthermore, we have for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(3383n+12)^{2}+(1950n+7)}$
$\displaystyle=[3383n+12;~{}\overline{3,2,7,1,3,4,1,1,1,3383n+11,1,1,1,4,3,1,7,2,3,2(3383n+12)}],$
(3.15) $\displaystyle\sqrt{(9041n+14)^{2}+(1930n+3)}$
$\displaystyle=[9041n+14;~{}\overline{9,2,1,2,2,5,4,1,1,9041n+13,1,1,4,5,2,2,1,2,9,2(9041n+14)}].$
(3.16)

###  3.3. Formula with repeated 2’s

Perron gives this formula [17, p.114]:

$\sqrt{(3n+1)^{2}+(2n+1)}=[3n+1;~{}\overline{2,1,3n,1,2,6n+2}].$

It can be verified that no formula exists if 1 is replaced with any other
number in the pattern. Kraitchik [13, p.47] gives this formula:

$\sqrt{(7n+1)^{2}+(6n+1)}=[7n+1;~{}\overline{2,2,1,7n,1,2,2,14n+2}].$

I found the continuation of the previous two formulas:

$\sqrt{(17n+1)^{2}+(14+1)}=[34n+1;~{}\overline{2,2,2,1,17n,1,2,2,2,34n+2}],$

and

$\displaystyle\sqrt{(41n+1)^{2}+(34n+1)}=\left[41n+1;\right.$
$\displaystyle\left.\overline{2,2,2,2,1,41n,1,2,2,2,2,82n+2}\right],$

both of which can be easily proved by means of the algorithm. In fact, these
four formulas are special cases of the theorem:

######  Theorem 1.

Let $p_{k}$ is the numerator in the $k$-th convergent of $\sqrt{2}$. Then

$\displaystyle\sqrt{(p_{k+1}~{}n+1)^{2}+(2p_{k}~{}n+1)}=\left[(p_{k}n+1);\right.$
$\displaystyle\left.\overline{2~{}\text{repeated}~{}k~{}\text{times},1,(p_{k+1}n),1,2~{}\text{repeated}~{}k~{}\text{times},2(p_{k+1}n+1)}\right].$

###### Proof.

Let us recall the formula (2.9) and Lemma 2. The first few powers of the
matrix associated with the scf of $\sqrt{2}$ follow.

$\begin{bmatrix}1&2\\\ 1&1\end{bmatrix}^{2}=\begin{bmatrix}3&4\\\
2&3\end{bmatrix};\quad\begin{bmatrix}1&2\\\
1&1\end{bmatrix}^{3}=\begin{bmatrix}7&10\\\ 5&7\end{bmatrix}$

and

$\begin{bmatrix}1&2\\\ 1&1\end{bmatrix}^{4}=\begin{bmatrix}17&24\\\
12&17\end{bmatrix};\quad\begin{bmatrix}1&2\\\
1&1\end{bmatrix}^{5}=\begin{bmatrix}41&58\\\ 29&41\end{bmatrix}.$

The $(k+1)$th $\&$ $k$th power matrices jointly give a formula with 2 repeated
$k$ times. Let us now apply the procedure used in deriving the scf for period
3 in subsection 3.3.3. Let $\sqrt{d}=\sqrt{a^{2}+b}=a+(\sqrt{a^{2}+b}-a)$. Put
$y=\sqrt{a^{2}+b}-a$.

If $\sqrt{d}=[a;\overline{2,1,a-1,1,2,2a}].$ Then

$y=\cfrac{1}{2+\cfrac{1}{1+\cfrac{1}{a-1+\cfrac{1}{2+\cfrac{1}{1+\cfrac{1}{y+2a}}}}}}$

after some long calculation leads to $3y^{2}+6ay-(2a+1)=0.$ Solving the
quadratic equation, we get the positive root:
$y=-a+\sqrt{a^{2}+\frac{2a+1}{3}}$. This implies that $b=\frac{2a+1}{3}$ which
must be an integer if $d$ is to be an integer. The solution $a=3n+1$ gives
$b=2n+1$.

When $\sqrt{d}=[a;\overline{2,2,1,a-1,1,2,2,2a}]$, the same procedure gives
the equation: $7y^{2}+14ay-(6a+1)=0$ whose positive root yields
$b=\frac{6a+1}{7}$ and for $d$ to be an integer we have $a=7n+1$ and $b=6n+1.$

With $\sqrt{d}=[a;\overline{2,2,2,1,a-1,1,2,2,2,2a}]$ the procedure gives the
equation: $17y^{2}+34ay-(14a+3)=0$ whose positive root yields
$b=\frac{14a+3}{17}$ and for $d$ to be an integer we have $a=17n+1$ and
$b=14n+1.$

And if 2 is repeated $k$ times in the period, using (2.9) we get the equation:
$p_{k+1}y^{2}+2p_{k+1}ay-(2p_{k}a+p_{k-1})=0$ whose positive root yields
$b=\frac{2p_{k}a+p_{k-1}}{p_{k+1}}$ and for $d$ to be an integer we have
$a=p_{k+1}n+1$ and $b=2p_{k}n+1$ where $p_{k}$ is the numerator of $c_{k}$ of
$\sqrt{2}$. ∎

##  4\. Formulae with central term $=a_{0}$

######  Proposition 3.

Let $a_{n}$ be the central term of the period of the scf of
$\sqrt{d}=\sqrt{a^{2}+b}$. Then $a_{n}=a_{0}\Longleftrightarrow b\equiv
2\pmod{4}.$

This implies that $b$ is always even, and $d\equiv a\pmod{2}$; $d$ is
odd(even) if and only if $a$ is odd(even).

###  4.1. Formulae with $\ell(d)=6$

Kraitchik [13, p.41] gives two particular formulas ($m=1,2$):

$\displaystyle\sqrt{(3n+1)^{2}+(4n+2)}=[3n+1;~{}\overline{1,2,3n+1,2,1,6n+2}],$
$\displaystyle\sqrt{(9n+2)^{2}+(8n+2)}=[9n+2;~{}\overline{2,4,9n+2,4,2,18n+4}].$

###  4.2. Formulae with $\ell(d)=8$

We find in Kraitchik’s book [13, p.47]:

$\sqrt{(7n+5)^{2}+(8n+6)}=[7n+5;~{}\overline{1,1,3,7n+5,3,1,1,14n+10}],\,n\in\mathbb{N}_{0}.$

It is a special case $(m=2)$ of a general formula for any fixed
$m\in\mathbb{N}\setminus\\{1\\}$:

$\displaystyle\sqrt{\\{(2m^{2}-1)n+2m^{2}-m-1\\}^{2}+(4mn+4m-2)}$
$\displaystyle=\left[(2m^{2}-1)n+2m^{2}-m-1;\right.$
$\displaystyle\left.\overline{m-1,1,2m-1,(2m^{2}-1)n+2m^{2}-m-1,2m-1,}\right.$
$\displaystyle\left.\overline{1,m-1,2\\{(2m^{2}-1)n+2m^{2}-m-1}\right].$ (4.1)

It can be proved by using the continued fraction algorithm. The next special
case $(m=3)$, true for $n=0,1,2,\dots$, follows.

$\sqrt{(17n+14)^{2}+(12n+10)}=[17n+14;~{}\overline{2,1,5,17n+14,5,1,2,34n+28}].$

###  4.3. Formula with $\ell(d)=10$

This formula ($n=1,2,3,\dots$) gives a combination of 1 and 2:

$\sqrt{(11n+1)^{2}+2(8n+1)}=[11n+1;~{}\overline{1,2,1,2,11n+1,2,1,2,1,22n+2}].$
(4.2)

We also have a more general formula ($n=1,2,3,\dots$):

$\sqrt{(9n+3)^{2}+18}=[9n+3;~{}\overline{n,2,1,2n,9n+3,2n,1,2,n,18n+6}].$
(4.3)

I discovered an akin formula with only four fixed quotients:

$\sqrt{(9n+6)^{2}+18}=[9n+6;~{}\overline{n,1,2,2n+1,9n+6,2n+1,2,1,n,18n+12}].$
(4.4)

We also have these formulas ($n=0,1,2,\dots$)

$\displaystyle\sqrt{(17n+15)^{2}+(20n+18)}=[17n+15;$
$\displaystyle\overline{1,1,2,3,17n+15,3,2,1,1,2(17n+15)}].$ (4.5)

$\displaystyle\sqrt{(27n+18)^{2}+(44n+30)}=[27n+18;$
$\displaystyle\overline{1,4,2,2,27n+18,2,2,4,1,54n+36}].$ (4.6)

$\displaystyle\sqrt{(33n+21)^{2}+(28n+18)}=[33n+21;$
$\displaystyle\overline{2,2,1,4,33n+21,4,1,2,2,2(33n+21)}].$ (4.7)

$\displaystyle\sqrt{(321n+21)^{2}+(152n+10)}=[321n+21;$
$\displaystyle\overline{4,4,2,8,321n+21,8,2,4,4,2(321n+21)}].$ (4.8)

All these formulas can be proved easily by means of the continued fraction
algorithm.

###  4.4. Formula with $\ell(d)=12$

We find this formula in [13, p.51]:

$\displaystyle\sqrt{(23n+6)^{2}+2(18n+5)}=[23n+6;$
$\displaystyle\overline{1,3,1,1,2,23n+6,2,1,1,3,1,46n+12}];\quad
n\in\mathbb{N}_{0}.$ (4.9)

I obtained this formula:

$\displaystyle\sqrt{(193n+11)^{2}+2(52n+3)}=[193n+11;$
$\displaystyle\overline{3,1,2,2,7,193n+11,7,2,2,1,3,2(193n+11)}];\quad
n\in\mathbb{N}_{0}.$ (4.10)

####  4.4.1. Formula with $\ell(d)=14$

We further have for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(153n+13)^{2}+(2(58n+5))}$
$\displaystyle=[153n+13;~{}\overline{2,1,1,1,3,5,153n+13,5,3,1,1,1,2,2(153n+13)}].$
(4.11)

####  4.4.2. Formula with $\ell(d)=16$

Furthermore, we have for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(217n+13)^{2}+(356n+22)}$
$\displaystyle=[217n+13;~{}\overline{1,4,1,1,3,2,2,217n+13,2,2,3,1,1,4,1,2(217n+13)}].$
(4.12)

####  4.4.3. Formula with $\ell(d)=18$

Furthermore, we have for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(747n+11)^{2}+2(590n+9)}$
$\displaystyle=[747n+11;~{}\overline{1,3,1,3,7,1,1,2,747n+11,2,1,1,7,3,1,3,1,2(747n+11)}].$
(4.13)

$\displaystyle\sqrt{(339n+137)^{2}+(400n+162)}=[339n+137;$
$\displaystyle\overline{1,1,2,3,1,1,2,3,339n+137,3,2,1,1,3,2,1,1,2(339n+137)}].$
(4.14)

$\displaystyle\sqrt{(1187n+850)^{2}+(1008n+722)}=[1187n+850;$
$\displaystyle\overline{2,2,1,4,2,2,1,4,1187n+850,4,1,2,2,4,1,2,2,2(1187n+850)}].$
(4.15)

####  4.4.4. Formula with $\ell(d)=20$

Furthermore, we have for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(7199n+19)^{2}+(2264n+6)}$
$\displaystyle=[7199n+19;~{}\overline{6,2,1,3,1,1,2,1,12,7199n+19,12,1,2,1,1,3,1,2,6,2(7199n+19)}].$
(4.16)

####  4.4.5. Formula with $\ell(d)=22$

Furthermore, we have for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(3201n+12)^{2}+(5660n+22)}$
$\displaystyle=[3201n+12;~{}\overline{1,7,1,1,1,2,4,1,3,2,3201n+12,2,3,1,4,2,1,1,1,7,1,2(3201n+12)}].$
(4.17)

####  4.4.6. Formula with $\ell(d)=26$

Furthermore, we have for $n=0,1,2,\dots$,

$\displaystyle\sqrt{(6763n+1354)^{2}+(7980n+1598)}=[6763n+1354;$
$\displaystyle\overline{1,1,2,3,1,1,2,3,1,1,2,3,6763n+1354,3,2,1,1,3,2,1,1,3,2,1,1,2(6763n+1354)}].$
(4.18)

$\displaystyle\sqrt{(42699n+6102)^{2}+(36260n+5182)}=[42699n+6102;$
$\displaystyle\overline{2,2,1,4,2,2,1,4,2,2,1,4,42699n+6102,4,1,2,2,4,1,2,2,4,1,2,2,2(42699n+6102)}].$
(4.19)

##  5\. Formulas with replicating pair $\\{m,\,2m\\}$, central term $=a_{0}$

Define two sequences $A_{k+1}=4A_{k}-A_{k-1},\;B_{k+1}=4B_{k}-B_{k-1}$ with
$A_{1}=3,B_{1}=1,A_{0}=1,B_{0}=0.$ Then

######  Theorem 2.

$\displaystyle\sqrt{(A_{k}~{}n+1)^{2}+2(2B_{k}~{}n+1)}=\left[A_{k}n+1;\right.$
$\displaystyle\left.\overline{\text{1 \& 2 repeated k
times},(A_{k}n+1),\text{2 \& 1 repeated k times},2(A_{k}n+1)}\right],$

###### Proof.

The sequences defined here give $A_{k}/B_{k}$:

$\frac{3}{1},\,\frac{11}{4},\,\frac{41}{15},\,\frac{153}{56},\,\frac{571}{209},\dots$

And let us now recall Lemma 3. The first five powers of the matrix are:

$\begin{bmatrix}3&2\\\ 1&1\end{bmatrix}^{2}=\begin{bmatrix}11&8\\\
4&3\end{bmatrix};\quad\begin{bmatrix}3&2\\\
1&1\end{bmatrix}^{3}=\begin{bmatrix}41&30\\\ 15&11\end{bmatrix}$
$\begin{bmatrix}3&2\\\ 1&1\end{bmatrix}^{4}=\begin{bmatrix}153&112\\\
56&41\end{bmatrix};\quad\begin{bmatrix}3&2\\\
1&1\end{bmatrix}^{5}=\begin{bmatrix}571&418\\\ 209&153\end{bmatrix}.$

Thus $A_{k}=q_{2k}=p^{\prime}_{2k-1}$ and $B_{k}=q_{2k-1}=q^{\prime}_{2k-1}$
in (2.13) in Lemma 3.

Applying the procedure followed in the proof of earlier theorem, we have
$\sqrt{d}=[a;\overline{1,2,a,2,1,2a}]$:

$y=\cfrac{1}{1+\cfrac{1}{2+\cfrac{1}{a+\cfrac{1}{2+\cfrac{1}{1+\cfrac{1}{y+2a}}}}}}$

which after some long calculation leads to $3y^{2}+6ay-(4a+2)=0.$ Solving the
quadratic equation, we get the positive root:
$y=-a+\sqrt{a^{2}+\frac{4a+2}{3}}$. For $d$ to be an integer we have the
solution $a=3n+1$ gives $b=4n+2$.

When $\sqrt{d}=[a;\overline{1,2,1,2,a,2,1,2,1,2a}]$, the same procedure gives
the equation: $11y^{2}+22ay-(16a+6)=0$ whose positive root yields
$b=\frac{16a+6}{11}$ and for $d$ to be an integer we have $a=11n+1$ and
$b=16n+2.$

With $\sqrt{d}=[a;\overline{1,2,1,2,1,2,a,2,1,2,1,2,1,2a}]$, the procedure
gives the equation: $41y^{2}+82ay-(60a+22)=0$ whose positive root yields
$b=\frac{60a+22}{41}$ and for $d$ to be an integer we have $a=41n+1$ and
$b=60n+2.$

With $\sqrt{d}=[a;\overline{1,2,1,2,1,2,1,2,a,2,1,2,1,2,1,2,1,2a}]$, we get
the equation: $153y^{2}+306y-(224a+82)=0$ whose positive root yields
$b=\frac{224+82}{153}$ and for $d$ to be an integer we have $a=153n+1$ and
$b=224n+2.$

And for $k$ times the pairs $(1,2$ and $(2,1)$, we immediately obtain the
desired result by applying the formulas in (2.9). ∎

We now give a generalization of the preceding theorem.

######  General Theorem 1.

Let $\sqrt{m^{2}+2}=[m;\overline{m,2m}]$ and $q_{2k},\,q_{2k-1}$ be the
denominators of its convergents; then the multiplier for convergents with gap
2 equals $M=2(m^{2}+1)$, and so: $\displaystyle
q_{2k+2}=Mq_{2k}-q_{2k-2};\quad
q_{2k+1}=Mq_{2k-1}-q_{2k-3};\;q_{0}=1,\;q_{1}=m.\displaystyle$ This gives
$q_{2}=2m^{2}+1,\;q_{3}=2m(m^{2}+1),\;q_{4}=2m^{2}(2m^{2}+3)+1$. We then have:

$\displaystyle\sqrt{(q_{2k}~{}n+m)^{2}+2(2q_{2k-1}~{}n+1)}=\left[q_{2k}~{}n+m;\right.$
$\displaystyle\left.\overline{(m,2m)~{}\text{repeated ~{}k
~{}times},(q_{2k}~{}n+m),(2m,~{}m)~{}\text{repeated}~{}k~{}\text{times},2(q_{2k}~{}n+m)}\right].$

###  5.1. Formulas for case $m=1$

We noted some formulas for Theorem 2.

###  5.2. Formulas for case $m=2$

The convergents of $\sqrt{6}=[2;\overline{2,4}]$ are:

$\frac{5}{2},\,\frac{22}{9},\,\frac{49}{20},\,\frac{218}{89},\,\frac{485}{198},\,\frac{2158}{881},\,\frac{48271}{1960},\,\frac{21362}{8721},\dots$

They yield these formulas:

$\sqrt{(9n+2)^{2}+2(4n+1)}=\left[9n+2;\overline{2,4,9n+2,4,2,2(9n+2)}\right].$
(5.1)

$\sqrt{(89n+2)^{2}+2(40n+1)}=\left[89n+2;\overline{2,4,2,4,89n+2,4,2,4,2,2(89n+2)}\right].$
(5.2)

$\displaystyle\sqrt{(881n+2)^{2}+2(396n+1)}=\left[881n+2;\right.$
$\displaystyle\left.\overline{2,4,2,4,2,4,41n+1,4,2,4,2,4,2,2(881n+2)}\right].$
(5.3)

###  5.3. Formulas for case $m=3$

The convergents of $\sqrt{11}=[3;\overline{3,6}]$ are:

$\frac{10}{3},\,\frac{63}{19},\,\frac{199}{60},\,\frac{1257}{379},\,\frac{3970}{1197},\,\frac{25077}{7561},\,\frac{79201}{23880},\,\frac{500283}{150841},\dots$

They lead to the following formulas.

$\sqrt{(19n+3)^{2}+2(2\cdot
3n+1)}=\left[19n+3;\overline{3,6,19n+3,6,3,2(19n+3)}\right].$ (5.4)

$\sqrt{(379n+3)^{2}+2(2\cdot
60n+1)}=\left[379n+3;\overline{3,6,3,6,379n+3,6,3,6,3,2(379n+3)}\right].$
(5.5)

$\displaystyle\sqrt{(7561n+3)^{2}+2(2\cdot 1197n+1)}=\left[7561n+3;\right.$
$\displaystyle\left.\overline{3,6,3,6,3,6,7561n+3,6,3,6,3,6,3,2(7561n+3)}\right].$
(5.6)

###  5.4. Proof of the occurrence of $m,2m$ once

I now prove the formula wherein the pair $(m,2m)$ occurs once ($k=1$) for any
$m\in\mathbb{N},\,n\in\mathbb{N}$:

$\displaystyle\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+2(2mn+1)}=$ (5.7)
$\displaystyle[(2m^{2}+1)n+m;~{}\overline{m,2m,(2m^{2}+1)n+m,2m,m,2(2m^{2}+1)n+2m}].$

###### Proof.

$\displaystyle\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}$
$\displaystyle=((2m^{2}+1)n+m)+\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}-((2m^{2}+1)n+m)$
$\displaystyle=((2m^{2}+1)n+m)+\frac{4mn+2}{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}+((2m^{2}+1)n+m)}.$

So $a_{0}=(2m^{2}+1)n+m$ and the expression on the extreme right on being
inverted becomes

$m+\frac{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}-((2m^{2}-1)n+m)}{4mn+2}.$

So $a_{1}=m$ and the expression on the extreme right becomes

$\frac{2mn+1}{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}+((2m^{2}-1)n+m)}$

which on being inverted becomes

$2m+\frac{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}-((2m^{2}+1)n+m)}{2mn+1}.$

So $a_{2}=2m$ and the expression on the extreme right becomes

$\frac{2}{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}+((2m^{2}+1)n+m)}$

which on being inverted becomes

$((2m^{2}+1)n+m)+\frac{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}-((2m^{2}+1)n+m)}{2}.$

So $a_{3}=(2m^{2}+1)n+m$ and the expression on the extreme right becomes

$\frac{2mn+1}{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}+((2m^{2}+1)n+m)}$

which on being inverted becomes

$2m+\frac{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}-((2m^{2}-1)n+m)}{2mn+1}.$

So $a_{4}=2m$ and the expression on the extreme right becomes

$\frac{4mn+2}{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}+((2m^{2}-1)n+m)}$

which on being inverted becomes

$m+\frac{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}-((2m^{2}+1)n+m)}{4mn+2}.$

So $a_{0}=m$ and the expression on the extreme right becomes

$\displaystyle\frac{1}{\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}+((2m^{2}+1)n+m)}$
$\displaystyle=\frac{1}{2(((2m^{2}+1)n+m))+\sqrt{\\{(2m^{2}+1)n+m\\}^{2}+(4mn+2)}-((2m^{2}+1)n+m)}$

Hence, $a_{6}=2(((2m^{2}+1)n+m)$ and the loop begins all over again. ∎

###  5.5. Proof of the occurrence of $m,2m$ twice

Similarly, the formula wherein the pair $(m,2m)$ occurs twice($k=2$) for any
$m\in\mathbb{N},\,n\in\mathbb{N}$:

$\displaystyle\sqrt{\\{(2m^{2}(2m^{2}+3)+1)n+m\\}^{2}+2(2m(m^{2}+1)n+1)}=$
$\displaystyle\left[(2m^{2}(2m^{2}+3)+1)n+m;~{}\overline{m,2m,m,2m,(2m^{2}(2m^{2}+3)+1)n+m},\right.$
$\displaystyle\left.\overline{2m,m,2m,m,2((2m^{2}(2m^{2}+3)+1)n+m)}\right].$
(5.8)

can also be proved by the algorithm.

The general formula can be proved using the procedure used earlier though the
proof is somewhat tedious.

##  6\. Formulas with repeated triple $\\{1,1,3\\}$

Define the sequences $\\{p_{k}\\}$, $\\{q_{k}\\}$:

$\displaystyle p_{-1}=-1,\quad p_{0}=1,\quad
p_{k}=8~{}p_{k-1}+p_{k-2}\;\text{for}\;k\geq 1,$ (6.1) $\displaystyle
q_{-1}=4,\quad q_{0}=0,\quad q_{k}=8~{}q_{k-1}+q_{k-2}\;\text{for}\;k\geq 1.$
(6.2)

Its associated matrix is

$\begin{bmatrix}7&2\\\ 4&1\end{bmatrix}^{k}=\begin{bmatrix}p_{k}&q_{k}/2\\\
q_{k}&p_{k-1}+q_{k-1}/2\end{bmatrix}.$ (6.3)

We then have:

######  Theorem 3.

$\displaystyle\sqrt{\left\\{p_{k}~{}n+\frac{p_{k}+3}{2}\right\\}^{2}+\left(2q_{k}~{}n+q_{k}+2\right)}=\left[p_{k}~{}n+\frac{p_{k}+3}{2};\overline{(1,1,3)~{}k~{}\text{times}},\right.$
$\displaystyle\left.\overline{p_{k}~{}n+\frac{p_{k}+3}{2},(3,1,1)~{}\text{repeated}~{}k~{}\text{times},2\left(p_{k}~{}n+\frac{p_{k}+3}{2}\right)}\right].$

###### Proof.

This can be proved by mimicking the proof of Theorems 1 and 2. ∎

The first three formulas yielded by this theorem follows.

$\sqrt{(7n+5)^{2}+(8n+6)}=[7n+5;~{}\overline{1,1,3,7n+5,3,1,1,2(7n+5)}].$
(6.4)

$\displaystyle\sqrt{(57n+30)^{2}+(64n+34)}=\left[57n+30;\right.$
$\displaystyle\left.\overline{1,1,3,1,1,3,57n+30,3,1,1,3,1,1,2(57n+30)}\right].$
(6.5)

$\displaystyle\sqrt{(463n+233)^{2}+(520n+262)}=\left[463n+233;\right.$
$\displaystyle\left.\overline{1,1,3,1,1,3,1,1,3,463n+233,3,1,1,3,1,1,3,1,1,2(463n+233)}\right].$
(6.6)

##  7\. Repeated odd partial quotients

###  7.1. General formula for $\ell-1$ quotient $(2m+1),\,m\geq 0$

####  7.1.1. Methodology

As derived earlier,
$\frac{(2m+1)+\sqrt{(2m+1)^{2}+4}}{2}=[2m+1;\overline{2m+1}]$. Let $(2m+1)$ be
the repeated partial quotient in the period of the scf for
$-(2m+1)+\sqrt{(2m+1)^{2}+4}=[0;m,1,1,m,4m+2]$ using the formula (3.5). Now if
we calculate the inverse of its convergent at each quotient we find that the
denominator is odd at the quotient $a_{1},$ at $a_{2}$ and at $a_{4}$ while it
is even at the quotient $a_{3}$ and at $a_{5}.$ That is, only in the truncated
fractions $(a_{1},a_{2},a_{3})$ and $(a_{1},a_{2},a_{3},a_{4},2a_{0})$ the
denominator is even. The _trial and error method_ revealed that the
truncations with even denominators yield the desired formulas but not those
having odd denominators. We normally use the notation
$c_{k}=\frac{p_{k}}{q_{k}}$; I will use capital letters, to avoid confusion.

Taking the truncation $(a_{1},a_{2},a_{3})=(m,1,1)$, we get the convergent
$c_{3}=\frac{p_{3}}{q_{3}}$ which we denote by $C_{1}=\frac{P_{1}}{Q_{1}}$:

$C_{1}=\frac{P_{1}}{Q_{1}}=\frac{2m+1}{2}=\frac{2m+1}{2},$ (7.1)

and its successor with truncation after five more quotients
$c_{8}=\frac{p_{8}}{q_{8}}=(m,1,1,m,4m+2,m,1,1)$ which we denote by
$C_{2}=\frac{P_{2}}{Q_{2}}$:

$C_{2}=\frac{P_{2}}{Q_{2}}=\frac{(2m+1)^{4}+3(2m+1)^{2}+1}{2(2m+1)^{3}+4(2m+1)}.$
(7.2)

Next we take the full period: $(a_{1},a_{2},a_{3},a_{4},a_{5})=(m,1,1,m,4m+2)$
and get the convergent $c_{5}=\frac{p_{5}}{q_{5}}$ and denote it by
$C^{\prime}_{1}=\frac{P^{\prime}_{1}}{Q^{\prime}_{1}}$:

$C^{\prime}_{1}=\frac{P^{\prime}_{1}}{Q^{\prime}_{1}}=(m,1,1,m,4m+2)=\frac{(2m+1)[(2m+1)^{2}+2]}{2[(2m+1)^{2}+1]},$
(7.3)

and its successor with two full periods: $(m,1,1,m,4m+2,m,1,1,m,4m+2)$ and get
the convergent $c_{10}=\frac{p_{10}}{q_{10}}$ and denote it by
$C^{\prime}_{2}=\frac{P^{\prime}_{2}}{Q^{\prime}_{2}}$::

$C^{\prime}_{2}=\frac{P^{\prime}_{2}}{Q^{\prime}_{2}}=\frac{(2m+1)^{6}+5(2m+1)^{4}+6(2m+1)^{2}+1}{2[(2m+1)^{5}+4(2m+1)^{3}+3(2m+1)}.$
(7.4)

From these relations we deduce the the multiplier ($M$) for further
convergents after every five quotients is: $M=(2m+1)[(2m+1)^{2}+3]$. Then

$P_{k+1}=MP_{k}+P_{k-1};\;Q_{k+1}=MQ_{k}+Q_{k-1},\quad k\geq 2.$ (7.5)

$P^{\prime}_{k+1}=MP^{\prime}_{k}+P^{\prime}_{k-1};\quad
Q^{\prime}_{k+1}=MQ^{\prime}_{k}+Q^{\prime}_{k-1},\quad k\geq 2.$ (7.6)

I have defined here $C_{k}:=c_{5k-2}$ and $P_{k}:=p_{5k-2},Q_{k}:=q_{5k-2}$
and $C^{\prime}_{k}:=c_{5k}$ and
$P^{\prime}_{k}:=p_{5k},Q^{\prime}_{k}=:q_{5k}$, in terms of the regular
convergents.

####  7.1.2. General formula

######  General Theorem 2.

(i) Let $P_{k}$ and $Q_{k}$ be the numbers as defined above. Then

$\displaystyle\sqrt{\left(P_{k}~{}n~{}-\frac{P_{k}-(2m+1)}{2}\right)^{2}+\left(Q_{k}~{}n~{}-\frac{Q_{k}-2}{2}\right)}$
$\displaystyle=\left[P_{k}~{}n~{}-\frac{P_{k}-(2m+1)}{2};\right.$
$\displaystyle\left.\overline{(2m+1)~{}\text{repeated}~{}(3k-2)~{}\text{times},~{}2\left(P_{k}~{}n~{}-\frac{P_{k}-(2m+1)}{2}\right)}\right].$

(ii) Let $P^{\prime}_{k}$ and $Q^{\prime}_{k}$ be the numbers as defined
above. We then have

$\displaystyle\sqrt{\left(P^{\prime}_{k}~{}n~{}-\frac{P^{\prime}_{k}-(2m+1)}{2}\right)^{2}+\left(Q^{\prime}_{k}~{}n~{}-\frac{Q^{\prime}_{k}-2}{2}\right)}$
$\displaystyle=\left[P^{\prime}_{k}~{}n~{}-\frac{P^{\prime}_{k}-(2m+1)}{2};\right.$
$\displaystyle\left.\overline{(2m+1)~{}\text{repeated
}~{}3k~{}\text{times},~{}2\left(P^{\prime}_{k}~{}n~{}-\frac{P^{\prime}_{k}-(2m+1)}{2}\right)}\right].$

###### Proof.

We have here the partial quotient $(2m+1)$ repeated $(3k-2)$ times. In the
$2\times 2$ matrix approach, this just corresponds to the matrix
$\begin{bmatrix}2m+1&1\\\ 1&0\end{bmatrix}$ raised to the $3k-2$ power. Now we
just need to pre- and post-multiply by the $2\times 2$ matrices corresponding
to the first and last partial quotient, and work out the equation. It would
match the LHS of our General Theorem 2.

From our discussion in subsection LABEL:genmat, we get:

$\begin{bmatrix}2m+1&1\\\
1&0\end{bmatrix}^{3k-2}=\begin{bmatrix}u_{3k-1}&u_{3k-2}\\\
u_{3k-2}&u_{3k-3}\end{bmatrix};\;\begin{bmatrix}2m+1&1\\\
1&0\end{bmatrix}^{3k}=\begin{bmatrix}u_{3k+1}&u_{3k}\\\
u_{3k}&u_{3k-1}\end{bmatrix}$

where $u_{1}=1,u_{2}=2m+1.$ As noted earlier, $u_{3k}$ is always even while
$u_{3k+1}$ and $u_{3k+2}$ are always odd for $k=0,1,2,\dots$ The pair
$(u_{3k-1},2u_{3k-2})$ corresponds to $(P_{k},Q_{k})$ and yields the quotient
$(2m+1)$ repeated $(3k-2)$ times while $(u_{3k+1},2u_{3k})$ corresponds to
$(P^{\prime}_{k},Q^{\prime}_{k})$ and yields the quotient $(2m+1)$ repeated
$(3k)$ times in the period. The pair $(u_{3k},2u_{3k-1})$, with $u_{3k}$ even,
is inadmissible as the two numbers are not relatively prime because 2 divides
both. Let us, for example, take $m=1$. We then have:

$\begin{bmatrix}3&1\\\ 1&0\end{bmatrix}^{3}=\begin{bmatrix}33&10\\\
10&3\end{bmatrix};\quad\begin{bmatrix}3&1\\\
1&0\end{bmatrix}^{4}=\begin{bmatrix}109&33\\\ 33&10\end{bmatrix}$

$\begin{bmatrix}3&1\\\ 1&0\end{bmatrix}^{6}=\begin{bmatrix}1189&360\\\
360&109\end{bmatrix};\quad\begin{bmatrix}3&1\\\
1&0\end{bmatrix}^{7}=\begin{bmatrix}3927&1189\\\ 1189&360\end{bmatrix}$

We will see soon that these are exactly the numbers and the associated
formulas; the only difference is that all three numbers, excepting the first
element in the first row and the first column, are twice those given here.
Applying (2.9) completes the proof. ∎

###  7.2. Period with $\ell-1$ units, case $m=0$

(i). Let $F_{3k-1}$ be the $(3k-1)$th Fibonacci number. Then for
$k\in\mathbb{N}$ and $n=1,2,\dots$

$\displaystyle\sqrt{\left(F_{3k-1}~{}n-\frac{F_{3k-1}-1}{2}\right)^{2}+2\left(F_{3k-2}~{}n-\frac{F_{3k-2}-1}{2}\right)}$
$\displaystyle=\left[F_{3k-1}~{}n-\frac{F_{3k-1}-1}{2};\overline{1~{}\text{repeated}~{}(3k-2)~{}\text{times},~{}2\left(F_{3k-1}~{}n-\frac{F_{3k-1}-1}{2}\right)}\right].$

(ii). Let $F_{3k+1}$ be the $(3k+1)$th Fibonacci number. Then

$\displaystyle\sqrt{\left(F_{3k+1}~{}n-\frac{F_{3k+1}-1}{2}\right)^{2}+2\left(F_{3k}~{}n-\frac{F_{3k}}{2}\right)+1}$
$\displaystyle=\left[F_{3k+1}~{}n-\frac{F_{3k+1}-1}{2};\overline{1~{}\text{repeated}~{}3k~{}\text{times},~{}2\left(F_{3k+1}~{}n-\frac{F_{3kr+1}-1}{2}\right)}\right].$

This is based on the discussion in [13] and gave a clue to the general result.
We have these recurrence relations (with $M=4$):

$F_{3k+4}=4F_{3k+1}+F_{3k-2};\;F_{3k+3}=4F_{3k}+F_{3k-3};\;F_{3k+2}=4F_{3k-1}+F_{3k-4}.$

######  Case 1.

$\displaystyle(i).~{}\sqrt{n^{2}+2n}=[n;\overline{1,2n}],\,n\in\mathbb{N}.$
$\displaystyle(ii).~{}\sqrt{(3n-1)^{2}+2(2n-1)+1}=[3n-1;\overline{1,1,1,2(3n-1)}],\,n\in\mathbb{N}.$

######  Case 2.

$\displaystyle(i).~{}\sqrt{(5n-2)^{2}+2(3n-1)}=[5n-2;\overline{1,1,1,1,2(5n-2)}],\,n\in\mathbb{N}.$
$\displaystyle(ii).~{}\sqrt{(13n-6)^{2}+2(8n-4)+1}=[13n-6;\overline{1,1,1,1,1,1,2(13n-6)}].$

######  Case 3.

(i).

$\displaystyle\sqrt{(21n-10)^{2}+2(13n-6)}$
$\displaystyle=[21n-10;\overline{1,1,1,1,1,1,1,2(21n-10)}].$

(ii).

$\displaystyle\sqrt{(55n-27)^{2}+2(34n-17)+1}$
$\displaystyle=[55n-27;\overline{1,1,1,1,1,1,1,1,1,2(55n-27)}].$

###  7.3. Period with $\ell-1$ threes

Taking $m=1,$ we have

$\sqrt{13}=[3;\overline{1,1,1,1,6}];\;-3+\sqrt{13}=[0;\overline{1,1,1,1,6}].$

The relations derived earlier straightway yield $\frac{P_{k}}{Q_{k}}$ and
$\frac{P^{\prime}_{k}}{Q^{\prime}_{k}}.$ We are also giving the associated
terminating continued fractions for elucidation.

######  Case 4.

(i). We have $\frac{P_{1}}{Q_{1}}=(1,1,1)=\frac{3}{2}.$ So

$\sqrt{(3n)^{2}+2n}=\left[3n;\overline{3,6n)}\right].$

(ii). Next, $\frac{P^{\prime}_{1}}{Q^{\prime}_{1}}=(1,1,1,1,6)=\frac{33}{20}.$
So

$\sqrt{(33n-15)^{2}+(20n-9)}=[33n-15;\overline{3,3,3,2(33n-15)}].$

######  Case 5.

(i). We have $\frac{P_{2}}{Q_{2}}=(1,1,1,1,6,1,1,1)=\frac{109}{66}.$ So

$\sqrt{(109n-53)^{2}+(66n-32)}=\left[109n-53;\overline{3,3,3,3,2(109n-53)}\right].$

(ii). Next,
$\frac{P^{\prime}_{2}}{Q^{\prime}_{2}}=(1,1,1,1,6,1,1,1,1,6)=\frac{1189}{720}.$
So

$\displaystyle\sqrt{(1189n-593)^{2}+(720n-359)}$
$\displaystyle=[1189n-593;\overline{3,3,3,3,3,3,2(1189n-593)}].$

######  Case 6.

(i). We have $\frac{P_{3}}{Q_{3}}=(1,1,1,1,6,1,1,1,1,6,1,1,1)=\frac{36\cdot
109+3}{36\cdot 66+2}=\frac{3927}{2378}.$ So

$\displaystyle\sqrt{(3927n-1962)^{2}+(2378n-1188)}=\left[3927n-1962;\right.$
$\displaystyle\left.\overline{3,3,3,3,3,3,3,2(3927n-1962)}\right].$

(ii). Next,
$\frac{P^{\prime}_{3}}{Q^{\prime}_{3}}=(1,1,1,1,6,1,1,1,1,6,1,1,1,1,6)=\frac{36\cdot
1189+33}{36\cdot 720+20}=\frac{42837}{25940}.$ So

$\displaystyle\sqrt{(42837n-21417)^{2}+(25940n-12969)}$
$\displaystyle=[42837n-21417;\overline{3,3,3,3,3,3,3,3,3,2(42837n-21417)}].$

###  7.4. Period with $\ell-1$ fives

$m=2$ gives $-5+\sqrt{29}$ $=[0;\overline{2,1,1,2,29}]$. Using the general
formula yields

######  Case 7.

$(i).~{}\sqrt{(5n)^{2}+2n}=\left[5n;\overline{5,10n)}\right].$

$(ii).~{}\sqrt{(135n-65)^{2}+(52n-25)}=\left[135n-65;\overline{5,5,5,2(135n-65)}\right].$

######  Case 8.

$(i).~{}\sqrt{(701n-348)^{2}+(270n-134)}=\left[701n-348;\overline{5,5,5,5,2(701n-348)}\right].$

$\displaystyle(ii).~{}\sqrt{(18901n-9448)^{2}+(7280n-3639)}=$
$\displaystyle\left[18901n-9448;\overline{5,5,5,5,5,5,2(18901n-9448)}\right].$

######  Case 9.

$\displaystyle(i).~{}\sqrt{(98145n-49070)^{2}+(37802n-18900)}=\left[98145n-49070;\right.$
$\displaystyle\left.\overline{5,5,5,5,5,5,5,2(98145n-49070)}\right].$

$\displaystyle(ii).~{}\sqrt{(2646275n-1323135)^{2}+(1019252n-509625)}=$
$\displaystyle\left[2646275n-1323135;\overline{5,5,5,5,5,5,5,5,5,2(2646275n-1323135)}\right].$

One can go on like this and deduce formulas for larger values of $m$ by
varying convergents.

##  8\. General formula for $\ell-1$ quotient $(2m),m\geq 1$

###  8.1. Methodology

Let $(2m),\,m\geq 1$ be the quotient that repeats in the period. We then use
the scf for $\sqrt{(2m)^{2}+4}$, the special case ($n=2$) of (3.3) for the
needed convergents. I hit on this scf after examining the formulas given on
pages 59-60 of Kraitchik’s book [13]. The convergents
$c_{k}=\displaystyle\frac{p_{k}}{q_{k}}$ can be computed with the recurrence
relations $k\geq 1$:

$\displaystyle
p_{2k}=mp_{2k-1}+p_{2k-2};\;p_{2k+1}=4mp_{2k}+p_{2k-1};\;p_{0}=1,\;p_{1}=2m;$
$\displaystyle
q_{2k}=mq_{2k-1}+q_{2k-2};\;q_{2k+1}=4mq_{2k}+q_{2k-1};\;q_{0}=0,\;q_{1}=1.$

###  8.2. General formula

We then have this general formula for any fixed $m$:

######  General Theorem 3.

$\displaystyle\sqrt{(q_{k+1}n)^{2}+(p_{k+1})n+m^{2}+1}$
$\displaystyle=\left[q_{k+1}n~{}+m;\overline{2m~{}\text{repeated}~{}k~{}\text{times},2(q_{k+1}n+m)}\right]$

###### Proof.

Here we have to raise the associated matrix by a power $k.$ We have

$\displaystyle
c_{1}=\frac{p_{1}}{q_{1}}=\frac{2m}{1};\;c_{2}=(2m,m)=\frac{p_{2}}{q_{2}}=\frac{2m^{2}+1}{m};$
$\displaystyle
c_{3}=(2m,m,4m)=\frac{p_{3}}{q_{3}}=\frac{4(2m^{2}+1)m+2m}{4m^{2}+1},$

which give us the recurrence relations that we used in our method. ∎

###  8.3. Period with $\ell-1$ twos

We have $\sqrt{2^{2}+4}=[2;\overline{1,4}].$ Its convergents
$c_{k}=\displaystyle\frac{p_{k}}{q_{k}}$ can be computed with the recurrence
relations $k\geq 1$:

$\displaystyle
p_{2k}=p_{2k-1}+p_{2k-2};\;p_{2k+1}=4p_{2k}+p_{2k-1};\;p_{0}=1,\;p_{1}=2;$
$\displaystyle
q_{2k}=q_{2k-1}+q_{2k-2};\;q_{2k+1}=4q_{2k}+q_{2k-1};\;q_{0}=0,\;q_{1}=1.$

The convergents (numerators/denominators in https://oeis.org/A041010 and
https://oeis.org/A041011) are:

$\frac{2}{1},~{}\frac{3}{1},~{}\frac{14}{5},~{}\frac{17}{6},~{}\frac{82}{29},~{}\frac{99}{35},~{}\frac{478}{169},~{}\frac{577}{204},~{}\frac{2786}{985},\dots$

The first five cases follow (cf. [13, 59][22, p.327]):

$\displaystyle\sqrt{n^{2}+3n+2}=\left[n+1;\overline{2,2n+2}\right],$
$\displaystyle\sqrt{(5n)^{2}+14n+2}=\left[5n+1;\overline{2,2,10n+2}\right],$
$\displaystyle\sqrt{(6n)^{2}+17n+2}=\left[6n+1;\overline{2,2,2,12n+2}\right],$
$\displaystyle\sqrt{(29n)^{2}+82n+2}=\left[29n+1;\overline{2,2,2,2,58n+2}\right],$
$\displaystyle\sqrt{(35n)^{2}+99n+2}=\left[35n+1;\overline{2,2,2,2,2,70n+2}\right].$

The matrix $\begin{bmatrix}3&8\\\
1&3\end{bmatrix}^{k}=\begin{bmatrix}p_{2k}&8q_{2k}\\\
q_{2k}&p_{2k}\end{bmatrix}$ gives even convergents and $(2k-1)$ twos.

######  Remark 1.

Sierpinski takes $2n,\,12n,\,70n,$ etc. in place of $n,\,6n,35n,$ etc. in the
above formulas and so missed all odd $d$’s such as
$\sqrt{55}=\left[7;\overline{2,2,2,14}\right]$.

###  8.4. Period with $\ell-1$ fours

We have $\sqrt{4^{2}+4}=[4;\overline{2,8}].$ The convergents are

$\frac{4}{1},~{}\frac{9}{2},~{}\frac{76}{17},~{}\frac{161}{36},~{}\frac{1364}{305},~{}\frac{2889}{646},~{}\frac{24476}{5473},~{}\frac{51841}{11592},~{}\frac{439204}{98209},\dots$

The first five cases(cf. [13, 60]) follow:

######  Case 10.

$\sqrt{(2n)^{2}+9n+5}=[2n+2;\overline{4,4n+4}].$

######  Case 11.

$\sqrt{(17n)^{2}+76n+5}=[17n+2;\overline{4,4,34n+4}].$

######  Case 12.

$\sqrt{(36n)^{2}+161n+5}=[36n+2;\overline{4,4,4,72n+4}].$

######  Case 13.

$\sqrt{(305n)^{2}+1364n+5}=[305n+2;\overline{4,4,4,4,610n+4}].$

######  Case 14.

$\sqrt{(646n)^{2}+2889n+5}=[646n+2;\overline{4,4,4,4,4,1292n+4}].$

###  8.5. Period with $\ell-1$ sixes

We have $\sqrt{6^{2}+4}=[6;\overline{3,12}].$ Its convergents are:

$\frac{6}{1},~{}\frac{19}{3},~{}\frac{234}{37},~{}\frac{721}{114},~{}\frac{8886}{1405},~{}\frac{27379}{4329},~{}\frac{33743}{53353},\dots$

The first few cases are:

######  Case 15.

$\sqrt{(3n)^{2}+19n+10}=[3n+3;\overline{6,6n+6}].$

######  Case 16.

$\sqrt{(37n)^{2}+234n+10}=[37n+3;\overline{6,6,74n+6}].$

######  Case 17.

$\sqrt{(114n)^{2}+721n+10}=[114n+3;\overline{6,6,6,228n+6}].$

######  Case 18.

$\sqrt{(1405n)^{2}+8886n+10}=[1405n+3;\overline{6,6,6,6,2810n+6}].$

One can go on like this indefinitely.

##  9\. Concluding remarks

I have obtained some formulas containing certain patterns in the continued
fractions of square roots. There is still enough scope to look for more
patterns.

##  10\. Acknowledgments

I would like to thank Jeffrey Shallit for suggesting proof using matrices, and
Stephen Lucas for the derivation in 3.1.3.

## References

  * [1] L. C. Andrews, _Special Functions of Mathematics for Engineers._ 2nd ed. McGraw-Hill, 1992.
  * [2] V. I. Arnold, Lengths of periods of continued fractions of square roots of integers. Funct. Anal. Other Math. (2009) 2: 151–164.
  * [3] J. Binet, Mémoire sur l’intégration des équations linéaires aux différences finies, d’un ordre quelconque à coefficients variables. _Comptes rendus hebdomadaires des séances de l’Académie des sciences,_ XVII (1843) 559–567.
  * [4] M. Born and E. Wolf, _Principles of Optics: Electromagnetic Theory of Propagation, Interference, and Diffraction of Light._ (7e, 1999) CUP, 2003.
  * [5] J. Borwein, A. J. Van Der Poorten, J. Shallit, and W. Zudilin, _Neverending Fractions: An Introduction to Continued Fractions._ CUP, 2014.
  * [6] H. Davenport, _The Higher Arithmetic: An Introduction to the Theory Of Numbers._ Cambridge University Press, 8th ed. 2008.
  * [7] L. Euler, De Fractionibus Continuis Dissertatio. _Commentarii academiae scientiarum Petropolitanae_ 9 (1744) 98–137. _Opera Omnia:_ Series 1, Vol. 14, pp.187–216.
  * [8] L. Euler, Observationes analyticae. _Novi Commentarii academiae scientiarum Petropolitanae_ 11 (1767) 124–143. _Opera Omnia:_ Series 1, Vol. 15, pp. 50–69.
  * [9] J. S. Frame, Continued Fractions and Matrices. Amer. Math. Monthly 56 (1949) 2, 98–103.
  * [10] Hua Loo-Keng, _Introduction to Number Theory_. Springer-Verlag, 1982.
  * [11] A. Hurwitz and N. Kritikos, _Lectures on Number Theory._ Springer-Verlag, 1986.
  * [12] A. N. Khovanskii, Continued fractions. In: L. A. Lyusternik and A. R. Yanpol’skii (eds), _Mathematical Analysis: Functions, Limits, Series, Continued Fractions._ Pergamon Press, 1965, Chapter V.
  * [13] M. Kraitchik, _Théorie des nombres: Tome II_. Gauthier-Villars, Paris, 1926.
  * [14] W. J. LeVeque, _Fundamentals of Number Theory._ Addison-Wesley, 1977.
  * [15] É. Lucas, Théorie des Fonctions Numériques Simplement Périodiques. Amer. J. Math. 1 (1878) 2, 184–196.
  * [16] I. Niven, H. S. Zuckerman and H. L. Montgomery, _An Introduction to the Theory of Numbers._ J. Wiley, 5th ed. 1991.
  * [17] O. Perron, Die Lehre von den Kettenbrüchen. Leipzig and Berlin: Druck und Verlag von B. G. Teubner, 1913.
  * [18] A.J. van der Poorten, An introduction to continued fractions. In: J. H. Loxton A.J. van der Poorten (ed.) _Diophantine Analysis: Proceedings of the Number Theory section of the 1985 Australian Mathematical Society convention._ CUP, 1986, pp. 99–138.
  * [19] A. J. van der Poorten, Notes on continued fractions and recurrence sequences. In: J. H. Loxton (ed.) _Number Theory and Cryptography._ CUP, 1990, Chapter 6.
  * [20] P. J. Rippon and H. Taylor, Even and Odd Periods in Continued Fractions of Square Roots. Fibonacci Quarterly, 42 (2004) 2, 170–180.
  * [21] A. M. Rockett and P. Szüsz, _Continued Fractions._ World Scientific, 1992.
  * [22] W. Sierpinski, _Elementary Theory of Numbers._ 2nd English ed. rev. and enlarged by A. Schinzel. North Holland, PWN-Polish Scientific Publishers, 1988.