<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[12pt,reqno]{article}

\usepackage[usenames]{color}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{amscd}

\newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle #2}}}}

\usepackage[colorlinks=true,
linkcolor=webgreen,
filecolor=webbrown,
citecolor=webgreen]{hyperref}

\definecolor{webgreen}{rgb}{0,.5,0}
\definecolor{webbrown}{rgb}{.6,0,0}

\usepackage{color}
\usepackage{fullpage}
\usepackage{float}

\usepackage{psfig}
\usepackage{graphics,amsmath,amssymb}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{latexsym}
\usepackage{epsf}

\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{.1in}
\setlength{\evensidemargin}{.1in}
\setlength{\topmargin}{-.1in}
\setlength{\textheight}{8.4in}

\newcommand{\seqnum}[1]{\href{http://oeis.org/#1}{\underline{#1}}}

\begin{document}

\begin{center}
\epsfxsize=4in
\leavevmode\epsffile{logo129.eps}
\end{center}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{conjecture}[theorem]{Conjecture}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}

\begin{center}
\vskip 1cm{\LARGE\bf 
On Error Sums for Square Roots of Positive \\
\vskip 0.02in
Integers with Applications to Lucas and Pell \\
\vskip .1in
Numbers
}
\vskip 1cm
\large
Carsten Elsner \\ 
Fachhochschule f{\"u}r die Wirtschaft\\
University of Applied Sciences \\
Freundallee 15 \\
D-30173 Hannover \\
Germany \\ 
\href{mailto:carsten.elsner@fhdw.de}{\tt carsten.elsner@fhdw.de}
\end{center}

\vskip .2 in
 
\def \N{\mathbb{N}}
\def \Q{\mathbb{Q}}
\def \Z{\mathbb{Z}}
\def \E{\mathcal{E}}
\def \a{\alpha}
\def \b{\beta}

\newcommand{\eenb}{\mathcal{E}_{MC}}
\newcommand{\eed}{\overline{\mathcal{E}}} 
\newcommand{\ee}{\mathcal{E}} 



\begin{abstract}  
Several types of infinite series are considered, which are defined by a fixed real number $\a$ and the denominators and
numerators of the convergents of $\a$. In this paper we restrict $\a$ to the irrational square roots of positive integers.
We express the corresponding error sums in terms of a finite number of convergents. It is shown that an error sum formed
by convergents with even indices takes only rational values. Two applications for error sums with $\a =\sqrt{5}$ and
$\a =\sqrt{2}$ are given, where the convergents are composed of Lucas and Pell numbers, respectively.
\end{abstract} 


\section{Introduction and statement of the results} \label{Sec1}  
Let $x = \langle a_0,a_1,a_2,\dots,a_n,\dots \rangle$ be the regular continued fraction expansion of a real number $x$.
We denote the convergents of $x$ by
$p_m/q_m=\langle a_0,a_1,a_2,\dots,a_m \rangle$ for $m=0,1,\dots$.
During the last few
years, the author and his collaborators have investigated the error sum functions $\ee(x)$ and $\ee^*(x)$, defined by
\begin{eqnarray*}
\ee(x) &amp;=&amp; \sum_{m=0}^{\infty} \big| q_mx - p_m \big| = \sum_{m=0}^{\infty} {(-1)}^m \big( q_mx - p_m \big) \,,\\
\ee^*(x) &amp;=&amp; \sum_{m=0}^{\infty} \big( q_mx - p_m \big)
\end{eqnarray*}  
in its various aspects. In the following we list the most striking results of previous papers.
\begin{enumerate}
\item \cite[Theorem 1, Theorem 2]{Elsner5}:
\[\ee\big( [0,1] \big) = \Big[ \,0,\frac{1+\sqrt{5}}{2}\,\Big] \,,\qquad \ee^*\big( [0,1] \big) = \big[ 0,1 \big] \,.\]
\item \cite[Theorem 5]{Elsner6} and \cite[Proposition 5.1]{Ridley}:   
\[\int_0^1 \ee(x)\,dx = \frac{3\zeta(2)\log 2}{2\zeta(3)} - \frac{5}{8} \,,\qquad \int_0^1 \ee^*(x)\,dx 
= \frac{3}{8} \,,\]
where $\zeta(2)=\pi^2/6$ and $\zeta(3)$ are values of the Riemann zeta-function $\zeta(z)$.
\item \cite[Theorem 2]{Elsner6}: Both functions, $\ee(x)$ and $\ee^*(x)$, are continuous at every real irrational point $x$, and discontinuous
at rational points $x$. 
\item \cite[Theorem 3, Theorem 4]{Elsner5}: For every modulo one uniformly distributed sequence ${(x_n)}_{n\geq 0}$ of real numbers, the sequences
${\big( \ee(x_n)\big)}_{n\geq 0}$ and ${\big( \ee^*(x_n)\big)}_{n\geq 0}$ are not uniformly distributed. 
\item  \cite[p.\ 2]{Elsner4}:
\[\ee(e) = 2e\int_0^1 \exp(-t^2)\,dt - e \,,\qquad \ee^*(e) = 2\int_0^1 \exp(t^2)\,dt -2e+3 \,,\]
where $e=\exp(1)$. 
\end{enumerate} 
Even better a real number $x$ can be approximated by convergents $p_m/q_m$ with small subscripts $m$, even smaller are the
values of $\ee(x)$ and $\ee^*(x)$. To illustrate this fact by an example, we compute $\ee(\sqrt{D})+\ee^*(\sqrt{D})$ for
$D=a^2+1$ $(a=1,2,\dots)$ by using $\sqrt{a^2+1}=\langle a,\overline{2a}\,\rangle$ and Theorem~\ref{Thm2} below:
\[\ee(\sqrt{a^2+1})+\ee^*(\sqrt{a^2+1}) = \frac{1}{a} \,.\]
We define four variants of the error sum functions $\ee(x)$ and $\ee^*(x)$ as follows:
\begin{eqnarray}
\eed(x) &amp;=&amp; \frac{1}{2} \big( \ee(x)+\ee^*(x) \big) = \sum_{m=0}^{\infty} \big( q_{2m}x - p_{2m} \big) \,,
\label{1.10} \\
\ee_2(x) &amp;=&amp; \sum_{m=0}^{\infty} {\big( q_mx - p_m\big)}^2 \,,
\label{1.20} \\
\eenb(x) &amp;=&amp; (  x - a_0 )+ \sum_{\nu = 1}^{\infty}\; \sum_{1\leq b \leq a_\nu} \big| (bq_{\nu -1}+q_{\nu -2})x 
- (bp_{\nu -1}+p_{\nu -2})  \big| \,,
\label{1.30}\\ 
\eenb^*(x) &amp;=&amp; (  x - a_0 )+ \sum_{\nu = 1}^{\infty}\; \sum_{1\leq b \leq a_\nu} \big( (bq_{\nu -1}+q_{\nu -2})x
- (bp_{\nu -1}+p_{\nu -2})  \big) \,.
\label{1.40}
\end{eqnarray}  
The error sums $\eenb(x)$ and $\eenb^*(x)$ are formed by taking all the minor convergents of $x$ into account. The series
in (\ref{1.30}) and (\ref{1.40}) do not exist for every real number $x$, but they converge at least for all quadratic irrationals
$x$. In this paper we exclusively restrict $x$ on square roots of positive integers, which allows to express the error sums
by finite expressions in terms of $p_m$ and $q_m$ using the convergents $p_1/q_1,\ldots,p_{4k}/{q_{4k}}$. Here, $k$ is the length of the
primitive period of the continued fraction expansion
\begin{equation}
\sqrt{D} = \langle a_0,\overline{a_1,\ldots,a_k}\,\rangle \,.
\label{1.50}
\end{equation}
It is already known \cite[Theorem~4]{Elsner4} that $\ee(x)$ and $\ee^*(x)$ belong to the number field ${\Q}(x)$, when
$x$ is a real algebraic number of degree two. Here, we give explicite formulas for $\ee(\sqrt{D})$ and $\ee^*(\sqrt{D})$, 
which reveals some surprising connections between these numbers. For instance, $\eed(\sqrt{D})$ is a rational number (see Theorem~\ref{Thm2}). 
\begin{theorem}
Let $D$ be a positive integer, but not a perfect square. Then we have the identities
\begin{eqnarray*}
\ee(\sqrt{D}) &amp;=&amp; \big( 1 + \frac{p_{2k-1}}{2Dq_{2k-1}^2} \big( (2p_{2k-1} +1) \sum_{j=1}^{2k} {(-1)}^j 
q_j-\sum_{j=1}^{2k} {(-1)}^j q_{j+2k} \big) \\
&amp;&amp;-\,\frac{1}{2Dq_{2k-1}^2} \sum_{j=1}^{4k} {(-1)}^j q_j \big) \sqrt{D} + \frac{1}{2q_{2k-1}}  \big( (2p_{2k-1} +1) 
\sum_{j=1}^{2k} {(-1)}^j q_j \\
&amp;&amp; -\,\sum_{j=1}^{2k} {(-1)}^j q_{j+2k} \big) - p_0 \,,\\
\ee^*(\sqrt{D}) &amp;=&amp; \big( 1 + \frac{p_{2k-1}}{2Dq_{2k-1}^2} \big( (2p_{2k-1} +1) \sum_{j=1}^{2k} q_j 
-\sum_{j=1}^{2k} q_{j+2k} \big) - \frac{1}{2Dq_{2k-1}^2} \sum_{j=1}^{4k} q_j \big) \sqrt{D} \\ 
&amp;&amp;+\,\frac{1}{2q_{2k-1}}  \big( (2p_{2k-1} +1) \sum_{j=1}^{2k} q_j - \sum_{j=1}^{2k} q_{j+2k} \big) - p_0 \,.
\end{eqnarray*}
\label{Thm1}
\end{theorem} 
By $\lfloor x \rfloor$ we denote the integer part of the positive real number $x$. 
\begin{theorem}
Let $D$ be a positive integer, but not a perfect square. Then we have the identity
\[\eed(\sqrt{D}) = \frac{q_2+q_4+q_6+\cdots +q_{4k}}{2p_{2k-1}q_{2k-1}} - \frac{Dq_{2k-1}}{p_{2k-1}} - \lfloor \sqrt{D} \rfloor \,.\]
\label{Thm2} 
\end{theorem}
As already mentioned above, we have for real algebraic numbers $x$ of degree two the formulas $\ee(x)=\omega_1+\omega_3x$ and $\ee^*(x)=\omega_2+\omega_4x$
with suitable rationals $\omega_1,\omega_2,\omega_3$, and $\omega_4$. For $x =\sqrt{D}$ Theorem~\ref{Thm2} immediately implies that $\omega_3=-\omega_4$. 
It turns out that additionally $\omega_2=1+\omega_1$ holds. We summarize these facts as follows.
\begin{theorem}
Let $D$ be a positive integer, but not a perfect square. Then there are rationals $\omega_0$ and $\omega_1$ satisfying
\begin{eqnarray*}
\ee(\sqrt{D}) &amp;=&amp; \omega_1 + \omega_0\sqrt{D} \,,\\
\ee^*(\sqrt{D}) &amp;=&amp; 1+ \omega_1 - \omega_0\sqrt{D} \,.
\end{eqnarray*}
\label{Thm3}
\end{theorem}
The convergents of $\sqrt{5}$ with even subscripts are formed by Lucas numbers $L_n=F_{n+1}+F_{n-1}$ $(n=0,1,\ldots)$, namely $p_{2m}=L_{6m+3}/2$, 
$q_{2m}=(L_{6m+2}+L_{6m+4})/10$. The convergents of $\sqrt{2}$ are constructed by Pell numbers, which are defined recursively by 
\[P_0=0 \,,\quad P_1=1 \,,\quad P_n= 2P_{n-1}+P_{n-2} \quad (n\geq 2) \,.\]
For $\sqrt{2}$, we have $p_m=P_m+P_{m+1}$, $q_m=P_{m+1}$. Therefore, Theorem~\ref{Thm2} gives the following corollary.
\begin{corollary}
We have the identities
\begin{eqnarray*}
\frac{5}{2} &amp;=&amp; \sum_{m=0}^{\infty} \big( (L_{6m+2} + L_{6m+4})\sqrt{5} - 5L_{6m+3} \big) \,,\\
\frac{1}{2} &amp;=&amp; \sum_{m=0}^{\infty} \big( P_{2m+1}\sqrt{2} - P_{2m} - P_{2m+1}\big) \,.
\end{eqnarray*}
\label{Cor2}
\end{corollary} 
The background of our results and their proofs is obviously formed by the theory of regular continued fractions. We need various facts
from the theory of linear recurrences, and we apply results on solutions of Pell's equation, for which we refer in Section~\ref{Sec2} to Perron's classical monograph \cite{Perron} on continued fractions.
In Section~\ref{Sec3} of this paper we prove Theorem~\ref{Thm1}, and continue in Section~\ref{Sec4} with the proof of Theorem~\ref{Thm2}
and the rational part $1+\omega_1$ in Theorem~\ref{Thm3}. 

By applying similar arguments, one can easily deduce the following identities for the error sums $\eenb(\sqrt{D})$, $\eenb^*(\sqrt{D})$,
and $\ee_2(\sqrt{D})$, which we state without proof. To simplify the identities for $\eenb(\sqrt{D})$ and $\eenb^*(\sqrt{D})$ we need two 
sequences of integers defined by
\begin{eqnarray*}
\omega_\nu^{(1)} &amp;=&amp; \frac{1}{2} (1+a_{\nu +1}) a_{\nu +1} - a_{\nu +2} \qquad (\nu \geq 0) \,,\\
\omega_\nu^{(2)} &amp;=&amp; \frac{1}{2} (1+a_{\nu +1}) a_{\nu +1} + a_{\nu +2} \qquad (\nu \geq 0) 
\end{eqnarray*}
in terms of the partial quotients $a_1,a_2,\dots$ from the continued fraction expansion (\ref{1.50}) of $\sqrt{D}$.
\begin{theorem}
Let $D$ be a positive integer, but not a perfect square. Moreover, let $\alpha := p_{2k-1}+q_{2k-1}\sqrt{D}$.
Then we have the identities 
\begin{eqnarray*}
\eenb(\sqrt{D}) &amp;=&amp; \sqrt{D} - \lfloor \sqrt{D} \rfloor + a_1 - \frac{2\alpha^2 \sqrt{D}}{(\alpha^2 -1)(\alpha -1)} 
\sum_{j=0}^{2k-1} {(-1)}^j (\alpha q_j - q_{j+2k}) \omega_j^{(1)} \,, \\
\eenb^*(\sqrt{D}) &amp;=&amp; \sqrt{D} - \lfloor \sqrt{D} \rfloor - a_1 + \frac{2\alpha^2 \sqrt{D}}{(\alpha^2 -1)(\alpha -1)} 
\sum_{j=0}^{2k-1} (\alpha q_j - q_{j+2k}) \omega_j^{(2)} \,.
\end{eqnarray*}
\label{Thm4}
\end{theorem}  
\begin{theorem}
Let $D$ be a positive integer, but not a perfect square. Moreover, let $\alpha := p_{2k-1}+q_{2k-1}\sqrt{D}$. Then we have the identity
\[\ee_2(\sqrt{D}) = {\big( \sqrt{D} - \lfloor \sqrt{D} \rfloor \big)}^2 + \frac{\alpha^4}{{(\alpha^2 -1)}^3} \sum_{j=1}^{2k}
 {\big( ( \alpha p_j - p_{j+2k}) - ( \alpha q_j - q_{j+2k}) \sqrt{D} \big)}^2 \,.\] 
\label{Thm5}
\end{theorem}
The Appendix consists of tables for values of all above mentioned error sums at the points $\sqrt{D}$.

\section{Auxiliary results} \label{Sec2}
Our results rely on certain identities involving only a finite number of convergents of $\sqrt{D}$. These relations are established in Lemma~\ref{Lem2}.  
\begin{lemma}
Let $D$ be a positive integer, but not a perfect square. Moreover, let $k$ be the primitive period of the continued fraction expansion (\ref{1.50}) of $\sqrt{D}$,
and let $1\leq j\leq k$. Then, both sequences ${( p_{j+2kn})}_{n\geq 0}$ and ${( q_{j+2kn})}_{n\geq 0}$, satisfy the linear recurrence formula
\[u_{j+2kn} = 2p_{2k-1}u_{j+2k(n-1)} - u_{j+2k(n-2)} \qquad (n\geq 2) \,.\]
\label{Lem1}
\end{lemma}
\begin{proof} We prove a slightly stronger result. Let $p_m/q_m$ with $m\geq 0$ denote the convergents of a quadratic irrational number 
$x = \langle a_0,\overline{a_1,\ldots,a_r}\, \rangle$, where $r$ is a multiple of the length of the primitive period. By $z_n$ we denote either $z_n=p_{j+rn}$ or 
$z_n=q_{j+rn}$ with $0\leq j&lt;k$ and $n\geq 0$. Elsner and Komatsu \cite[Corollary~1]{Elsner1} showed that there is a positive integer $d$, such that the numbers from the sequence ${(z_n)}_{n\geq 0}$ 
satisfy the linear recurrence formula
\begin{equation}
z_n = dz_{n-1} + {(-1)}^{r-1}z_{n-2} \qquad (n\geq 2) \,.
\label{2.10}
\end{equation}
The first step in the proof is to show that the coefficient $d$ on the right-hand side of (\ref{2.10}) does not depend on $j$ and not on the particular numbers $p_{j+rn}$ 
or $q_{j+rn}$ under consideration. Let $d=d(j)$ be the coefficient in (\ref{2.10}) according to the numbers $z_n \,:=\, p_{j+rn}$ with $n\geq 0$, $0\leq j &lt;r-1$, and $r&gt;1$
(There is nothing to prove for $r=1$). Then there are real parameters $C_1&gt;0$, $C_2$, and $\alpha, \beta$, satisfying
\[z_n = C_1 \alpha^n + C_2 \beta^n \qquad (n\geq 0) \,,\]
where $\alpha$ and $\beta$ are the roots of the characteristic polynomial $X^2-dX+{(-1)}^r$ of the recurrence formula (\ref{2.10}). 
$\a$ and $\b$ are given by
\[\alpha = \frac{d}{2} + \sqrt{\frac{d^2}{4} + {(-1)}^{r-1}} \qquad \mbox{and} \qquad \beta = \frac{d}{2} - \sqrt{\frac{d^2}{4} + {(-1)}^{r-1}} \,.\]
This implies
\begin{equation}
\alpha &gt; 1 \,,\quad -1 &lt; \beta &lt; 1 \,,\quad \alpha \beta = {(-1)}^r \,.
\label{2.20}
\end{equation} 
Next we consider the numbers
\[{\overline{z}}_n \,:=\, p_{j+1+rn} \qquad (n\geq 0) \,,\]
where $j+1&lt;r$ holds by our condition on $j$ and $r$. For $r&gt;1$ we have the inequalities
\begin{equation}
z_n &lt; {\overline{z}}_n &lt; z_{n+1} \qquad (n\geq 0)\,.
\label{2.30}
\end{equation}
Repeating the above arguments for the numbers ${\overline{z}}_n$, we find real parameters $C_3&gt;0$, $C_4$, $\alpha_0 &gt;1$ and $-1&lt;\beta_0 &lt;1$, 
satisfying
\[{\overline{z}}_n = C_3{\alpha_0}^n +  C_4{\beta_0}^n \qquad (n\geq 0)\,.\]
{\em Case~1:\/} Let $\alpha_0 &gt; \alpha$. 
 From $\beta^n \to 0$ and $\beta_0^n \to 0$ we conclude that for all sufficiently large integers $n$ the inequality
\[{\overline{z}}_n = C_3{\alpha_0}^n +  C_4{\beta_0}^n &gt; C_1 \alpha^{n+1} + C_2 \beta^{n+1} = z_{n+1}\ \]
contradicts the right-hand inequality in (\ref{2.30}). 

{\em Case~2:\/} Let $\alpha_0 &lt; \alpha$.  
But this assumption is incompatible with the left-hand inequality of (\ref{2.30}), since all sufficiently large integers $n$ give
\[{\overline{z}}_n = C_3{\alpha_0}^n +  C_4{\beta_0}^n &lt; C_1 \alpha^{n} + C_2 \beta^{n} = z_n\,.\]
Hence $\alpha_0 =\alpha$. Since $\beta_0$ and $\beta$ are the algebraic conjugates of $\alpha_0$ and $\alpha$, respectively,
they are uniquely determined by $\alpha_0$ and $\alpha$. It follows that $\beta_0 =\beta$. This proves that the numbers from both sequences 
$p_{j+rn}=C_1\alpha^n+C_2\beta^n$ and $p_{j+1+rn}=C_3\alpha^n+C_4\beta^n$ satisfy the same linear recurrence formula (\ref{2.10}). The 
arguments can be repeated for the numbers $q_{j+rn}$ and $q_{j+1+rn}$. Therefore the coefficient $d$ in (\ref{2.10}) depends at most on $D$. 
Let us return to the continued fraction expansion $\sqrt{D}=\langle a_0,\overline{a_1,\ldots,a_k}\,\rangle$ 
from (\ref{1.50}). The above number $r$ can be restricted to an arbitrary multiple of $k$. Let $r=2k$, which rely on  
$\sqrt{D}=\langle a_0,\overline{a_1,\ldots,a_k,a_{k+1},\ldots,a_{2k}}\,\rangle$. Lemma~\ref{Lem1} is either applied to
the numbers $z_n = p_{j+2kn}$ $(n\geq 0)$ or to the numbers $z_n = q_{j+2kn}$ $(n\geq 0)$, where $1\leq j\leq k$. 
With $u_{j+2kn}$ replaced by $z_n$, we use (\ref{2.10}) with $r=2k$ to fix some positive integer
$d$ independently from $j$ such that
\begin{equation}
z_n = dz_{n-1} - z_{n-2} \qquad (n\geq 2) \,.
\label{2.40}
\end{equation} 
To compute $d$, we deduce the recurrence formula for the numbers $P_n:=p_{(2k-1)+2k(n-1)}=p_{2kn-1}$ $(n\geq 1)$ and for
$Q_n:=q_{(2k-1)+2k(n-1)}=q_{2kn-1}$ $(n\geq 1)$. For our arguments see the book of Perron \cite[\S\,27]{Perron}. It is
well-known that $X=P_n$ and
$Y=Q_n$ satisfy Pell's equation $X^2-DY^2=1$. Then, setting
\begin{eqnarray*}
\alpha &amp;=&amp; p_{2k-1}+q_{2k-1}\sqrt{D} \,,\\
\beta &amp;=&amp; p_{2k-1}-q_{2k-1}\sqrt{D} \,,
\end{eqnarray*}
we have the formula
\[P_n+Q_n\sqrt{D} = {\big( P_1+Q_1\sqrt{D} \big)}^n = \alpha^n \qquad (n\geq 1) \,,\]
which is satisfied by
\begin{equation}
P_n = \frac{1}{2} \big( \alpha^n + \beta^n \big) \qquad \mbox{and} \qquad 
Q_n = \frac{1}{2\sqrt{D}} \big( \alpha^n - \beta^n \big) \qquad (n\geq 1) \,.
\label{2.45}
\end{equation} 
Therefore we find
\begin{eqnarray*}
&amp;&amp; p_{2k-1}^2 - 1 = Dq_{2k-1}^2 \\
&amp;\Longleftrightarrow&amp; 2p_{2k-1}^2 \pm 2p_{2k-1}q_{2k-1}\sqrt{D} - 1 = p_{2k-1}^2 \pm 2p_{2k-1}q_{2k-1}\sqrt{D} 
+ Dq_{2k-1}^2 \\
&amp;\Longleftrightarrow&amp; 2p_{2k-1} \big( p_{2k-1} \pm q_{2k-1}\sqrt{D} \big) - 1 = {\big( p_{2k-1} \pm q_{2k-1}\sqrt{D} 
\big)}^2 \\
&amp;\Longleftrightarrow&amp; 2p_{2k-1}\alpha - 1 = \alpha^2 \qquad \mbox{and} \qquad 2p_{2k-1}\beta - 1 = \beta^2 \,.
\end{eqnarray*}
Hence,
\begin{eqnarray}
2p_{2k-1}\alpha^{n-1} - \alpha^{n-2} &amp; = &amp; \alpha^n \qquad (n\geq 2)\,,
\label{2.50} \\
2p_{2k-1}\beta^{n-1} - \beta^{n-2} &amp; = &amp; \beta^n \qquad (n\geq 2) \,.
\label{2.60}
\end{eqnarray}
Summing up (\ref{2.50}) and (\ref{2.60}), we obtain
\[2p_{2k-1}\big( \alpha^{n-1} \pm \beta^{n-1} \big) - (\alpha^{n-2} \pm \beta^{n-2}) = \alpha^n \pm \beta^n \qquad 
(n\geq 2)\,. \]
Consequently we find by (\ref{2.45}) (with the upper signs) $P_n=2p_{2k-1}P_{n-1}-P_{n-2}$ and (with the lower signs)
$Q_n=2p_{2k-1}Q_{n-1}-Q_{n-2}$ for $n\geq 2$. This shows that $d$ equals $2p_{2k-1}$ in (\ref{2.40}), which completes the 
proof of Lemma~\ref{Lem1}. 
\end{proof}
\begin{lemma}
Let $D$ be a positive integer, but not a perfect square. Moreover, let $k$ be the primitive period of the continued fraction expansion (\ref{1.50}) of $\sqrt{D}$.
Then we have the identities
\begin{eqnarray}
p_{2k-1}+q_{2k-1}\sqrt{D} &amp; = &amp; \frac{\sum_{j=1}^{2k} \big( q_{j+2k}\sqrt{D} + p_{j+2k} \big)}{\sum_{j=1}^{2k} 
\big( q_{j}\sqrt{D} + p_{j} \big)} \,,
\label{2.70} \\
\frac{p_{2k-1}-1}{q_{2k-1}} &amp; = &amp; \frac{\sum_{j=1}^k p_{2j}}{2+\sum_{j=1}^k q_{2j}} \,,
\label{2.80} \\
\frac{p_{2k-1}+1}{q_{2k-1}} &amp; = &amp; \frac{1+\sum_{j=1}^k p_{2j-1}}{\sum_{j=1}^k q_{2j-1}} \,.
\label{2.85}
\end{eqnarray}
\label{Lem2}
\end{lemma}
\begin{proof} Replacing $k$ by $2k$ and $\nu$ by $j+1$, the formulas  
\begin{eqnarray}
A_{\nu +k-1} &amp;=&amp; B_{\nu -1}DB_{k-1} + A_{\nu -1}A_{k-1} \,,
\label{2.90} \\
B_{\nu +k-1} &amp;=&amp; B_{\nu -1}A_{k-1} + A_{\nu -1}B_{k-1} 
\label{2.100}
\end{eqnarray} 
from page\,94 in \cite[\S 28]{Perron} turn into
\begin{eqnarray}
p_{j+2k} &amp;=&amp; p_{2k-1}p_{j} + Dq_{2k-1}q_{j} \qquad (j\geq 0) \,,
\label{2.110} \\
q_{j+2k} &amp;=&amp; p_{2k-1}q_{j} + q_{2k-1}p_{j} \qquad (j\geq 0) \,.
\label{2.120} 
\end{eqnarray}
Adding up from $j=1$ to $j=2k$, we obtain
\begin{eqnarray*}
p_{2k-1}\sum_{j=1}^{2k} p_{j} + Dq_{2k-1}\sum_{j=1}^{2k} q_{j} &amp;=&amp; \sum_{j=1}^{2k} p_{j+2k} \,,\\
p_{2k-1}\sum_{j=1}^{2k} q_{j} + q_{2k-1}\sum_{j=1}^{2k} p_{j} &amp;=&amp; \sum_{j=1}^{2k} q_{j+2k} \,.
\end{eqnarray*}
Next, we multiply the second equation by $\sqrt{D}$ and then add the first equation.
\begin{eqnarray*}
&amp;&amp; p_{2k-1}\sum_{j=1}^{2k} q_{j}\sqrt{D} + q_{2k-1}\sqrt{D}\sum_{j=1}^{2k} p_{j} + p_{2k-1}\sum_{j=1}^{2k} p_{j} + q_{2k-1}\sqrt{D}\sum_{j=1}^{2k} q_{j}\sqrt{D} \\
&amp;=&amp; \sum_{j=1}^{2k} q_{j+2k}\sqrt{D} + \sum_{j=1}^{2k} p_{j+2k} \,.
\end{eqnarray*}
This identity can be transformed into
\[(p_{2k-1} + q_{2k-1}\sqrt{D}) \sum_{j=1}^{2k} (q_{j}\sqrt{D} + p_{j}) = \sum_{j=1}^{2k} (q_{j+2k}\sqrt{D} + p_{j+2k}) \,,\]
which is equivalent with  (\ref{2.70}). 

To prove (\ref{2.80}) and (\ref{2.85}), we adapt the notation introduced by Perron \cite{Perron} concerning regular continued fractions. 
Let $\alpha = \alpha_0 = \langle a_0,a_1,a_2,\ldots \rangle$ be a regular continued fraction. By $p_m=p_{m,0}=p_m(\alpha_0)$ and $q_m=q_{m,0}=q_m(\alpha_0)$ 
we denote the numerator and denominator, respectively, of the $m$th convergent. Next, let
\[\a_r \,:=\, \langle a_r,a_{r+1},a_{r+2},\ldots \rangle \qquad (r\geq 0) \,.\]
Numerators and denominators of the  $m$th convergent of $\a_r$ are denoted by $p_{m,r}=p_m(\a_r)$ and $q_{m,r}=q_m(\a_r)$, respectively. For every $r\geq 0$ 
we have the identity
\[\a = \langle a_0,a_1,a_2,\ldots,a_{r-1},\a_r \rangle \,.\]
Later we shall take advantage of the very important formula
\begin{equation}
p_{\nu}q_{\mu} - p_{\mu}q_{\nu} = {(-1)}^{\mu} q_{\nu - \mu - 1,\mu +1} \qquad (\nu \geq \mu \geq 0) \,,
\label{2.130}
\end{equation} 
see \cite[\S \,6, (3)]{Perron}. For the proof of (\ref{2.80}) we need two additional identities (see Lemmas~\ref{Lem3} and \ref{Lem4} below).
\begin{lemma}
Let $D$ be a positive integer, but not a perfect square. Moreover, let $k$ be the primitive period of the continued fraction expansion (\ref{1.50}) of $\sqrt{D}$.
Then, for $k\geq 2$, we have the identity
\[\sum_{j=0}^{k-2} q_{2j} = \sum_{j=0}^{k-2} q_{2k-2j-4,2j+3} \,.\]
\label{Lem3}
\end{lemma} 
\begin{proof} By
\[\frac{p_n}{q_n} = \langle a_0,a_1,\ldots,a_n \rangle \]
we denote the regular continued fraction expansion of the rational number $p_n/q_n$. Since $p_n$ and $q_n$ are coprime, we 
have, on the one hand, the formula
\[q_n (\langle a_0,a_1,\ldots,a_n \rangle ) = q_n \,.\]
It is well-known that for $n\geq 1$ the identity
\[\frac{q_n}{q_{n-1}} = \langle a_n,a_{n-1},\ldots ,a_2,a_1 \rangle \] 
holds \cite[\S \,11, (3)]{Perron}, such that for every integer $b_0$ we deduce, on the other hand, 
\[q_n (\langle b_0,a_n,a_{n-1},\ldots ,a_2,a_1 \rangle )  
= q_n ( b_0 + \frac{1}{\langle a_n,a_{n-1},\ldots ,a_2,a_1 \rangle})
= q_n \big( b_0 + \frac{q_{n-1}}{q_n}\big) = q_n \,,\]
since $q_{n-1}$ and $q_n$ are coprime, too. Altogether we have shown for $n\geq 1$ that
\begin{equation}
q_n = q_n (\langle a_0,a_1,a_2,\ldots a_{n-1},a_n \rangle ) 
= q_n (\langle b_0,a_n,a_{n-1},\ldots ,a_2,a_1 \rangle ) \qquad (a_0,b_0 \in {\Z}) \,.
\label{2.140}
\end{equation}
Now we prove the formula
\begin{equation}
q_{2j} = q_{2j,2(k-j)-1} \qquad (0\leq j\leq k-2) \,.
\label{2.150}
\end{equation}
For $j=0$ this reads $1=q_0=q_{0,2k-1}=1$, so that we may assume $j\geq 1$.  
Perron \cite[\S \,24, Satz\,3.9]{Perron} showed that the regular continued fraction expansion of $\sqrt{D}$ has a
symmetric form:
\[\sqrt{D} = \langle a_0,\overline{a_1,a_2,\ldots ,a_{r-1},a_r,a_{r-1},\ldots ,a_2,a_1,a_k} \,\rangle \]
for even $k$ (where $r=k/2$), and
\[\sqrt{D} = \langle a_0,\overline{a_1,a_2,\ldots ,a_r,a_r,\ldots ,a_2,a_1,a_k} \,\rangle \]
for odd $k$ (where $r=(k-1)/2$). Independently of the parity of $k$ there is a symmetric arrangement around every
partial quotient $a_k,a_{2k},$ $a_{3k},\ldots$. In particular, around $a_{2k}$ we have
\begin{equation}
a_{2k+\nu} = a_{2k-\nu} = a_{\nu} \qquad (\nu= 1,2,\ldots,2k-1) \,.
\label{2.160}
\end{equation}
On the one hand, it is clear for $j\geq 1$ that
\begin{equation}
q_{2j} = q_{2j,0} = q_{2j} (\langle a_0,a_1,a_2,\ldots ,a_{2j} \rangle ) \,,
\label{2.170}
\end{equation}
holds. On the other hand, we deduce the following equations for $1\leq j \leq k-2$.
\begin{eqnarray}
q_{2j,2(k-j)-1} &amp;=&amp; q_{2j} (\langle a_{2k-2j-1},a_{2k-2j},a_{2k-2j+1},\ldots ,a_{2k-2},a_{2k-1} \rangle ) 
\nonumber \\
&amp;=&amp; q_{2j} (\langle a_{2j+1},a_{2j},a_{2j-1},\ldots ,a_{2},a_{1} \rangle ) \,,
\label{2.180}
\end{eqnarray} 
where the last identity relies on (\ref{2.160}). Applying (\ref{2.140}) (with $n=2j\geq 2$ and $b_0=a_{2j+1}$) to the 
representations of $q_{2j}$ and $q_{2j,2(k-j)-1}$ from (\ref{2.170}) and (\ref{2.180}), respectively, we finish the proof 
of (\ref{2.150}). Then we obtain
\[\sum_{j=0}^{k-2} q_{2j} = \sum_{j=0}^{k-2} q_{2j,2k-2j-1} = \sum_{j=0}^{k-2} q_{2k-2(k-2-j)-4,2(k-2-j)+3} 
= \sum_{j=0}^{k-2} q_{2k-2j-4,2j+3} \,,\]
which completes the proof of Lemma~\ref{Lem3}. 
\end{proof} 
\begin{lemma}
Let $D$ be a positive integer, but not a perfect square. Moreover, let $k$ be the primitive period of the continued fraction expansion (\ref{1.50}) of $\sqrt{D}$.
Then we have the identity
\[q_{2k-2} + q_{2k} = 2p_{2k-1} \,.\]
\label{Lem4}
\end{lemma} 
\begin{proof} Applying (\ref{2.120}) with $j=0$, and taking into account that $q_0=1$ and $p_0=a_0$, 
we obtain
\begin{equation}
q_{2k} = p_{2k-1} + a_0q_{2k-1} \,.
\label{2.190}
\end{equation} 
Additionally we express $q_{2k}$ by the basic recurrence formula
\[q_{2k} = a_{2k}q_{2k-1} + q_{2k-2} \,.\]
Taking (\ref{2.190}) into account, this gives
\[q_{2k-2} = q_{2k} - a_{2k}q_{2k-1} = p_{2k-1} + a_0q_{2k-1} - a_{2k}q_{2k-1} 
= p_{2k-1} + (a_0 - a_{2k})q_{2k-1} \,.\] 
We know \cite[\S \,24]{Perron} that $a_k = 2a_0 = 2\lfloor \sqrt{D} \rfloor$ holds for $a_k$ in (\ref{1.50}). Hence,
$a_0-a_{2k}=a_0-a_k=a_0-2a_0=-a_0$, which yields
\[q_{2k-2} = p_{2k-1} - a_0q_{2k-1} \,.\]
Adding (\ref{2.190}), we obtain the desired identity $q_{2k-2} + q_{2k} = 2p_{2k-1}$ in Lemma~\ref{Lem4}. 
\end{proof}

We continue proving (\ref{2.80}). First, let $k=1$. Then, (\ref{2.80}) is equivalent with $2p_1 - q_2 - 2 = q_1p_2 - p_1q_2 = -1$,
or $2p_1 = q_0 + q_2$. This holds by Lemma~\ref{Lem4}. In the following we may assume $k\geq 2$. With Lemma~\ref{Lem3}, Lemma~\ref{Lem4}, and 
$q_0=1$, we obtain, step by step,
\begin{eqnarray*}
1+\sum_{j=1}^{k-1} q_{2k-2j-2,2j+1} &amp;=&amp; 1+\sum_{j=0}^{k-2} q_{2k-2j-4,2j+3} = 1 - q_{2k-2} - q_{2k} + \sum_{j=0}^k q_{2j} \\
&amp;=&amp; 1 - 2p_{2k-1}  + \sum_{j=0}^k q_{2j} = 2 - 2p_{2k-1}  + \sum_{j=1}^k q_{2j} \,.
\end{eqnarray*}  
On the left-hand side we express 1 by $p_{2k-1}q_{2k} - p_{2k}q_{2k-1}$ and the terms of the sum by (\ref{2.130}) with $\nu=2k-1$,
$\mu=2j$. This gives the identity
\[p_{2k-1}\sum_{j=1}^k q_{2j} - q_{2k-1}\sum_{j=1}^k p_{2j} = 1 + \sum_{j=1}^{k-1} (p_{2k-1}q_{2j} - p_{2j}q_{2k-1}) 
= 2 - 2p_{2k-1}  + \sum_{j=1}^k q_{2j} \,,\]
which is equivalent with (\ref{2.80}). It remains to prove (\ref{2.85}), which (similar to (\ref{2.150})) relies on the 
basic identity
\begin{equation}
q_{2j-1} = q_{2j-1,2(k-j)} \qquad (1\leq j\leq k-1) \,.
\label{2.200}
\end{equation}
Instead of (\ref{2.170}) we have for $j\geq 1$ that
\[q_{2j-1} = q_{2j-1,0} = q_{2j-1} (\langle a_0,a_1,a_2,\ldots ,a_{2j-1} \rangle ) \,.\]
For $1\leq j\leq k-1$ we replace (\ref{2.180}) by
\begin{eqnarray*}
q_{2j-1,2(k-j)} &amp;=&amp; q_{2j-1} (\langle a_{2k-2j},a_{2k-2j+1},a_{2k-2j+2},\ldots ,a_{2k-2},a_{2k-1} \rangle ) \\
&amp;=&amp; q_{2j-1} (\langle a_{2j},a_{2j-1},a_{2j-2},\ldots ,a_{2},a_{1} \rangle ) \,,
\end{eqnarray*}
where again (\ref{2.160}) is taken into account. Finally, these results are combined by (\ref{2.140}), which is applied
with $n=2j-1\geq 1$ and $b_0=a_{2j}$. Thus,
\[q_{2j-1,2(k-j)} = q_{2j-1} (\langle a_0,a_1,a_2,\ldots ,a_{2j-1} \rangle ) = q_{2j-1} \qquad 
(1\leq j\leq k-1)\,.\]
This proves (\ref{2.200}). Hence, it follows by (\ref{2.200}) that
\begin{eqnarray*}
q_{2k-1} &amp;=&amp; q_{2k-1} + \sum_{j=1}^{k-1} (q_{2j-1} - q_{2j-1,2(k-j)}) \\
&amp;=&amp; q_{2k-1} + \sum_{j=1}^{k-1} q_{2j-1} - \sum_{j=1}^{k-1} q_{2k-2(k-j)-1,2(k-j)} \\
&amp;=&amp; q_{2k-1} + \sum_{j=1}^{k-1} q_{2j-1} - \sum_{j=1}^{k-1} q_{2k-2j-1,2j} \\
&amp;=&amp; \sum_{j=1}^k q_{2j-1} - \sum_{j=1}^k q_{2k-2j-1,2j} \,.
\end{eqnarray*} 
For the last equation we recall the formula $q_{-1,2k}=q_{-1}=0$.    
We express the terms of the right-hand sum by (\ref{2.130}), where we set $\nu =2k-1$ and $\mu =2j-1$. This gives
\[p_{2k-1}q_{2j-1} - p_{2j-1}q_{2k-1} = -q_{2k-2j-1,2j} \qquad (1\leq j \leq k) \,.\]
Hence we have 
\[q_{2k-1} = \sum_{j=1}^k q_{2j-1} + p_{2k-1}\sum_{j=1}^k q_{2j-1} - q_{2k-1}\sum_{j=1}^k p_{2j-1} \,,\]
which is equivalent with (\ref{2.85}). This completes the proof of Lemma~\ref{Lem2}. 
\end{proof}

\section{Proof of Theorem~\ref{Thm1}} \label{Sec3}
\begin{proof}[Proof of Theorem~\ref{Thm1}] 
The characteristic equation of the recurrence formula in Lemma~\ref{Lem1} is given by
\[z^2-2p_{2k-1}z+1 =0\,.\]
We denote the roots of this equation by $\a$ and $\b$, where $\a &gt;\b$. In particular,
\begin{equation}
\a = p_{2k-1} + \sqrt{p_{2k-1}^2-1} \,.
\label{3.10}
\end{equation}
$X:=p_{2k-1}$ and $Y:=q_{2k-1}$ form a solution of Pell's equation $X^2 - DY^2=1$  \cite[\S 27, Satz~3.18]{Perron}. 
Therefore, (\ref{3.10}) simplifies to
\begin{equation}
\a = p_{2k-1} + q_{2k-1}\sqrt{D} \,.
\label{3.20}
\end{equation}
The second zero $\b$ of the characteristic polynomial is   
\[\b = p_{2k-1} - q_{2k-1}\sqrt{D} = \frac{1}{p_{2k-1} + q_{2k-1}\sqrt{D}} = \frac{1}{\a} \,.\] 
Hence, by Lemma~\ref{Lem1}, we have the explicit formula 
\begin{equation}
u_{j+2kn} = C_1 \a^n + \frac{C_2}{\a^n} \qquad (n\geq 0) \,,
\label{3.30} 
\end{equation} 
where the constants $C_1$ and $C_2$ only depend on the first and second term $p_{j},p_{j+2k}$ or $q_{j},q_{j+2k}$, 
respectively, of the sequence ${(u_{j+2kn})}_{n\geq 0}$. To compute $C_1$ and $C_2$ we solve the linear system of equations,
\begin{eqnarray*}
A &amp;=&amp; C_1 + C_2 \,,\\
B &amp;=&amp; C_1\a + \frac{C_2}{\a} \,,
\end{eqnarray*} 
for $C_1$ and $C_2$. We obtain
\begin{eqnarray*}
C_1 &amp;=&amp; (\a B - A) \frac{1}{\a^2-1} \,,\\
C_2 &amp;=&amp; (\a A - B) \frac{\a}{\a^2-1} \,.
\end{eqnarray*}
Substituting $A=p_{j},B=p_{j+2k}$ for $n=0$ and $n=1$ into (\ref{3.30}), we find the values of $C_1$ and $C_2$ for
the sequence ${(p_{j+2kn})}_{n\geq 0}$. Similarly we obtain the constants for ${(q_{j+2kn})}_{n\geq 0}$ by choosing 
$A=q_{j},B=q_{j+2k}$. The resulting explicit formulas are 
\begin{eqnarray}
p_{j+2kn} &amp;=&amp; (\a p_{j+2k} - p_{j}) \frac{\a^n}{\a^2 -1} + (\a p_{j} - p_{j+2k}) 
\frac{\a}{\a^n(\a^2 -1)} \,,
\label{3.40} \\
q_{j+2kn} &amp;=&amp; (\a q_{j+2k} - q_{j}) \frac{\a^n}{\a^2 -1} + (\a q_{j} - q_{j+2k}) 
\frac{\a}{\a^n(\a^2 -1)} \,.
\label{3.50}
\end{eqnarray} 
These formulas will be used to transform the error sums into geometric series. To shorten the proofs of the two identities 
in Theorem~\ref{Thm1}, we introduce the notation $\ee^{(1)}:=\ee^*$ and $\ee^{(-1)}:=\ee$. Then, for $s=\pm 1$, we
have 
\begin{eqnarray}
\E^{(s)}(\sqrt{D}) &amp;=&amp; \sum_{m=0}^{\infty} s^m (q_{m}\sqrt{D} - p_{m}) =
\sqrt{D} - p_0 + \sum_{n=0}^{\infty} \sum_{j=1}^{2k} s^{j+2kn} (q_{j+2kn}\sqrt{D} - p_{j+2kn}) \nonumber \\
&amp;=&amp; \sqrt{D} - p_0 + \sum_{n=0}^{\infty} \sum_{j=1}^{2k} s^j\big( \,\sqrt{D} (\a q_{j+2k} - q_{j}) 
\frac{\a^n}{\a^2 -1} + \sqrt{D} (\a q_{j} - q_{j+2k}) \frac{\a}{\a^n(\a^2 -1)} \nonumber \\
&amp;&amp; \qquad - (\a p_{j+2k} - p_{j}) \frac{\a^n}{\a^2 -1} - (\a p_{j} - p_{j+2k}) 
\frac{\a}{\a^n(\a^2 -1)} \,\big) \nonumber \\
&amp;=&amp; \sqrt{D} - p_0 + \sum_{j=1}^{2k} s^j\big( \sqrt{D}(\a q_{j+2k} - q_{j}) - ( \a p_{j+2k} 
- p_{j}) \big) \sum_{n=0}^{\infty} \frac{\a^n}{\a^2 -1} 
\label{3.60} \\
&amp;&amp; \qquad + \sum_{j=1}^{2k} s^j\big( \sqrt{D}(\a q_{j} - q_{j+2k}) - (\a p_{j} 
- p_{j+2k}) \big) \sum_{n=0}^{\infty} \frac{\a}{\a^n(\a^2 -1)} \,.
\label{3.70}
\end{eqnarray} 
The underlying concept for the formulas in Theorem~\ref{Thm1} appears through the above sums where $j$ runs from 1 to 
$2k$: Here we do {\em not\/} consider a primitive period of the continued fraction expansion (\ref{1.50}) of $\sqrt{D}$, 
but we combine two primitive periods to a period of length $2k$, i.e., we use the expansion $\sqrt{D}=\langle a_0,
\overline{a_1,a_2,\ldots,a_{2k}}\,\rangle$. It follows from $\a &gt;1$ that the coefficient of the infinite series in 
(\ref{3.60}) vanishes, since $\ee^{(s)}(\sqrt{D})$ exists, while the second series in (\ref{3.70}) converges. Hence, 
\[\sum_{j=1}^{2k} s^j\big( \sqrt{D}(\a q_{j+2k} - q_{j}) - (\a p_{j+2k} - p_{j}) \big) = 0 \,.\]
The left-hand side of (\ref{2.70}) can be denoted by $\a$ using (\ref{3.20}). An equivalent version of (\ref{2.70}) is 
\[\sum_{j=1}^{2k} \sqrt{D} (\a q_{j} - q_{j+2k}) = - \sum_{j=1}^{2k} (\a p_{j} - p_{j+2k}) \,.\]
This equation simplifies the coefficient of the infinite series in (\ref{3.70}). Thus we obtain
\begin{eqnarray}
\E^{(s)}(\sqrt{D}) &amp;=&amp; \sqrt{D} - p_0 + \sum_{j=1}^{2k} 2s^j\sqrt{D} (\a q_{j} - q_{j+2k}) 
\sum_{n=0}^{\infty} \frac{\a}{\a^n(\a^2 -1)} \nonumber \\
&amp;=&amp; \sqrt{D} - p_0 + 2\sqrt{D} \frac{\a^2}{(\a^2 -1)(\a -1)}\sum_{j=1}^{2k} s^j(\a q_{j} - q_{j+2k}) \,.
\label{3.80}
\end{eqnarray}
Set $d:=2p_{2k-1}$. The equations
\begin{eqnarray*}
\frac{\a^2}{(\a^2 -1)(\a -1)} &amp;=&amp; \frac{\a +1}{d^2-4} \,,\\
\frac{\a^3}{(\a^2 -1)(\a -1)} &amp;=&amp; \frac{(d+1)\a -1}{d^2-4} 
\end{eqnarray*}
are a consequence of the algebraic identity $\a^2 -d\a +1=0$. Substituting into (\ref{3.80}) and replacing
$\a$ by (\ref{3.20}), we get
\begin{eqnarray*}
\E^{(s)}(\sqrt{D}) &amp;=&amp; \sqrt{D} - p_0 + 2\sqrt{D} \sum_{j=1}^{2k} s^j\frac{(d+1)\a -1}{d^2-4}\,q_{j}
- 2\sqrt{D} \sum_{j=1}^{2k} s^j\frac{\a +1}{d^2-4}\,q_{j+2k} \\
&amp;=&amp; \sqrt{D} - p_0 + \frac{2\a\sqrt{D}(d+1)}{d^2-4} \sum_{j=1}^{2k} s^jq_{j} - \frac{2\sqrt{D}}{d^2-4} \sum_{j=1}^{2k} s^jq_{j} 
- \frac{2\a\sqrt{D}}{d^2-4} \sum_{j=1}^{2k} s^jq_{j+2k} \\
&amp;&amp; - \frac{2\sqrt{D}}{d^2-4} \sum_{j=1}^{2k} s^jq_{j+2k} \\
&amp;=&amp; \sqrt{D} - p_0 + \frac{2(d+1)}{d^2-4}(p_{2k-1}\sqrt{D} + q_{2k-1}D) \sum_{j=1}^{2k} s^jq_{j} \\
&amp;&amp; - \frac{2}{d^2-4} (p_{2k-1}\sqrt{D} + q_{2k-1}D) \sum_{j=1}^{2k} s^jq_{j+2k} 
- \frac{2\sqrt{D}}{d^2-4} \sum_{j=1}^{2k} s^j(q_{j} + q_{j+2k}) \\
&amp;=&amp; \big( \,1+\frac{d}{d^2-4} \big( \,(d+1)\sum_{j=1}^{2k} s^jq_{j} - \sum_{j=1}^{2k} s^jq_{j+2k}\,\big) 
- \frac{2}{d^2-4} \sum_{j=1}^{4k} s^jq_{j} \,\big) \sqrt{D} \\
&amp;&amp; +\frac{2Dq_{2k-1}}{d^2-4} \big( \,(d+1)\sum_{j=1}^{2k} s^jq_{j} - \sum_{j=1}^{2k} s^jq_{j+2k}\,\big) - p_0 \,.
\end{eqnarray*} 
With
\[\frac{d}{d^2-4} = \frac{p_{2k-1}}{2Dq_{2k-1}^2}\,,\qquad \frac{2}{d^2-4} = \frac{1}{2Dq_{2k-1}^2} \,,
\qquad \frac{2Dq_{2k-1}}{d^2-4} = \frac{1}{2q_{2k-1}} \,, \]
we finally obtain for $s=\pm 1$ the two identities stated in Theorem~\ref{Thm1}.
\end{proof}

\section{Proof of Theorem~\ref{Thm2} and Theorem~\ref{Thm3}} \label{Sec4}
\begin{proof}[Proof of Theorem~\ref{Thm2}]  
For any function $f:{\N} \to {\N}$ and any positive integer $m$ the identities
\begin{equation}
\sum_{j=1}^{2m} {(-1)}^jf(j) + \sum_{j=1}^{2m} f(j) = 2\sum_{j=1}^m f(2j) \,,\qquad 
\sum_{j=1}^{2m} f(j) - \sum_{j=1}^{2m} {(-1)}^jf(j) = 2\sum_{j=1}^m f(2j-1) 
\label{4.05}
\end{equation}  
hold obviously. We use the left-hand formula when we add the equations from Theorem~\ref{Thm1}. Thus we obtain
\begin{eqnarray}
\eed(\sqrt{D}) &amp;=&amp; \frac{1}{2} \big( \ee(\sqrt{D})+\ee^*(\sqrt{D}) \big) \nonumber \\
&amp;=&amp; \big( 1 + \frac{p_{2k-1}}{2Dq_{2k-1}^2} \big( (2p_{2k-1} +1) \sum_{j=1}^{k} q_{2j} 
-\sum_{j=1}^{k} q_{2j+2k} \big) - \frac{1}{2Dq_{2k-1}^2} \sum_{j=1}^{2k} q_{2j} \big) \sqrt{D} \nonumber \\ 
&amp;&amp;+\,\frac{1}{2q_{2k-1}}  \big( (2p_{2k-1} +1) \sum_{j=1}^{k} q_{2j} - \sum_{j=1}^{k} q_{2j+2k} \big) - p_0 \,. 
\label{4.10}
\end{eqnarray}
To prove the vanishing of the irrational part, we have to show the following identity:
\begin{eqnarray}
2Dq_{2k-1}^2 + p_{2k-1}\big( (2p_{2k-1}+1)\sum_{j=1}^k q_{2j} - \sum_{j=1}^k q_{2j+2k} \big) - \sum_{j=1}^{2k} q_{2j} 
= 0 \,.
\label{4.20}
\end{eqnarray} 
Noting that $p_{2k-1}^2 - Dq_{2k-1}^2=1$, we obtain
\[\frac{p_{2k-1}-1}{q_{2k-1}} = \frac{p_{2k-1}^2-1}{q_{2k-1}(1+p_{2k-1})} = \frac{Dq_{2k-1}}{1+p_{2k-1}} \,.\]
Hence, equation (\ref{2.80}) in Lemma~\ref{Lem2} takes the form
\[\frac{Dq_{2k-1}}{1+p_{2k-1}} = \frac{\sum_{j=1}^k p_{2j}}{2+\sum_{j=1}^k q_{2j}} \,.\]
Then, 
\begin{eqnarray*}
2Dq_{2k-1}^2 &amp;=&amp; -Dq_{2k-1}^2 \sum_{j=1}^k q_{2j} + q_{2k-1} (1+p_{2k-1}) \sum_{j=1}^k p_{2j} \\
&amp;=&amp; \sum_{j=1}^k q_{2j} - p_{2k-1}^2\sum_{j=1}^k q_{2j} + q_{2k-1}\sum_{j=1}^k p_{2j} + p_{2k-1}q_{2k-1}\sum_{j=1}^k p_{2j} \\
&amp;=&amp; \sum_{j=1}^k q_{2j} + p_{2k-1}\sum_{j=1}^k q_{2j} + q_{2k-1}\sum_{j=1}^k p_{2j} - p_{2k-1} \big( (2p_{2k-1} + 1)
\sum_{j=1}^k q_{2j} \\
&amp;&amp; -\,p_{2k-1}\sum_{j=1}^k q_{2j} - q_{2k-1}\sum_{j=1}^k p_{2j} \big) \,. 
\end{eqnarray*}   
We replace $j$ by $2j$ in (\ref{2.120}). Hence $q_{2j+2k}=p_{2k-1}q_{2j}+q_{2k-1}p_{2j}$, which simplifies the above formula
by
\begin{eqnarray*}
2Dq_{2k-1}^2 &amp;=&amp; \sum_{j=1}^k q_{2j} + \sum_{j=1}^k q_{2j+2k} - p_{2k-1} \big( (2p_{2k-1} + 1)\sum_{j=1}^k q_{2j} 
- \sum_{j=1}^k q_{2j+2k} \big) 
\nonumber \\
&amp;=&amp; \sum_{j=1}^{2k} q_{2j} - p_{2k-1} \big( (2p_{2k-1} + 1)\sum_{j=1}^k q_{2j} - \sum_{j=1}^k q_{2j+2k} \big) \,,
\end{eqnarray*}
which is equivalent with (\ref{4.20}). An equivalent version of (\ref{4.20}) is
\[(2p_{2k-1} + 1)\sum_{j=1}^k q_{2j} - \sum_{j=1}^k q_{2j+2k} = \frac{1}{p_{2k-1}} \sum_{j=1}^{2k} q_{2j}
- \frac{2Dq_{2k-1}^2}{p_{2k-1}} \,,\]
which transforms (\ref{4.10}) into
\begin{eqnarray*}
\eed(\sqrt{D}) &amp;=&amp; \frac{1}{2q_{2k-1}}  \big( (2p_{2k-1} +1) \sum_{j=1}^{k} q_{2j} - \sum_{j=1}^{k} q_{2j+2k} \big) 
- p_0 \\
&amp;=&amp; \frac{1}{2p_{2k-1}q_{2k-1}} \sum_{j=1}^{2k} q_{2j} - \frac{Dq_{2k-1}}{p_{2k-1}} - \lfloor \sqrt{D} \rfloor \,.
\end{eqnarray*}
This completes the proof of Theorem~\ref{Thm2}. 
\end{proof}
\begin{proof}[Proof of Theorem~\ref{Thm3}]
It was already mentioned in Section~\ref{Sec1} that for $\ee(\sqrt{D})=\omega_1+\omega_3\sqrt{D}$ and $\ee^*(\sqrt{D})=\omega_2+\omega_4\sqrt{D}$
the relation $\omega_3=-\omega_4$ is an easy consequence of the rationality of $\eed(\sqrt{D})$. To complete the proof of 
Theorem~\ref{Thm3}, it remains to show the relation $\omega_2=1+\omega_1$. We take the expressions for $\omega_2$
and $\omega_1$ from Theorem~\ref{Thm1} and apply the right-hand formula in (\ref{4.05}). This gives
\begin{eqnarray*}
\omega_2 - \omega_1 &amp;:=&amp; \frac{1}{2q_{2k-1}}  \big( (2p_{2k-1} +1) \sum_{j=1}^{2k} q_j - \sum_{j=1}^{2k} q_{j+2k} \big) \\
&amp;&amp; -\,\frac{1}{2q_{2k-1}}  \big( (2p_{2k-1} +1) \sum_{j=1}^{2k} {(-1)}^j q_j - \sum_{j=1}^{2k} {(-1)}^j q_{j+2k} \big) \\
&amp;=&amp; \frac{1}{q_{2k-1}} \big( (2p_{2k-1} +1) \sum_{j=1}^k q_{2j-1} - \sum_{j=1}^k q_{2j+2k-1} \big) \,.
\end{eqnarray*}  
Replacing $k$ by $2k$ and $\nu$ by $2j$ in (\ref{2.100}), we obtain the formula
\[q_{2j+2k-1} = q_{2j-1}p_{2k-1} + p_{2j-1}q_{2k-1} \qquad (1\leq j\leq k) \,.\]
Hence,
\begin{eqnarray*}
q_{2k-1}(\omega_2 - \omega_1) &amp;=&amp; (2p_{2k-1}+1) \sum_{j=1}^k q_{2j-1} - p_{2k-1}\sum_{j=1}^k q_{2j-1} - q_{2k-1}\sum_{j=1}^k p_{2j-1} \\
&amp;=&amp; \sum_{j=1}^k (p_{2k-1}q_{2j-1} - q_{2k-1}p_{2j-1}) + \sum_{j=1}^k q_{2j-1} \\
&amp;=&amp; q_{2k-1} \,.
\end{eqnarray*} 
The last identity is a consequence of (\ref{2.85}) in Lemma~\ref{Lem2}. It follows that $\omega_2 - \omega_1=1$, which completes the proof of Theorem~\ref{Thm3}.
\end{proof}
%\newpage
\section{Appendix} \label{App}
It is easy to compute the error sums $\mathcal{E}(\sqrt{D})$, $\mathcal{E}^*(\sqrt{D})$, and $\E(\sqrt{D})$ by MAPLE using additionally the identities from
Theorem~\ref{Thm1} and Theorem~\ref{Thm2}. Table\,1 shows their values for $D=2,3,5,6,\ldots ,20$, $D=1000$, and $D=4729494$.
For $D=1000$ the complete regular continued fraction of $\sqrt{1000}$ is given by
\[\sqrt{1000} = \langle 31,\overline{1,1,1,1,1,6,2,2,15,2,2,6,1,1,1,1,1,62} \,\rangle \,.\]
The square root of $D=4729494$ plays an important role in solving Archimedes' cattle problem \cite{Vardi}. Here we obtain
the error sum values  
\begin{eqnarray*}
\mathcal{E}(\sqrt{D}) &amp;=&amp; \frac{20188024581818087903}{42064753838929196629}
+ \frac{60164573624755981416\sqrt{4729494}}{163337439156562070510407} \,,\\ \\
\mathcal{E}^*(\sqrt{D}) &amp;=&amp; \frac{62252778420747284532}{42064753838929196629}
- \frac{60164573624755981416\sqrt{4729494}}{163337439156562070510407} \,.
\end{eqnarray*}
The results of the computations with $D=1000$ and $D=4729494$ reveal a general phenomenon: numerators and denominators of the rationals
$\omega_1$ and $\omega_0$ in $\mathcal{E}(\sqrt{D})=\omega_1+\omega_0\sqrt{D}$ are significantly smaller than the denominators $q_{\nu}$ 
appearing in the formulas of Theorem~\ref{Thm1}. For instance, for $D=4729494$, we have 
\[q_{4k}=q_{368}=2.3363 \ldots \cdot 10^{177} \,.\]

Similarly we compute the values of $\mathcal{E}_{MC}(\sqrt{D}), \mathcal{E}_{MC}^*(\sqrt{D})$, and $\mathcal{E}_2(\sqrt{D})$
with the identities from Theorem~\ref{Thm4} and Theorem~\ref{Thm5}, respectively (Table\,2).

\begin{table}[H]
\centering
\[
\scalemath{0.7}{
\begin{array}{l|c|r|c|c|c}
D &amp; \sqrt{D} &amp; k &amp; \mathcal{E}(\sqrt{D}) &amp; \mathcal{E}^*(\sqrt{D}) &amp; \overline{\mathcal{E}}(\sqrt{D}) \\ \hline &amp; &amp; &amp; &amp; &amp; \\
2 &amp; \langle 1,\overline{2}\,\rangle &amp; 1 &amp; \displaystyle \frac{\sqrt{2}}{2} &amp; \displaystyle 1 - \frac{\sqrt{2}}{2} &amp; 
\displaystyle \frac{1}{2} \\ &amp; &amp; &amp; &amp; &amp; \\
3 &amp; \langle 1,\overline{1,2}\,\rangle &amp; 2 &amp; \displaystyle \frac{1}{2} + \frac{\sqrt{3}}{2} &amp; 
\displaystyle \frac{3}{2} - \frac{\sqrt{3}}{2} &amp; \displaystyle 1 \\ &amp; &amp; &amp; &amp; &amp; \\
5 &amp; \langle 2,\overline{4}\,\rangle &amp; 1 &amp; \displaystyle -\frac{1}{4} + \frac{\sqrt{5}}{4} &amp; 
\displaystyle \frac{3}{4} - \frac{\sqrt{5}}{4} &amp; \displaystyle \frac{1}{4} \\ &amp; &amp; &amp; &amp; &amp; \\
6 &amp; \langle 2,\overline{2,2,4}\,\rangle &amp; 2 &amp; \displaystyle \frac{\sqrt{6}}{4} &amp; 
\displaystyle 1 - \frac{\sqrt{6}}{4} &amp; \displaystyle \frac{1}{2} \\ &amp; &amp; &amp; &amp; &amp; \\
7 &amp; \langle 2,\overline{1,1,1,4}\,\rangle &amp; 4 &amp; \displaystyle \frac{1}{2} + \frac{5\sqrt{7}}{14} &amp; 
\displaystyle \frac{3}{2} - \frac{5\sqrt{7}}{14} &amp; 1 \\ &amp; &amp; &amp; &amp; &amp; \\
8 &amp; \langle 2,\overline{1,4}\,\rangle &amp; 2 &amp; \displaystyle \frac{1}{2} + \frac{\sqrt{2}}{2} &amp; 
\displaystyle \frac{3}{2} - \frac{\sqrt{2}}{2} &amp; 1 \\ &amp; &amp; &amp; &amp; &amp; \\
10 &amp; \langle 3,\overline{6}\,\rangle &amp; 1 &amp; \displaystyle -\frac{1}{3} + \frac{\sqrt{10}}{6} &amp; 
\displaystyle \frac{2}{3} - \frac{\sqrt{10}}{6} &amp; \displaystyle \frac{1}{6} \\ &amp; &amp; &amp; &amp; &amp; \\
11 &amp; \langle 3,\overline{3,6}\,\rangle &amp; 2 &amp; \displaystyle -\frac{1}{6} + \frac{\sqrt{11}}{6} &amp; 
\displaystyle \frac{5}{6} - \frac{\sqrt{11}}{6} &amp; \displaystyle \frac{1}{3} \\ &amp; &amp; &amp; &amp; &amp; \\
12 &amp; \langle 3,\overline{2,6}\,\rangle &amp; 2 &amp; \displaystyle \frac{\sqrt{3}}{3} &amp; 
\displaystyle 1 - \frac{\sqrt{3}}{3} &amp; \displaystyle \frac{1}{2} \\ &amp; &amp; &amp; &amp; &amp; \\
13 &amp; \langle 3,\overline{1,1,1,1,6}\,\rangle &amp; 5 &amp; \displaystyle \frac{13}{36} + \frac{11\sqrt{13}}{36} &amp; 
\displaystyle \frac{49}{36} - \frac{11\sqrt{13}}{36} &amp; \displaystyle \frac{31}{36} \\ &amp; &amp; &amp; &amp; &amp; \\
14 &amp; \langle 3,\overline{1,2,1,6}\,\rangle &amp; 4 &amp; \displaystyle \frac{1}{2} + \frac{3\sqrt{14}}{14} &amp; 
\displaystyle \frac{3}{2} - \frac{3\sqrt{14}}{14} &amp; 1 \\ &amp; &amp; &amp; &amp; &amp; \\
15 &amp; \langle 3,\overline{1,6}\,\rangle &amp; 2 &amp; \displaystyle \frac{1}{2} + \frac{\sqrt{15}}{6} &amp; 
\displaystyle \frac{3}{2} - \frac{\sqrt{15}}{6} &amp; 1 \\ &amp; &amp; &amp; &amp; &amp; \\
17 &amp; \langle 4,\overline{8}\,\rangle &amp; 1 &amp; \displaystyle -\frac{3}{8} + \frac{\sqrt{17}}{8} &amp; 
\displaystyle \frac{5}{8} - \frac{\sqrt{17}}{8} &amp; \displaystyle \frac{1}{8} \\ &amp; &amp; &amp; &amp; &amp; \\
18 &amp; \langle 4,\overline{4,8}\,\rangle &amp; 2 &amp; \displaystyle -\frac{1}{4} + \frac{3\sqrt{2}}{8} &amp; 
\displaystyle \frac{3}{4} - \frac{3\sqrt{2}}{8} &amp; \displaystyle \frac{1}{4} \\ &amp; &amp; &amp; &amp; &amp; \\
19 &amp; \langle 4,\overline{2,1,3,1,2,8}\,\rangle &amp; 6 &amp; \displaystyle -\frac{1}{26} + \frac{5\sqrt{19}}{26} &amp; 
\displaystyle \frac{25}{26} - \frac{5\sqrt{19}}{26} &amp; \displaystyle \frac{6}{13} \\ &amp; &amp; &amp; &amp; &amp; \\
20 &amp; \langle 4,\overline{2,8}\,\rangle &amp; 2 &amp; \displaystyle \frac{\sqrt{5}}{4} &amp; 
\displaystyle 1 - \frac{\sqrt{5}}{4} &amp; \displaystyle \frac{1}{2} \\ &amp; &amp; &amp; &amp; &amp; \\
1000 &amp; \langle 31,\overline{1,\ldots ,62}\,\rangle &amp; 18 &amp; \displaystyle \frac{4351}{8886} + \frac{965\sqrt{10}}{2962} &amp; 
\displaystyle \frac{13237}{8886} - \frac{965\sqrt{10}}{2962} &amp; \displaystyle \frac{4397}{4443} \\ &amp; &amp; &amp; &amp; &amp; \\
4729494 &amp; \langle 2174,\overline{1,\ldots ,4348}\,\rangle &amp; 92 &amp; \ldots &amp; \dots &amp; 
\displaystyle \frac{82440803002565372435}{84129507677858393258}
\end{array}
} \]
\end{table}
\centerline{Table 1}

\begin{table}[H]
\centering
\[
\scalemath{0.7}{
\begin{array}{l|c|r|c|c|c}
D &amp; \sqrt{D} &amp; k &amp; \mathcal{E}_{MC}(\sqrt{D}) &amp; \mathcal{E}_{MC}^*(\sqrt{D}) &amp; \displaystyle \mathcal{E}_2(\sqrt{D}) + \frac{1}{2}\\ &amp; &amp; &amp; &amp; \\ \hline &amp; &amp; &amp; &amp; \\
2 &amp; \langle 1,\overline{2}\,\rangle &amp; 1 &amp; \displaystyle 1 + \frac{\sqrt{2}}{2} &amp; \displaystyle 2 - \frac{3\sqrt{2}}{2}
&amp; \displaystyle \frac{\sqrt{2}}{2} \\ &amp; &amp; &amp; &amp; \\
3 &amp; \langle 1,\overline{1,2}\,\rangle &amp; 2 &amp; 2 &amp; 3 - \sqrt{3} 
&amp; \displaystyle \frac{2\sqrt{3}}{3} \\ &amp; &amp; &amp; &amp; \\
5 &amp; \langle 2,\overline{4}\,\rangle &amp; 1 &amp; \displaystyle \frac{7}{2} - \frac{\sqrt{5}}{2} &amp;  
\displaystyle \frac{9}{2} - \frac{5\sqrt{5}}{2} 
&amp; \displaystyle \frac{\sqrt{5}}{4} \\ &amp; &amp; &amp; &amp; \\
6 &amp; \langle 2,\overline{2,2,4}\,\rangle &amp; 2 &amp; \displaystyle \frac{9}{2} - \sqrt{6} &amp; 
\displaystyle \frac{11}{2} - 2\sqrt{6} 
&amp; \displaystyle \frac{7\sqrt{6}}{24} \\ &amp; &amp; &amp; &amp; \\
7 &amp; \langle 2,\overline{1,1,1,4}\,\rangle &amp; 4 &amp; \displaystyle 5 - \frac{8\sqrt{7}}{7} &amp; 
\displaystyle 6 - \frac{13\sqrt{7}}{7} 
&amp; \displaystyle \frac{3\sqrt{7}}{7} \\ &amp; &amp; &amp; &amp; \\
8 &amp; \langle 2,\overline{1,4}\,\rangle &amp; 2 &amp; \displaystyle \frac{13}{2} - \frac{5\sqrt{2}}{2} &amp; 
\displaystyle \frac{15}{2} - \frac{7\sqrt{2}}{2} 
&amp; \displaystyle \frac{7\sqrt{2}}{8} \\ &amp; &amp; &amp; &amp; \\
10 &amp; \langle 3,\overline{6}\,\rangle &amp; 1 &amp; \displaystyle 8 - \frac{3\sqrt{10}}{2} &amp; 
\displaystyle 9 - \frac{7\sqrt{10}}{2} 
&amp; \displaystyle \frac{\sqrt{10}}{6} \\ &amp; &amp; &amp; &amp; \\
11 &amp; \langle 3,\overline{3,6}\,\rangle &amp; 2 &amp; 9 - 2\sqrt{11} &amp; 10 - 3\sqrt{11} 
&amp; \displaystyle \frac{2\sqrt{11}}{11} \\ &amp; &amp; &amp; &amp; \\
12 &amp; \langle 3,\overline{2,6}\,\rangle &amp; 2 &amp; \displaystyle 10 - \frac{13\sqrt{3}}{3} &amp; 
\displaystyle 11 - \frac{17\sqrt{3}}{3} 
&amp; \displaystyle \frac{5\sqrt{3}}{12} \\ &amp; &amp; &amp; &amp; \\
13 &amp; \langle 3,\overline{1,1,1,1,6}\,\rangle &amp; 5 &amp; \displaystyle \frac{169}{18} - \frac{37\sqrt{13}}{18} &amp; 
\displaystyle \frac{187}{18} - \frac{53\sqrt{13}}{18} 
&amp; \displaystyle \frac{11\sqrt{13}}{36} \\ &amp; &amp; &amp; &amp; \\
14 &amp; \langle 3,\overline{1,2,1,6}\,\rangle &amp; 4 &amp; \displaystyle 11 - \frac{16\sqrt{14}}{7} &amp; 
\displaystyle 12 - \frac{19\sqrt{14}}{7} 
&amp; \displaystyle \frac{5\sqrt{14}}{16} \\ &amp; &amp; &amp; &amp; \\
15 &amp; \langle 3,\overline{1,6}\,\rangle &amp; 2 &amp; \displaystyle 13 - \frac{7\sqrt{15}}{3} &amp; 
\displaystyle 14 - \frac{8\sqrt{15}}{3} 
&amp; \displaystyle \frac{\sqrt{15}}{3}  \\ &amp; &amp; &amp; &amp; \\ 
17 &amp; \langle 4,\overline{8}\,\rangle &amp; 1 &amp; \displaystyle \frac{29}{2} - \frac{5\sqrt{17}}{2} &amp; 
\displaystyle \frac{31}{2} - \frac{9\sqrt{17}}{2} 
&amp; \displaystyle \frac{\sqrt{17}}{8} \\ &amp; &amp; &amp; &amp; \\
18 &amp; \langle 4,\overline{4,8}\,\rangle &amp; 2 &amp; \displaystyle \frac{31}{2} - 9\sqrt{2} &amp; 
\displaystyle \frac{33}{2} - 12\sqrt{2} 
&amp; \displaystyle \frac{19\sqrt{2}}{48}  \\ &amp; &amp; &amp; &amp; \\
19 &amp; \langle 4,\overline{2,1,3,1,2,8}\,\rangle &amp; 6 &amp; \displaystyle \frac{199}{13} - \frac{40\sqrt{19}}{13} &amp; 
\displaystyle \frac{212}{13} - \frac{51\sqrt{19}}{13} &amp; \displaystyle \frac{122\sqrt{19}}{741} \\ &amp; &amp; &amp; &amp; \\
20 &amp; \langle 4,\overline{2,8}\,\rangle &amp; 2 &amp; \displaystyle \frac{35}{2} - \frac{13\sqrt{5}}{2} &amp; 
\displaystyle \frac{37}{2} - \frac{15\sqrt{5}}{2} &amp; \displaystyle \frac{13\sqrt{5}}{40} \\ &amp; &amp; &amp; &amp; \\
1000 &amp; \langle 31,\overline{1,\dots ,62}\,\rangle &amp; 18 &amp; \displaystyle \frac{8577575}{8886} - 
\frac{2707235\sqrt{10}}{8886} &amp; \displaystyle \frac{8586461}{8886} - \frac{2713225\sqrt{10}}{8886} &amp; 
\displaystyle \frac{88525597\sqrt{10}}{249696600}
\end{array} 
} \]
\end{table}
\centerline{Table 2}


\begin{thebibliography}{99}   
\bibitem{Elsner1} C. Elsner and T. Komatsu, On the residue classes of integer sequences satisfying a linear three term recurrence formula,
{\it Linear Algebra Appl.} {\bf 429} (2008), 933--947.
\bibitem{Elsner4} C. Elsner, Series of error terms for rational approximations of irrational numbers,
{\it J. Integer Seq.} {\bf 14} (2011), 
\href{https://cs.uwaterloo.ca/journals/JIS/VOL14/Elsner/elsner9.html}{Article 11.1.4}.
\bibitem{Elsner5} C. Elsner and M. Stein, On the value distribution of error sums for approximations with rational numbers,
{\it Integers} {\bf 12} (2012), A66, 1--28. 
\bibitem{Elsner6} C. Elsner and M. Stein, On error sum functions formed by convergents of real numbers,
{\it J. Integer Seq.} {\bf 14} (2011), 
\href{https://cs.uwaterloo.ca/journals/JIS/VOL14/Elsner2/elsner10.html}{Article 11.8.6}. 
\bibitem{Perron} O. Perron, {\it Die Lehre von den Kettenbr{\"u}chen}, Bd.\,1, Wissenschaftliche Buchgesellschaft, 1977.
\bibitem{Ridley} J. N. Ridley and G. Petruska, The error-sum function of continued fractions,
{\it Indag. Math.} (N.S.), {\bf 11}, (2000), 273--282.
\bibitem{Vardi} I. Vardi, Archimedes' cattle problem, {\it Amer. Math. Monthly} {\bf 105} (1998), 305--319.
\end{thebibliography}  



\bigskip
\hrule
\bigskip

\noindent 2010 {\it Mathematics Subject Classification}:
Primary 11J70, Secondary 11J04, 11D09, 11B39.

\noindent \emph{Keywords: } 
error sum, continued fraction, convergent, Pell's equation, Lucas
number, Pell number.

\bigskip
\hrule
\bigskip

\noindent (Concerned with sequences
\seqnum{A000032},
\seqnum{A000045},
\seqnum{A000129},
\seqnum{A040968}, and
\seqnum{A235861}.)

\bigskip
\hrule
\bigskip

\vspace*{+.1in}
\noindent
Received September 9 2013;
revised version received  January 21 2014.
Published in {\it Journal of Integer Sequences}, February 16 2014.


\bigskip
\hrule
\bigskip

\noindent
Return to
\htmladdnormallink{Journal of Integer Sequences home page}{http://www.cs.uwaterloo.ca/journals/JIS/}.
\vskip .1in


\end{document}

                                                                                

</pre></body></html>