\documentclass[12pt,reqno]{article}

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

\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 Continued Fractions with  \\
\vskip .1in
Non-Integer Numerators}
\vskip 1cm
\large
John Greene and Jesse Schmieg \\
Department of Mathematics and Statistics \\
University of Minnesota Duluth \\
Duluth, MN 55812 \\
USA \\
\href{mailto:jgreene@d.umn.edu}{\tt jgreene@d.umn.edu} \\
\href{mailto:schm3241@d.umn.edu}{\tt schm3241@d.umn.edu} \\
\end{center}

\vskip .2 in

\begin{abstract}
Anselm and Weintraub investigated a generalization of classic continued fractions, where the ``numerator" 1 is replaced by an arbitrary positive integer.  Here, we generalize further to the case of an arbitrary real number $z \geq 1$.  We focus mostly on the case where $z$ is rational but not an integer.  Extensive attention is given to periodic expansions and expansions for $\sqrt{n}$, where we note similarities and differences between the case where $z$ is an integer and when $z$ is rational.  When $z$ is not an integer, it need no longer be the case that $\sqrt{n}$ has a periodic expansion.  We give several infinite families where periodic expansions of various types exist.
\end{abstract}

\section{Introduction}
Let $z$ be a positive real number.  In this paper, we consider continued fractions of the form
\begin{equation*}
a_0+\cfrac{z}{a_1+\cfrac{z}{a_2+\cfrac{z}{a_3+\cdots}}},
\end{equation*}
where $a_{0}$ is an integer and $a_{1}, a_{2}, a_{3}, \ldots$ are positive integers.  We denote such a continued fraction by $[a_{0}, a_{1}, a_{2}, \ldots]_{z}$, and following Anselm and Weintraub \cite{AW11}, we refer to this as a $\text{cf}_{z}$ expansion.  Such continued fraction expansions where $z$ is a positive integer have been investigated before.  
Burger and his co-authors showed that there are infinitely many positive integers $z$ for which $\sqrt{n}$ has a periodic expansion with period 1.  A similar result, but for quasi-periodic continued fractions was obtained by Komatsu \cite{tK09}.  A more general, comprehensive study of $\text{cf}_{z}$ expansions with $z$ a positive integer was conducted Anselm and Weintraub \cite{AW11}.  One result of Anselm and Weintraub is that if $z \geq 2$ is an integer, then every real $x$ has infinitely many $\text{cf}_{z}$ expansions \cite[Theorem 1.8]{AW11}.  More recently, Dajani, Kraaikamp and Wekken \cite{DKW13} interpreted $\text{cf}_{z}$ expansions with positive integer $z$ in terms of dynamical systems to product an ergodic proof of \cite[Theorem 1.8]{AW11}.  This work was extended and further generalized by Dajani, Kraaikamp and Langeveld \cite{DKW13}.

In this paper, we ask what happens if one drops the condition that $z$ be an integer.  We mostly follow Anselm and Weintraub \cite{AW11} as we investigate general $\text{cf}_{z}$ expansions where $z$ is only assumed to be a positive real number.  We begin with a discussion of the general case (usually satisfying $z \geq 1$) in Sections 2 and 3.  Our main focus, however, is the case where $z$ is a rational number, with some attention to the case where $z$ is a quadratic irrational as well.

When $z$ is an integer, it is shown by Anselm and Weintraub \cite{AW11} that many well-known properties of simple continued fractions are preserved, most notably that every rational number has a finite $\text{cf}_{z}$ expansion and every quadratic irrational has a periodic $\text{cf}_{z}$ expansion.  When $z$ is rational, but not an integer, both of these properties can fail.  Formula \eqref{maximalExpansions_7_4_21_16} gives an example where the unique $\text{cf}_{z}$ expansion of $\frac{7}{4}$ is periodic, and Conjecture \ref{11eigthsConjecture} gives an example of a rational $x$ and rational $z$ for which the $\text{cf}_{z}$ expansion of $x$ appears to be aperiodic.  General properties of $\text{cf}_{z}$ expansions with rational $z$ are given in Section 4.

The notion of a reduced quadratic surd is important in the theory of simple continued fractions.  Anselm and Weintraub  modified the definition of a reduced quadratic surd \cite[Definition 2.12]{AW11} so as to apply to integers $z > 1$.  We must again modify this definition to make it applicable to our more general setting.  In Section 5, we introduce the notion of a pseudo-conjugate for a number $x$ with a periodic $\text{cf}_{z}$ expansion and use this to develop the appropriate definition of a reduced surd.  The properties of a reduced surd are developed in Section 5 as well.  Finally, these properties are applied to expansions for $\sqrt{n}$ in Section 6, and several infinite families of periodic expansions of $\sqrt{n}$ are given.

\section{Continued fractions as rational functions}

If we view $a_{0}, \ldots, a_{n}$ and $z$ as being indeterminates, then the finite continued fraction $[a_{0}, a_{1}, \ldots, a_{n}]_{z}$ is a rational function in these variables.  Many of the results from Anselm and Weintraub \cite{AW11} are special cases of formulas of Perron's \cite{oP13} and carry over with little or no modification to this rational function setting.  In this section, we give the most important properties of $[a_{0}, a_{1}, \ldots, a_{n}]_{z}$ as a rational function.

\begin{lemma} 
As rational function identities, we have
\begin{align}
 [a_{0}, a_{1}, \ldots, a_{n}]_{z} &= [a_{0}, a_{1}, \ldots, a_{k - 1}, [a_{k}, a_{k + 1}, \ldots, a_{n}]_{z}]_{z}, \label{rationalFunctions1} \\
 \notag \\
 [a_{0}, a_{1}, \ldots, a_{n}]_{z} &= [a_{0}, a_{1}, \ldots, a_{n - 2}, a_{n - 1} + z/a_{n}]_{z} \label{rationalFunctions2} \\
 \notag \\
 [a_{0}, ya_{1}, a_{2}, ya_{3}, &\ldots, xa_{n}]_{yz} = [a_{0}, a_{1}, \ldots, a_{n}]_{z}, \label{rationalFunctions3}
\end{align}
where $x = 1$, if $n$ is even, $y$ if $n$ is odd.
\end{lemma}

Given a sequence $a_{0}, a_{1}, a_{2}, \ldots$, define polynomials $p_{n}$ and $q_{n}$ recursively by
\begin{align}
p_{-1} &= 1, \qquad p_{0} = a_{0}, \qquad p_{n} = a_{n}p_{n - 1} + zp_{n - 2}, \quad \text{for } n \geq 1,\\
q_{-1} &= 0, \, \qquad q_{0} = 1, \; \qquad  q_{n} = a_{n}q_{n - 1} + zq_{n - 2}, \quad \text{for } n \geq 1.
\end{align}
As in \cite{AW11}, and more generally in \cite{oP13} we have the following.

\begin{theorem}\label{T: rec} 
\label{pnqnidentities}
For polynomials $p_{n}$ and $q_{n}$ so defined,
\begin{align}
p_{n}q_{n - 1} - p_{n - 1}q_{n} &= (-1)^{n - 1} \, z^{n}, \label{pnqnEqualities1} \\
p_{n}q_{n - 2} - p_{n - 2}q_{n} &= (-1)^{n}a_{n}z^{n - 1}, \label{pnqnEqualities2} \\
\frac{p_{n}}{q_{n}} &= [a_{0}, a_{1}, \ldots, a_{n}]_{z}, \label{pnqnEqualities3} \\
[a_{0}, a_{1}, \ldots, a_{n}, x]_{z} &= \frac{p_{n}x + zp_{n - 1}}{q_{n}x + zq_{n - 1}}. \label{pnqnEqualities4}
\end{align}
\end{theorem}

We will write $C_{n}$ for $\frac{p_{n}}{q_{n}}$, and following the usual conventions, as given, say, by Hardy and Wright \cite[Chapter X]{HW79} or Olds 
\cite[p.~231]{wL77}, we refer to the variables $a_{0}, a_{1}, \ldots$ as the partial quotients of the $\text{cf}_{z}$ expansion and the $C_{n}$ as the convergents of the expansion.

We view each $p_{k}$ as being a polynomial in $a_{0}, \ldots, a_{k}$, and $z$.  We find it useful to think of $q_{k}$ as a polynomial in $a_{0}, \ldots, a_{k}$ and $z$ even though it does not depend on $a_{0}$.  With this perspective, we have certain symmetry properties of $p_{n}$ and $q_{n}$ with respect to their variables and each other.

\begin{theorem}\label{T: sym} 
\label{pnqnrelationships}
The following relationships exist among $p_{n}$ and $q_{n}$.
\begin{itemize}
\item[(a)] $q_{n}(a_{0}, a_{1}, \ldots, a_{n}) = p_{n - 1}(a_{1}, \ldots, a_{n})$,
\item[(b)] $p_{n}(a_{0}, a_{1}, \ldots, a_{n}) = a_{0}q_{n}(a_{0}, a_{1}, \ldots, a_{n}) + zq_{n - 1}(a_{1}, \ldots, a_{n})$,
\item[(b)] $q_{n}(a_{0}, a_{1}, \ldots, a_{n}) = q_{n}(a_{n + 1}, a_{n}, \ldots, a_{1})$,
\item[(d)] $p_{n}(a_{0}, a_{1}, \ldots, a_{n}) = p_{n}(a_{n}, a_{n - 1}\ldots, a_{0})$.
\end{itemize}
\end{theorem}
\begin{proof}
Part (a) is a direct consequence of the recurrences for $q_{n}$ and $p_{n}$.  That is, $q_{n}$ satisfies the same recurrence as $p_{n - 1}$, but with indices for the $a$'s augmented by 1.  The other formulas are straightforward inductions.  We content ourselves with demonstrating part (d).  Assuming the rest of the formulas,
\begin{align*}
p_{n}(a_{0}, \ldots, a_{n}) &=  a_{0}q_{n}(a_{0}, a_{1}, \ldots, a_{n}) + zq_{n - 1}(a_{1}, \ldots, a_{n}) \\
&= a_{0}p_{n - 1}(a_{1}, \ldots, a_{n}) + zp_{n - 2}(a_{2}, \ldots, a_{n}) \\
&= a_{0}p_{n - 1}(a_{n}, \ldots, a_{1}) + zp_{n - 2}(a_{n}, \ldots, a_{2}) \\
&= p_{n}(a_{n}, a_{n - 1}\ldots, a_{0}).
\end{align*}
\end{proof}

We end this section with some facts on the polynomial structure of $p_{n}$ and $q_{n}$.

\begin{theorem}
\label{pnqnproperties}
Viewing $p_{n}$ and $q_{n}$ as polynomials in $a_{0}, \ldots, a_{n}, z$, we have
\begin{itemize}
\item[(a)]  every coefficient in each polynomial is 1.
\item[(b)] When viewed as polynomials in $z, \; \deg(p_{n}) = \lceil \frac{n}{2} \rceil, \; \deg(q_{n}) = \lfloor \frac{n}{2} \rfloor$.
\item[(c)] If $m = \lceil \frac{n}{2} \rceil$, the coefficient of $z^{m - k}$ in $p_{n}$ is a homogeneous polynomial in $a_{0}, \ldots, a_{n}$ of degree $2k + 1$ when $n$ is even, and $2k$ when $n$ is odd.  This polynomial can be explicitly described:  if it has degree $j$, then it consists of the sum of all terms of the form $a_{i_{1}}a_{i_{2}}\cdots a_{i_{j}}$ with $i_{1} < i_{2} < \cdots < i_{j}$, with $i_{1}$ even, $i_{2}$ odd, $i_{3}$ even, and so on.
\item[(d)]   If $m = \lfloor \frac{n}{2} \rfloor$, the coefficient of $z^{m - k}$ in $q_{n}$ is a homogeneous polynomial in $a_{1}, \ldots, a_{n}$ of degree $2k$ when $n$ is even, and $2k - 1$ when $n$ is odd.  Such a polynomial of degree $j$ is of the sum of all terms of the form $a_{i_{1}}a_{i_{2}}\cdots a_{i_{j}}$ with $i_{1} < i_{2} < \cdots < i_{j}$, with $i_{1}$ odd, $i_{2}$ even, $i_{3}$ odd, and so on.
\end{itemize}
\end{theorem}

For example,
\begin{align*}
 p_{5} &= z^{3} + (a_{0}a_{1} + a_{0}a_{3} + a_{0}a_{5} + a_{2}a_{3} + a_{2}a_{5} + a_{4}a_{5})z^{2} \\
 &+ (a_{0}a_{1}a_{2}a_{3} + a_{0}a_{1}a_{2}a_{5} + a_{0}a_{1}a_{4}a_{5} + a_{0}a_{3}a_{4}a_{5} + a_{2}a_{3}a_{4}a_{5})z + a_{0}a_{1}a_{2}a_{3}a_{4}a_{5}, \\
  q_{5} &= (a_{1} + a_{3} + a_{5})z^{2} + (a_{1}a_{2}a_{3} + a_{1}a_{2}a_{5} + a_{1}a_{4}a_{5} + a_{3}a_{4}a_{5})z + a_{1}a_{2}a_{3}a_{4}a_{5}.
\end{align*}

The proof of Theorem \ref{pnqnproperties} is a straightforward induction.  We note that as polynomials in $z, \; p_{n}$ is monic if $n$ is odd and $q_{n}$ is monic if $n$ is even.

\section{Representation, convergence and uniqueness issues} 

In this section we let $z, a_{0}, a_{1}, \ldots$ be real numbers.  Usually, $a_{0}$ will be a an integer and $a_{k}$ will be a positive integer for $k \geq 1$.  In the case where  $z, a_{0}, a_{1}, \ldots$ are all integers, $p_{n}$ and $q_{n}$ are also integer sequences.  In the case where $z$ is not an integer, however, $p_{n}$ and $q_{n}$ will usually not be integers.

The following is useful.

\begin{lemma}\label{L: quot}
Let $x$ and $a_{0}$ be real and let $a_{1}, a_{2}, a_{3}, \ldots, a_{m}$ be positive real numbers.  Suppose a sequence $\{ x_{k} \}$  can be defined by $\displaystyle x_{0} = x, \; x_{k} = \frac{z}{x_{k - 1} - a_{k - 1}}$ for all $k \leq m$.  This will be the case provided that $x_{k} \neq a_{k}$ for all $k \leq m - 1$. Then for each $n \leq m$,
\[
 x = [a_{0}, a_{1}, \ldots, a_{n - 1}, x_{n}]_{z}.
\]
\end{lemma}

This lemma is a direct consequence of formula \eqref{rationalFunctions2}.  Following \cite{HW79, wL77} we refer to the $x_{n}$ in Lemma \ref{L: quot} as the $n$'th complete quotient for $x$.

We now investigate convergence issues.  For general real sequences $\{a_{n} \}$ we have the following.

\begin{theorem}\label{T: conv} 
If $z > 0$ and $a_{k} \geq 1$ for all $k \geq 1$ then
\[  [a_{0}, a_{1},a_{2} \ldots ]_{z} = \lim_{n \to \infty} [a_{0}, a_{1}, a_{2}, \ldots, a_{n}]_{z}
\]
exists.
\end{theorem}
\begin{proof}
We follow the usual proof that infinite simple continued fractions converge.  Let $\displaystyle C_{n} = [a_{0}, a_{1}, a_{2}, \ldots, a_{n}]_{z} = \frac{p_{n}}{q_{n}}$.  By \eqref{pnqnEqualities2},
\[  C_{n} - C_{n - 2} = \frac{(-1)^{n}a_{n}z^{n - 1}}{q_{n}q_{n - 2}},
\]
so $C_{n} > C_{n - 2}$ whenever $n$ is even, and $C_{n} < C_{n - 2}$ when $n$ is odd.  Thus, the even $C$'s form an increasing sequence and the odd $C$'s form a decreasing sequence.  By \eqref{pnqnEqualities1}, $C_{2n} < C_{2n + 1}$ for each $n$ so $C_{0} < C_{2n} < C_{2n + 1} < C_{1}$, meaning each subsequence is bounded, and so convergent.  By \eqref{pnqnEqualities1},
\[  C_{n} - C_{n - 1} = \frac{(-1)^{n - 1}z^{n}}{q_{n}q_{n - 1}}.
\]
Thus, it remains to show that $q_{n}q_{n - 1}$ goes to infinity faster than $z^{n}$.  The slowest growth for $q_{n}$ occurs when all the $a$'s are 1, in which case $q_{n} = q_{n - 1} + zq_{n - 2}$ for all $n \geq 2$.  An easy induction shows that for all $\displaystyle n \geq 0, \; q_{n} \geq (1 + z)^{\lfloor \frac{n}{2} \rfloor}$, from which the result follows.
\end{proof}

Thus, all finite and infinite continued fraction expansions represent real numbers.  With no restrictions on the $a_{k}$, all reals can be represented as $\text{cf}_{z}$ expansions so from this point on, we restrict $a_{0}$ to be a an integer and $a_{k}$ to be a positive integer for all $k \geq 1$.

\begin{theorem}\label{T: rep}
Every real number has at least one $\text{cf}_{z}$ expansion if and only if $z \geq 1$.
\end{theorem}

\begin{proof}
First, if $0 < z < 1$ then no real $x$ with $z < x < 1$ can be represented as a $\text{cf}_{z}$ expansion.  This is because the convergents $C_{n}$ of Theorem \ref{T: conv} are increasing for even $n$, and decreasing for odd $n$.  Thus any $y = [a_{0}, a_{1}, a_{2}, \ldots]_{z}$ must satisfy $\displaystyle a_{0} \leq y \leq a_{0} + \frac{z}{a_{1}}$.  Consequently, if $y < 1$ then $a_{0}$ must be 0, forcing $\displaystyle y \leq \frac{z}{a_{1}} \leq z$.

Next, suppose that $z \geq 1$.  Since all integers have $\text{cf}_{z}$ expansions, let $x$ be a non-integer.  Following \cite{AW11} we construct a $\text{cf}_{z}$ expansion for $x$ as follows:  Let $x_{0} = x, \; a_{0} = \lfloor x \rfloor$ and $x_{1} = \displaystyle \frac{z}{x - a_{0}}$.  For $n \geq 1$, given $x_{n}$, let $a_{n}$ be a positive integer satisfying $x_{n} - z \leq a_{n} \leq x_{n}$.  If $x_{n} - a_{n} = 0$ stop.  Otherwise, set $\displaystyle x_{n + 1} = \frac{z}{x_{n} - a_{n}}$  and continue.  By construction, $0 \leq x_{n} - a_{n} < z$ so if $x_{n} - a_{n} \neq 0$ then $x_{n + 1} > 1$.  Thus, for each $x_{n}$ there will be a valid choice for $a_{n}$. This associates with $x$ the $\text{cf}_{z}$ expansion $[a_{0}, a_{1}, a_{2}, \ldots ]_{z}$, where the length of this expansion is finite if any $x_{n} = a_{n}$, and infinite otherwise.  We claim that
\[  x = [a_{0}, a_{1}, a_{2}, \ldots ]_{z}.
\]
To prove this, we first note that by Lemma \ref{L: quot} and the construction of the $x_{n}$,
\[
x = [a_{0}, a_{1}, a_{2}, \ldots, a_{n - 1}, x_{n} ]_{z}.
\]
Consequently, by formula \eqref{pnqnEqualities4}, $\displaystyle x = \frac{p_{n - 1}x_{n} + zp_{n - 2}}{q_{n - 1}x_{n} + zq_{n - 2}}$.  Thus,
\begin{align*}
x - [a_{0}, a_{1}, a_{2}, \ldots, a_{n - 1}]_{z} &= \frac{p_{n - 1}x_{n} + zp_{n - 2}}{q_{n - 1}x_{n} + zq_{n - 2}} - \frac{p_{n - 1}}{q_{n - 1}} \\
&= \frac{z(p_{n - 2}q_{n - 1} - p_{n - 1}q_{n - 2})}{q_{n - 1}(q_{n - 1}x_{n} + zq_{n - 2})}.
\end{align*}
That is,
\[ |x - [a_{0}, a_{1}, a_{2}, \ldots, a_{n - 1}]_{z}| < \frac{z^{n}}{q_{n - 1}^{2}},
\]
and the left hand side of this expression goes to 0 as $n$ goes to infinity (as in the proof of Theorem \ref{T: conv}), completing the proof.
\end{proof}

As a consequence, we have the following.

\begin{corollary}
\label{xnpart}
If $x = [a_{0}, a_{1}, a_{2}, a_{3}, \ldots]_{z}$ then with the $x_{n}$ as defined in Lemma \ref{L: quot} we have
\[  x_{n} = [a_{n}, a_{n + 1}, a_{n + 2}, \ldots]_{z}.
\]
In particular, if the $\text{cf}_{z}$ expansion of $x$ has at least two terms, then
\[  [a_{1}, a_{2}, a_{3}, \ldots]_{z} = \frac{z}{x - a_{0}}.
\]
Moreover, if $ x = [a_{0}, a_{1}, a_{2}, \ldots, a_{n - 1}, y]_{z}$ for some real $y \geq 1$ and $y = [b_{0}, b_{1}, \ldots ]_{z}$, with $b_{0} \geq 1$ then
\[ x = [a_{0}, a_{1}, a_{2}, \ldots, a_{n - 1}, b_{0}, b_{1}, \ldots]_{z},
\]
an infinite version of formula \eqref{rationalFunctions1}.
\end{corollary}

There are uniqueness considerations with such expansions since there may be several possible choices for $a_{n}$ satisfying $x_{n} - z \leq a_{n} \leq x_{n}$.  One canonical choice is $a_{n} = \lfloor x_{n} \rfloor$, the largest possible choice for $a_{n}$.  We call $a_{n}$ the \textit{maximal choice} if $a_{n} = \lfloor x_{n} \rfloor$.  The expansion in which the maximal choice is always made is called the \textit{maximal expansion}.  We note that when some $a_{n} =  \lfloor x_{n} \rfloor$, the resulting $x_{n + 1}$, should it exist, is as large as possible.  In particular, in this case, $x_{n + 1} > z$.  The other extreme is to select $a_{n} = \max(1, \lceil x_{n} - z \rceil)$.  If we do this for all $n$, the resulting expansion is called the \textit{minimal expansion}.  There are significant differences between the case where $z$ is an integer and where it is not.  For example, Lemma 1.7 in the paper by Anselm and Weintraub \cite{AW11} is problematic when $z$ is not an integer.

\begin{lemma} 
\label{maximalExpansions}
Let $z > 1$ and suppose that $x$ is not an integer.
\begin{itemize}
\item[(a)] The maximal $\text{cf}_{z}$ expansion of $x$ will have the form  $x = [a_{0}, a_{1}, a_{2}, \ldots ]_{z}$, where for $i \geq 1, \; a_{i} \geq \lfloor z \rfloor$,  and if the expansion terminates with last term $a_{n}$, then $a_{n} > z$.
\item[(b)]  Let $x = [a_{0}, a_{1}, a_{2}, \ldots ]_{z}$, and suppose that $a_{i} \geq \lceil z \rceil$, for all $i \geq 1$ and if the expansion terminates with $a_{n}$, then $a_{n} > z$.  Then this expansion coincides with the maximal expansion.
\end{itemize}
\end{lemma}

\begin{proof}
For the first part, as mentioned above, if  $a_{k - 1} =  \lfloor x_{k - 1} \rfloor$, then $x_{k}$, should it exist, satisfies $x_{k} > z$, so $a_{k} = \lfloor x_{k} \rfloor \geq \lfloor z \rfloor$.  If the expansion terminates, then $x_{n}$ is an integer so $a_{n} = x_{n} > z$.

For the second part, if the expansion terminates with $a_{n} > z$ then $x_{n} = a_{n} > z$ as well.  Thus, $\displaystyle x_{n} = \frac{z}{x_{n - 1} - a_{n - 1}} > z$ implies that $a_{n - 1} = \lfloor x_{n - 1} \rfloor$.  Whenever $a_{k}$ is not the last term in the expansion, $x_{k} > a_{k} \geq \lceil z \rceil $, and again $x_{k} > z$, implying that $a_{k - 1} = \lfloor x_{k - 1}\rfloor$.  This shows that for all $i \geq 0$ for which $x_{i}$ exists, $a_{i} = \lfloor x_{i} \rfloor$, and the expansion is given by the max algorithm.
\end{proof}

When $z$ is an integer, the two conditions in Lemma \ref{maximalExpansions} coincide and we have the characterization of the maximal expansion given by Anselm and Weintraub \cite{AW11}.  However, when $z$ is not an integer, these two conditions are different, so Lemma \ref{maximalExpansions} fails to give a characterization in this case. The following examples show that neither condition characterizes a maximal expansion.  Letting $ z = \frac{3}{2}$, first take $ x = [1, 1, 3]_{z} = \frac{23}{11}$.  Then the $a_{i}$ satisfy the conditions of the first part of Lemma \ref{maximalExpansions} but the maximal expansion of $ \frac{23}{11}$ is $[2, 16, 3]_{z}$.  Next, if $\displaystyle x = \frac{1 + \sqrt{7}}{2}$ then the max algorithm gives $x = [1, 1, 1, \ldots ]_{z}$, showing that the conditions in the second part of the lemma are not necessary.  Both of these examples can be generalized.  If $z$ is not an integer, then consider $x = [a, a, k]_{z}$, where $a = \lfloor z \rfloor$.  We have
\[  x = a + \frac{z}{a + \frac{z}{k}}.
\]
If we select $k$ large enough that $a + \frac{z}{k} < z$ then the maximal choice for $a_{0}$ is $a + 1$ instead of $a$.  If we select $x = [a, a, a, \ldots]_{z} = \frac{a + \sqrt{a^{2} + 4z}}{2}$, then it is not hard to show that $x = x_{n}$ for all $n$ and that $\lfloor x \rfloor = a$.  That is, $ [a, a, a, \ldots]_{z}$ will be the maximal expansion of $x$ even though this expansion does not satisfy part (b) of the lemma. Call the maximal expansion of $x$ a \textit{proper maximal expansion} if the expansion satisfies part (b) of Lemma 3.5.  That is, $x$ has a proper maximal expansion if $a_{i} \geq \lceil z \rceil$ for all $i \geq 1$, and in the case where the expansion terminates with $a_{n}$, that $a_{n} > z$.

We have the following weak condition.

\begin{lemma} 
Given a sequence $\{a_{n} \}$, with associated numerators and denominators $p_{n}$ and $q_{n}$ as in Theorem \ref{T: rec}, then $a_{n} > z$ for all $n \geq 1$ if and only if for each $n \geq 0$ the maximal expansion of  $\frac{p_{n}}{q_{n}}$ is $[a_{0}, a_{1}, \ldots, a_{n}]_{z}$.
\end{lemma}

\begin{proof}
Lemma 3.5(a) gives the necessity of the condition.  For sufficiency, we have
\begin{align*}
\frac{p_{n}}{q_{n}} &= [a_{0}, a_{1}, \ldots, a_{n}]_{z} \\
&= [a_{0}, a_{1}, \ldots, a_{n - 1} + z/a_{n}]_{z}.
\end{align*}
If $a_{n} \leq z$ then the maximal choice for the $(n - 1)$'st quotient will be larger than $a_{n - 1}$.  The result now follows by induction.
\end{proof}

We also have the following obvious result.

\begin{lemma} 
Suppose the maximal expansion of $x$ is $[a_{0}, a_{1}, a_{2}, \ldots]_{z}$.  Then for each $n$, the maximal expansion of $x_{n}$ is $[a_{n}, a_{n + 1}, a_{n + 2}, \ldots]_{z}$.
\end{lemma}

We now address the uniqueness of $\text{cf}_{z}$ expansions.

\begin{theorem} 
Let $x$ be a positive real number.
\begin{itemize}
\item[(a)]
If $0 < z < 1$ and $x = [a_{0}, a_{1}, a_{2}, \ldots ]_{z}$ then this expression is unique.
\item[(b)]
If $z = 1$ then $x$ has a unique $\text{cf}_{z}$ expansion if it is irrational and exactly two expansions if it is rational.
\item[(c)]
If $z \geq 2$ then every positive real number $x$ has infinitely many $\text{cf}_{z}$ expansions.
\end{itemize}
\end{theorem}

\begin{proof}
Case (b) is well-known \cite{HW79, wL77, cO63, oP13}.  For (a), let $z < 1$ and suppose that $x = [a_{0}, a_{1}, a_{2}, \ldots ]_{z}$.  We show that each $a_{k}$ is uniquely determined.  Since $\displaystyle a_{0} < x \leq a_{0} + \frac{z}{a_{1}}$, we have $\displaystyle 0 \leq  x - a_{0} \leq \frac{z}{a_{1}} < 1$.  Thus $a_{0} = \lfloor x \rfloor$, so $a_{0}$ is unique.  By  Corollary \ref{xnpart}, $\displaystyle \frac{z}{x - a_{0}} = [a_{1}, a_{2}, a_{3}, \ldots]_{z}$, and the argument just given inducts to show that all $a_{k}$ are uniquely determined.

For (c), suppose that $z \geq 2$ and $x > 0$.  If $x = m$, an integer, we may write $x = [m - 1, z]_{z}$, and find the $\text{cf}_{z}$ expansion of $z$ with the max-algorithm.  More generally, if the maximal expansion of $x$ is  $[a_{0}, a_{1}, \ldots, a_{n}]_{z}$, then by Lemma 3.5, $a_{n} > z \geq 2$.  Thus, we may write $x = [a_{0}, a_{1}, \ldots, a_{n} - 1, z]_{z}$, and again expand $z$.  If the expansion of $z$ terminates, we may iterate on the last partial quotient, allowing for infinitely many expansions of $x$.  Thus, replacing $x$ by some $x_{k}$, if necessary, we are reduced to the case where the maximal expansion for $x$ does not terminate, $x = [a_{0}, a_{1}, a_{2}, \ldots]_{z}$, and $a_{k} \geq \lfloor z \rfloor \geq 2$ for all $k \geq 1$.  Consequently, for any $n \geq 1$, we may write $x =  [a_{0}, a_{1},  \ldots, a_{n - 1}, x_{n}]_{z}$, with $x_{n} > 2$.  We can derive from this that $x = [a_{0}, a_{1}, \ldots, a_{n - 1}, m, x_{n + 1}]_{z}$, where $\displaystyle x_{n + 1} = \frac{z}{x_{n} - m}$, and $m$ is any integer for which $x_{n + 1} > 1$.  That is, we need $m$ to satisfy $0 < x_{n} - m < z$.  The obvious choice, $m = \lfloor x_{n} \rfloor$ gave rise to $a_{n}$ in the expansion for $x$ but we may also use $m = a_{n} - 1$ owing to the fact that $z \geq 2$. Hence,  $x = [a_{0}, a_{1}, \ldots, a_{n - 1}, a_{n} - 1, y]_{z}$, with $\displaystyle y = \frac{z}{x_{n} - a_{n} + 1} > 1$, and we may obtain another expansion for $x$ by expanding $y$.  Since the choice of $n$ was arbitrary, this leads to infinitely many $\text{cf}_{z}$ expansions.
\end{proof}

The authors do not know what happens with $1 < z < 2$.  Perhaps the ergodic approaches employed in \cite{DKL15, DKW13} can clarify the situation.  It appears that most $x$ (in some measure-theoretic sense) have infinitely many expansions.  Evidence for this is given in the following result.

\begin{theorem} 
Let $1 < z < 2$.
\begin{itemize}
\item[(a)]
Every $x > 0$ has an infinite $\text{cf}_{z}$ expansion.
\item[(b)]
A real number $x = [a_{0}, a_{1}, a_{2}, \ldots]_{z}$ has a unique $\text{cf}_{z}$ expansion if and only if the expansion is infinite, $x - \lfloor x \rfloor > z - 1$ and $x_{n} < \frac{z}{z - 1}$ for all complete quotients $x_{n}$ with $n \geq 1$.
\end{itemize}
\end{theorem}

\begin{proof}
Suppose that $x$ has a finite maximal expansion $[a_{0}, a_{1}, \ldots, a_{n}]_{z}$.  Since $z > 1, \; a_{n} \geq 2$ so we may write $x = [a_{0}, a_{1}, \ldots, a_{n} - 1, z]_{z}$ and expand $z$ (by the max algorithm) to produce a longer expression.  If $z$ has an infinite $\text{cf}_{z}$ expansion we are done.  Otherwise, we iterate.

For the second part, suppose that the $\text{cf}_{z}$ expansion of $x$ is unique.  By part (a), this expansion must be infinite.  Moreover, if we write $x = [a_{0}, a_{1}, \ldots, a_{n - 1}, x_{n}]_{z}$, then we must select $a_{n} = \lfloor x_{n} \rfloor$.  Since we are free to let $a_{n}$ be any positive integer with $x_{n} - z \leq a_{n} \leq x_{n}$, this means that $\lfloor x_{n} \rfloor - 1 > x_{n} - z$, or $x_{n} - a_{n} > z - 1$.  When $n = 0$, this says $x - \lfloor x \rfloor < z - 1$.  Given $x_{n} - a_{n} > z - 1$, we have $x_{n + 1} < \frac{z}{z - 1}$.  Conversely, if $x$ has more than just the max expansion then for some $n$, the $n$'th partial quotient need not be $\lfloor x_{n} \rfloor$.  In this case, $x_{n} - z \leq \lfloor x_{n} \rfloor - 1$, giving $x_{n+1} \geq \frac{x}{z - 1}$.
\end{proof}

\begin{corollary} 
If $1 < z < 2$ and $x$ has a unique $\text{cf}_{z}$ expansion $x = [a_{0}, a_{1}, \ldots]_{z}$, then the expansion is infinite and $a_{n} \leq \frac{z}{z - 1}$ for all $n \geq 1$.
\end{corollary}

This gives a necessary, but not a sufficient condition.  For example, $3 = [2, 1, 2, 1, \ldots]_{z}$ when $z = \frac{3}{2}$.  In this case, $\frac{z}{z - 1} = 3$, and $a_{n} < 3$ for all $n$.

We conclude this section by addressing the question of when a real number $x$ has a periodic $\text{cf}_{z}$ expansion.  We use the standard notation
\[  \overline{a_{1}, a_{2}, \ldots, a_{n}}
\]
to denote a sequence with periodic part $a_{1}, \ldots, a_{n}$.  For example,
\[  \frac{3}{2} = [1, 3]_{z} = [1, 2, 1, 3]_{z} = [1, \underbrace{2, 1, 2, 1, \ldots, 2, 1}_{k}, 3]_{z} = [\overline{1, 2}]_{z},
\]
when $z = \frac{3}{2}$. We also note the following maximal expansions.

\begin{align}
\frac{7}{4} &= [\, \overline{1} \,]_{21/16}, \label{maximalExpansions_7_4_21_16} \\
\sqrt{2} &= [1, \overline{3, 2} \,]_{3/2}, \label{maximalExpansions_sqrt2_3_2} \\
\frac{3}{2} &= [1, 2, 1, 2]_{\sqrt{2}}, & \text{ a finite expansion, } \label{maximalExpansions_3_2_sqrt2} \\
\frac{7}{6} &= [1, 8, 2, 1, 2, 2, \overline{3} \,]_{\sqrt{2}}, \label{maximalExpansions_7_6_sqrt2} \\
2\sqrt{2} &= [2, 1, 2]_{\sqrt{2}}, & \text{ a finite expansion, } \label{maximalExpansions_2sqrt2_sqrt2} \\
\sqrt{2} &= [1, \overline{3} \,]_{\sqrt{2}}, \label{maximalExpansions_sqrt2_sqrt2} \\
\sqrt{3} &= [1, \overline{1, 1, 2} \,]_{\sqrt{2}}, \label{maximalExpansions_sqrt3_sqrt2} \\
\sqrt{2} &= [1, 4, 9, 3, 8, 3, 14, \ldots]_{\sqrt{3}}, & \text{ an aperiodic expansion? } \label{maximalExpansions_sqrt2_sqrt3} \\
\sqrt{\pi + 4} &= [2, \overline{4} \,]_{\pi}. \label{maximalExpansions_sqrtpiplus4_pi}
\end{align}

With regard to formulas \eqref{maximalExpansions_3_2_sqrt2} and \eqref{maximalExpansions_7_6_sqrt2}, when checking all rational numbers $1 < x < 2$ with denominator less than 500, we found that most of them, about 75\%, had finite expansions when $z = \sqrt{2}$, and the rest had periodic expansions with period 1 or 6.  Those with period 1 always had some $x_{k} = 2 + \sqrt{2}$, and associated periodic part $\overline{3}$.  When $z = \sqrt{3}$, most rationals we checked had periodic expansions (about 81\%) with periods of length 2, 8, 12 or 72, and the rest had finite expansions. When $z = \sqrt{7}$, only $\frac{45}{43}$ appears to have a finite expansion (of length four). Moreover, based upon the first 500 terms, it appears that no other fraction in this range has a finite expansion, or even a periodic one.

Formulas \eqref{maximalExpansions_2sqrt2_sqrt2} and \eqref{maximalExpansions_sqrt2_sqrt2} show that $x$ and $2x$ can have very different expansions, while formulas \eqref{maximalExpansions_sqrt3_sqrt2} and \eqref{maximalExpansions_sqrt2_sqrt3} show that there is no relationship when $x$ and $z$ are interchanged.

By formula \eqref{pnqnEqualities4} every finite $\text{cf}_{z}$ expansion represents a number in $\mathbb{Z}(z)$, the ring of rational expressions in $z$ with integer coefficients.  Thus, all reals not belonging to $\mathbb{Z}(z)$ must have infinite $\text{cf}_{z}$ expansions.  Reals with periodic expansions must satisfy a quadratic equation.

\begin{theorem}\label{T: periodic} 
If $x$ has the $\text{cf}_{z}$ expansion
\[ [a_{0}, a_{1}, \ldots, a_{j - 1}, \overline{a_{j}, \ldots, a_{j + k - 1}} \,]_{z}
\]
then $x$ satisfies the quadratic equation
\begin{equation}
q_{k - 1}x^{2} + (zq_{k - 2} - p_{k - 1})x - zp_{k - 2} = 0 \label{periodicQuadraticj0}
\end{equation}
when $j = 0$,
\begin{equation}
q_{k - 1}x^{2} + (q_{k} - a_{0}q_{k - 1} - p_{k - 1})x  - (p_{k} - a_{0}p_{k - 1}) = 0 \label{periodicQuadraticj1}
\end{equation}
when $j = 1$, and
\begin{align}
x^{2}&(q_{j + k - 1}q_{j - 2} - q_{j + k - 2}q_{j - 1}) \label{periodicQuadraticjge2} \\
 &- x(p_{j + k - 1}q_{j - 2} + p_{j - 2}q_{j + k - 1} - p_{j + k - 2}q_{j - 1} - p_{j - 1}q_{j + k - 2}) \notag \\ 
 & \quad + p_{j + k - 1}p_{j - 2} - p_{j + k - 2}p_{j - 1} = 0 \notag
\end{align}
for $j \geq 2$.
\end{theorem}

If we define $p_{-2} = 0, \; q_{-2} = \frac{1}{z}$   then formulas \eqref{periodicQuadraticj0} and \eqref{periodicQuadraticj1} are special cases of \eqref{periodicQuadraticjge2} but it is convenient to have all three forms.
\begin{proof}  We only show that formula \eqref{periodicQuadraticjge2} holds.  If 
\[ x = [a_{0}, a_{1}, \ldots, a_{j - 1}, \overline{a_{j}, \ldots, a_{j + k - 1}} \,]_{z}
\]
then
\begin{align*}
x &= [a_{0}, a_{1}, \ldots, a_{j - 1}, x_{j}]_{z} \\
&= [a_{0}, a_{1}, \ldots, a_{j - 1}, a_{j}, \ldots, a_{j + k - 1}, x_{j}]_{z}.
\end{align*}
By Theorem \ref{pnqnidentities},
\[  x = \frac{p_{j - 1}x_{j} + zp_{j - 2}}{q_{j - 1}x_{j} + zq_{j - 2}}, \qquad x = \frac{p_{j + k - 1}x_{j} + zp_{j + k - 2}}{q_{j + k - 1}x_{j} + zq_{j + k - 2}},
\]
or
\[  x_{j} = -z\frac{p_{j - 2} - xq_{j - 2}}{p_{j - 1} - xq_{j - 1}} = -z\frac{p_{j  + k - 2} - xq_{j + k - 2}}{p_{j + k - 1} - xq_{j + k - 1}},
\]
from which the result follows.
\end{proof}
The discriminant of the quadratic in \eqref{periodicQuadraticj0} is $(zq_{k - 2} - p_{k - 1})^{2} + 4p_{k - 2}q_{k - 1} = (zq_{k - 2} + p_{k - 1})^{2} + 4(-1)^{n}z^{n}$, by formula \eqref{pnqnEqualities1}.  So if $x$ has a purely periodic expansion $[\overline{a_{0}, \ldots, a_{n - 1}} \, ]_{z}$, then
\begin{equation}
x = \frac{p_{k - 1} - zq_{k - 2} + \sqrt{(zq_{k - 2} + p_{k - 1})^{2} + 4(-1)^{n}z^{n}}}{2q_{k - 1}}. \label{purelyPeriodicQuadraticEquation}
\end{equation}

Theorem \ref{T: periodic} has the following converse.
\begin{theorem} 
\label{repeatingPeriodicPart}
If $a_{1}, \ldots, a_{j+k-1}$ are positive integers and there is an $x = [a_{0}, \ldots, a_{j + k - 1}, \ldots]_{z}$ which satisfies formula \eqref{periodicQuadraticjge2} then $x$ has the $\text{cf}_{z}$ expansion
\[ [a_{0}, a_{1}, \ldots, a_{j - 1}, \overline{a_{j}, \ldots, a_{j + k - 1}} \,]_{z}.
\]
If $a_{m} \geq z$ for $1 \leq m \leq j + k - 1$ then the expansion is a maximal $\text{cf}_{z}$ expansion.
\end{theorem}

\begin{proof}
By Theorem \ref{pnqnidentities},
\[  x_{j} = -z\frac{p_{j - 2} - xq_{j - 2}}{p_{j - 1} - xq_{j - 1}} \quad \text{and} \quad x_{j + k} = -z\frac{p_{j  + k - 2} - xq_{j + k - 2}}{p_{j + k - 1} - xq_{j + k - 1}}.
\]
Since $x$ satisfies formula \eqref{periodicQuadraticjge2}, $x_{j} - x_{j + k} = 0$, so $x$ is periodic, with the given expansion.  If $a_{m} \geq z$ for all $m \geq 1$ then by Lemma 3.5, the maximal expansion of $x$ has the desired form.
\end{proof}

We have the following easy consequences of Theorem \ref{T: periodic}.
\begin{corollary} 
\label{periodicRationalExpressionElement}
In order for a positive real number $x$ to have a periodic $\text{cf}_{z}$ expansion, $x$ must be an element of $\mathbb{Z}(\sqrt{f(z)})$, the set of rational expressions in $\sqrt{f(z)}$, where $f(z)$ is a rational function of $z$ with integer coefficients.
\end{corollary}

\begin{corollary} 
\label{PurePeriodOneTwo}
If $x$ is a positive real number then
\begin{itemize}
\item[(a)]  
$x$ has purely periodic expansion $[\, \overline{a} \,]_{z}$ if and only if $\displaystyle x = \frac{a + \sqrt{a^{2} + 4z}}{2}$.  This is the maximal expansion for $x$ provided $z < a + 1$.
\item[(b)]  $x$ has purely periodic expansion $[\, \overline{a, b} \,]_{z}$ if and only if $\displaystyle x = \frac{ab + \sqrt{a^{2}b^{2} + 4abz}}{2b}$.  This is the maximal expansion for $x$ provided $z < \min(a + \frac{a}{b}, b + \frac{b}{a})$.
\end{itemize}
\end{corollary}

\begin{proof}
The first part follows from the second.  If $x = [\overline{a, b} \,]_{z}$, then by \eqref{purelyPeriodicQuadraticEquation}, $x = \frac{ab + \sqrt{a^{2}b^{2} + 4abz}}{2b}$. On the other hand, given such an $x$, we have $ x_{1} = \frac{z}{x - a} = \frac{ab + \sqrt{a^{2}b^{2} + 4abz}}{2a}$ and $x_{2} = \frac{z}{x_{1} - b} = x$ so $x$ has the desired periodic expansion.  Moreover, $\lfloor x \rfloor = a$ if and only if $z < a + \frac{a}{b}$, and $\lfloor x_{1} \rfloor = b$ if and only if $z < b + \frac{b}{a}$, demonstrating the maximal expansion property.
\end{proof}

For example, if $a = 1$ in part (a) and $z = \frac{10}{9}$ then $1 + 4z = \frac{49}{9}$ so $x = \frac{5}{3}$ will have maximal expansion $[\, \overline{1} \,]_{z}$.  If $a = 2, b = 3, z = \frac{3}{2}$, then $x = 1 + \sqrt{2}$ in part (b), essentially giving expansion \eqref{maximalExpansions_sqrt2_3_2}.  Formulas \eqref{maximalExpansions_7_4_21_16}, \eqref{maximalExpansions_sqrt2_sqrt2} and \eqref{maximalExpansions_sqrtpiplus4_pi} are also essentially examples of Corollary~ \ref{PurePeriodOneTwo}.

\section{Expansions with rational \texorpdfstring{$z$}{z}} 

In this section, we focus on the case were $z$ is rational, say $z = \frac{u}{v}$ where $u$ and $v$ are positive relatively prime integers with $u > v$.  With $\displaystyle C_{n} = \frac{p_{n}}{q_{n}}$, as noted in Section 3, $p_{n}$ and $q_{n}$ will not, in general, be integers.  When $z$ is rational, we can scale $p_{n}$ and $q_{n}$ to obtain an integer numerator and denominator for $C_{n}$, but at the cost of more complicated recurrences.  In place of Theorem \ref{T: rec} we have the following.

\begin{theorem}\label{T: intseq}
Given a sequence of integers $\{ a_{n} \}$ with $a_{k} \geq 1$ for $k \geq 1$ define sequences $\{ P_{n} \}$ and $\{ Q_{n} \}$ inductively as follows:
\begin{align}
P_{-1} = 1, \qquad P_{0} = a_{0}, \qquad P_{n} = \begin{cases}
			a_{n}P_{n - 1} + uP_{n - 2}, & \text{ if $n$ is even;} \\
			va_{n}P_{n - 1} + uP_{n - 2}, & \text{ if $n$ is odd,}
		\end{cases} \label{rationalPnSequence} \\
Q_{-1} = 0, \qquad Q_{0} = 1, \qquad Q_{n} =  \begin{cases}
			a_{n}Q_{n - 1} + uQ_{n - 2}, & \text{ if $n$ is even;} \\
			va_{n}Q_{n - 1} + uQ_{n - 2}, & \text{ if $n$ is odd.}
		\end{cases} \label{rationalQnSequence}
\end{align}
If $\displaystyle C_{n} =\frac{P_{n}}{Q_{n}}$ then for each $n \geq 0$,
\[  C_{n} = [a_{0}, a_{1}, \ldots, a_{n}]_{z}.
\]
\end{theorem}

Other relevant results from Section 2 translate as follows.

\begin{theorem}
With $\{ a_{n} \}, \; \{ P_{n} \}, \; \{ Q_{n} \}$, defined as in Theorem \ref{T: intseq}, we have
\begin{align}
P_{n}Q_{n - 1} &- P_{n - 1}Q_{n} = (-1)^{n - 1}u^{n}, \\
P_{n}Q_{n - 2} &- P_{n - 2}Q_{n} = \begin{cases} (-1)^{n}u^{n - 1}, & \text{ if $n$ is even;} \\
                                                                             v(-1)^{n}u^{n - 1}, & \text{ if $n$ is odd,}
                                                      \end{cases} \\
x &=  \begin{cases}
			\frac{P_{n - 1}x_{n} + uP_{n - 2}}{Q_{n - 1}x_{n} + uQ_{n - 2}}, & \text{ if $n$ is even;} \\
			\frac{vP_{n - 1}x_{n} + uP_{n - 2}}{vQ_{n - 1}x_{n} + uQ_{n - 2}}, & \text{ if $n$ is odd,}
		\end{cases} \\
& v \mid Q_{2n - 1} \qquad \text{for all $n$,} \label{pnqnVDivides} \\
& \gcd(P_{n}, Q_{n}) \mid u^{n}  \quad \text{for all $n$.}
\end{align}
\end{theorem}

An easy induction gives the following relationship between $P_{n}, Q_{n}$ and $p_{n}, q_{n}$.

\begin{lemma} 
\label{pnqnvPowerCeiling}
For all $n \geq 0$,
\[  P_{n} = v^{\lceil n/2 \rceil}p_{n}, \qquad Q_{n} = v^{\lceil n/2 \rceil}q_{n}.
\]
\end{lemma}

With regard to periodic expansions, we may replace $p_{n}$ and $q_{n}$ with $P_{n}$ and $Q_{n}$ as well.

\begin{theorem}
\label{IntpqPeriodic}
Let $z = \frac{u}{v}$ be a positive rational number in lowest terms.  If positive real number $x$ has a purely periodic expansion
\[ x = [\, \overline{a_{0}, \ldots, a_{n - 1}} \,]_{z}
\]
then $x$ must satisfy the quadratic equation
\[ Q_{n - 1}x^{2} + (uQ_{n - 2} - P_{n - 1})x - uP_{n - 2} = 0
\]
if $n$ is even and
\[ vQ_{n - 1}x^{2} + (uQ_{n - 2} - vP_{n - 1})x - uP_{n - 2} = 0
\]
when $n$ is odd.
If $x$ is rational then $(uQ_{n - 2} + P_{n - 1})^{2} - 4u^{n}$ must be a perfect square in $n$ is even, $(uQ_{n - 2} + vP_{n - 1})^{2} + 4vu^{n}$ must be a perfect square if $n$ is odd.
\end{theorem}

Odd period lengths are rare in our calculations.  Here is one reason for this.

\begin{theorem}
\label{rationalZOddPeriodVSquare}
Let $z = \frac{u}{v}$ be a positive rational number in lowest terms.  If $x$ is a rational number with a periodic $\text{cf}_{z}$ expansion of odd length, then $v$ is a square.
\end{theorem}

\begin{proof}
If $x$ is not purely periodic, we may replace $x$ with a complete quotient $x_{k}$, which is purely periodic, so we may assume that $x$ has a purely periodic expansion.  As noted in formula \eqref{pnqnVDivides}, all $Q_{n}$ of odd index are divisible by $v$. Since $n$ is odd we may write $Q_{n - 2} = kv$ for some integer $k$.  By the previous theorem,
\begin{equation} (uQ_{n - 2} + vP_{n - 1})^{2} + 4vu^{n} = v^{2}(ku + P_{n - 1})^{2} + 4vu^{n} \label{oddPeriodSquareRelation}
\end{equation}
is a square.  Every positive integer can be written as a square times a square free part, so suppose $v = s^{2}t$ for some integers $s$ and $t$, where $t$ is square free.  Using \eqref{oddPeriodSquareRelation} we have $s^{2}(A^{2}t^{2} + 4tu^{n}) = m^{2}$ for some integers $A$ and $m$.  If $p$ is an odd prime dividing $t$ then $p^{2}$ will divide $m^{2}/s^{2}$ forcing $p^{2}$ to also divide $4tu^{n}$.  Since $t$ is prime to $u$ it must be that $p^{2}$ divides $t$, a contradiction.  Thus, at worst, $t = 2$.  In this case, $m$ is even and we may divide by $4$ to obtain $A^{2} + 2u^{n} = \left(\frac{m}{2s}\right)^{2}$.  Thus, $2u^{n}$ is even and the difference of two squares, forcing it to be divisible by 4.  As a consequence, $u$ is even, a contradiction since $u$ is prime to $v$.  Since $t$ is not divisible by any prime, $v = s^{2}$, as desired.
\end{proof}

Using Theorem \ref{rationalZOddPeriodVSquare} we may classify the $x$ and $z$ for which $x$ has a purely periodic expansion of period 1.

\begin{theorem}
\label{singleLengthPeriodClassification}
If $x$ and $z$ are rational, then $x = [\, \overline{n} \,]_{z}$ if and only if
\[  x = \frac{nw + k}{w}, \qquad z = \frac{k(nw + k)}{w^{2}},
\]
where $w, k, n$ are positive integers and $k$ is prime to $w$.  The expansion is maximal when $1 \leq k < w$.
\end{theorem}

\begin{proof}
If $x_{0} = x = \frac{nw + k}{w}$ and $z = \frac{k(nw + k)}{w^{2}}$, then a simple calculation with $a_{0} = n$ shows $x_{1} = x_{0}$, allowing for a periodic expansion.  In order for the expansion to be maximal, we need $\lfloor x \rfloor = n$, which requires $1 \leq k < w$.

Next, suppose that $x = [\, \overline{n} \,]_{z}$, where $x$ and $z$ are rational.  By Theorem \ref{rationalZOddPeriodVSquare} we may write $z = \frac{u}{w^{2}}$ for some positive integers $u$ and $w$.  By Theorem \ref{IntpqPeriodic} we have
\[  x = \frac{n + \sqrt{n^{2} + 4z}}{2} = \frac{nw + \sqrt{n^{2}w^{2} + 4u}}{2w}.
\]
For $x$ to be rational, it must be that $\sqrt{n^{2}w^{2} + 4u}$ is an integer.  Since it is larger than $nw$ we may write $\sqrt{n^{2}w^{2} + 4u} = nw + m$ for some integer $m$.  Squaring shows $m$ must be even, so let $m = 2k$.  Again squaring and simplifying gives $u = k(nw + k)$, giving $x$ and $z$ their desired forms.
\end{proof}

Formula \eqref{maximalExpansions_7_4_21_16}, a special case of Theorem \ref{singleLengthPeriodClassification}, shows that a rational number can have an infinite maximal $\text{cf}_{z}$ expansion even when $z$ is rational.  This contrasts with a result from Anselm and Weintraub \cite[Lemma 1.9]{AW11}, that when $z$ is an integer, the maximal $\text{cf}_{z}$ expansion of any positive rational number is finite.  However, we do have the following conjectures.

\begin{conjecture}
\label{3halvesFiniteConjecture}
If $z = \frac{3}{2}$ then every positive rational number has a finite $\text{cf}_{z}$ expansion.
\end{conjecture}

\begin{conjecture}
\label{5thirdsFinitePeriodicConjecture}
If $z = \frac{5}{3}$ then every positive rational number has either a finite $\text{cf}_{z}$ expansion or a periodic $\text{cf}_{z}$ expansion.
\end{conjecture}

We have tested Conjecture \ref{3halvesFiniteConjecture} on all rational numbers with denominator less than 1000.  There are other $z$ besides $\frac{3}{2}$ that appear to have this property.  In \cite{jS15} a list of 146 rational $z$ are given for which it appears that all positive rationals have a finite maximal $\text{cf}_{z}$ expansion.

For Conjecture \ref{5thirdsFinitePeriodicConjecture}, again, there are other $z$ besides $\frac{5}{3}$ that appear to have the given property.  In contrast, we have the following.

\begin{conjecture}
\label{11eigthsConjecture}
For $z = \frac{11}{8}$ the maximal $\text{cf}_{z}$ expansion of $\frac{4}{5}$ is neither finite nor periodic.
\end{conjecture}

Using Floyd's cycle finding algorithm \cite[p. 7, Exercise 6]{dK69}, we checked the expansion of $\frac{4}{5}$ through 1,000,000 partial quotients without it terminating or becoming periodic.  Here, $\frac{11}{8}$ appears to be the smallest rational $z$-value having this property.  That is, if $1 < z < 2, \; z = \frac{u}{v}$ and $u + v < 19$ then all rational numbers appear to have either finite or periodic maximal $\text{cf}_{z}$ expansions.  Also, nearly half of the rational $x$ we tried appeared to have aperiodic expansions with $z = \frac{11}{8}$.

Acting against Conjecture \ref{11eigthsConjecture} is that some rational numbers can have very long finite $\text{cf}_{z}$ expansions.  An example is $x = \frac{2369}{907}$, which has a maximal $\text{cf}_{z}$ expansion of length 37,132 when $z = \frac{11}{7}$.

\section{Periodic expansions and reduced quadratic surds}

In the theory of periodic continued fractions, both for simple continued fractions and in the work of Anselm and Weintraub \cite{AW11}, the notion of a quadratic irrational being \textit{reduced} is important.  The appropriate definition in \cite{AW11} is the following:  A quadratic irrational $x$ is $N$-reduced if $x > N$ and $-1 < \overline{x} < 0$, where $\overline{x}$ is the Galois conjugate of $x$.  For simple continued fractions, ``quadratic irrational" is essentially synonymous with ``periodic."  For the more general setting in \cite{AW11}, being a quadratic irrational was a necessary condition for periodicity.  This is not the case for general $z$ so to extend the idea of being reduced to the general $z$-setting, one must modify the definition of a conjugate.  Intuitively, if $x$ has a periodic expansion, then $x$ must satisfy a quadratic equation derived from the periodic expansion and we define its conjugate to be the other solution to that equation.

To be more rigorous, suppose that $x$ is a positive real number with periodic maximal $\text{cf}_{z}$ expansion of period length $k$ and tail length $j$ so
\[ x = [a_{0}, a_{1}, \ldots, a_{j - 1}, \overline{a_{j}, \ldots, a_{j + k - 1}} \,]_{z}.
\]
Then $x$ satisfies the quadratic equation in \eqref{periodicQuadraticjge2}.  The other solution to this equation is called the \textit{pseudo-conjugate} of $x$ with respect to $z$ and is denoted $\overline{x}$.  We note that the this conjugate can be written in the form
\begin{equation}
\overline{x} = \frac{p_{j + k - 1}p_{j - 2} - p_{j + k - 2}p_{j - 1}}{x(q_{j + k - 1}q_{j - 2} - q_{j + k - 2}q_{j - 1})}, \label{pseudoConjugateForm}
\end{equation}
and this pseudo-conjugate must equal the usual conjugate of $x$ when $x$ is a quadratic irrational and $z$ is rational.  The pseudo-conjugate map is not an involution, at least when $z$ is not an integer.  For example, if $z = \frac{7}{4}$ and $x = \frac{79}{30} = [2, 2, \overline{2, 5, 1, 2, 9}\,]_{z}$, then $\overline{x} = \frac{2287}{1294} = y$, but $\overline{y} = \frac{11818919047}{6687223982} \neq x$.  The following tool is needed.

\begin{lemma}
Suppose that $x = x_{0} = [a_{0}, a_{1}, \ldots, a_{j - 1}, \overline{a_{j}, \ldots, a_{j + k - 1}} \,]_{z}$ and $x_{1} = \frac{z}{x - a_{0}}$.  Then $x_{1}$ is also periodic and $\overline{x_{1}} = \frac{z}{\overline{x} - a_{0}}$.
\end{lemma}

\begin{proof}
The proof is easier if there is no tail so we will assume that $j \geq 1$.  It is obvious that $x_{1}$ is periodic since (for $j \geq 1$)
\[ x_{1} = [a_{1}, a_{2}, \ldots, a_{j - 1}, \overline{a_{j}, \ldots, a_{j + k - 1}} \,]_{z}.
\]
We use formula \eqref{pseudoConjugateForm} to show that $\overline{x} = a_{0} + \frac{z}{\overline{x_{1}}}$.  Using primes to indicate the variables involved are $a_{1}, a_{2}, \ldots$ rather than $a_{0}, a_{1}, \ldots$, we have
\begin{align*}
 a_{0} + \frac{z}{\overline{x_{1}}} &= a_{0} + \frac{zx_{1}(q'_{j + k - 2}q'_{j - 3} - q'_{j + k - 3}q'_{j - 2})}{p'_{j + k - 2}p'_{j - 3} - p'_{j + k - 3}p'_{j - 2}} \\
 &= a_{0} + \frac{z^{2}(q'_{j + k - 2}q'_{j - 3} - q'_{j + k - 3}q'_{j - 2})}{(x - a_{0})(p'_{j + k - 2}p'_{j - 3} - p'_{j + k - 3}p'_{j - 2})}.
\end{align*}
Using parts (a) and (b) of Theorem \ref{pnqnrelationships},
\begin{align*}
& \frac{z^{2}(q'_{j + k - 2}q'_{j - 3} - q'_{j + k - 3}q'_{j - 2})}{(x - a_{0})(p'_{j + k - 2}p'_{j - 3} - p'_{j + k - 3}p'_{j - 2})} \\&=  \frac{(p_{j+k-1} - a_{0}q_{j+k-1})(p_{j -2} - a_{0}q_{j - 2}) - (p_{j+k-2} - a_{0}q_{j+k-2})(p_{j - 1} - a_{0}q_{j - 1})}{(x - a_{0})(q_{j + k - 1}q_{j - 2} - q_{j + k - 2}q_{j - 1})} \\
 &\qquad = \frac{a_{0}^{2}}{x - a_{0}} + \frac{p_{j + k - 1}p_{j - 2} - p_{j + k - 2}p_{j - 1}}{(x - a_{0})(q_{j + k - 1}q_{j - 2} - q_{j + k - 2}q_{j - 1})} \\
 & \qquad \qquad - \frac{a_{0}}{x - a_{0}}\frac{p_{j + k - 1}q_{j - 2} + p_{j - 2}q_{j  + k - 1} - p_{j + k - 2}q_{j - 1} - p_{j - 1}q_{j  + k - 2}}{q_{j + k - 1}q_{j - 2} - q_{j + k - 2}q_{j - 1}}.
\end{align*}
Now by formula \eqref{periodicQuadraticjge2},
\begin{align*}
p_{j + k - 1}q_{j - 2} &+ p_{j - 2}q_{j  + k - 1} - p_{j + k - 2}q_{j - 1} - p_{j - 1}q_{j  + k - 2} \\
&= x(q_{j + k - 1}q_{j - 2} - q_{j + k - 2}q_{j - 1}) + \frac{1}{x} (p_{j + k - 1}p_{j - 2} - p_{j + k - 2}p_{j - 1}).
\end{align*}
Consequently,
\begin{align*}
a_{0} + \frac{z}{\overline{x_{1}}} &= a_{0} + \frac{a_{0}^{2}}{x - a_{0}} + \frac{p_{j + k - 1}p_{j - 2} - p_{j + k - 2}p_{j - 1}}{(x - a_{0})(q_{j + k - 1}q_{j - 2} - q_{j + k - 2}q_{j - 1})} \\
& - \frac{a_{0}x}{x - a_{0}} - \frac{a_{0}}{x - a_{0}}  \frac{p_{j + k - 1}p_{j - 2} - p_{j + k - 2}p_{j - 1}}{x(q_{j + k - 1}q_{j - 2} - q_{j + k - 2}q_{j - 1})} \\
&= a_{0} + \frac{a_{0}^{2}}{x - a_{0}} + \frac{x}{x - a_{0}} \overline{x} - \frac{a_{0}x}{x - a_{0}} - \frac{a_{0}}{x - a_{0}} \overline{x} \\
&= \overline{x},
\end{align*}
as desired.
\end{proof}

If $x$ has a maximal $\text{cf}_{z}$ expansion which is periodic, we define $x$ to be \textit{reduced} if $x > z$ and $-1 < \overline{x} < 0$.  Unfortunately, being reduced does not have the power it has in the simple continued fraction case.  We say $x$ is \textit{strongly reduced} if, in addition to being reduced, the maximal expansion of $x$ satisfies $a_{i} \geq z$ for all $i \geq 1$.  That is, all partial quotients except possibly the first are at least as large as $z$.  We have the following.

\begin{lemma}
If $x$ is strongly reduced, then so is $x_{1} = \frac{z}{x - a_{0}}$.
\end{lemma}

\begin{proof}
To be strongly reduced, $x$ must be periodic.  Since the partial quotients of $x_{1}$ are just shifted partial quotients of $x, \; x_{1}$ is also periodic.  This also shows that the partial quotients of $x_{1}$ are all sufficiently large.  Since $a_{0} = \lfloor x \rfloor$, it follows that $x_{1} > z$.  By the previous lemma, $\overline{x_{1}} = \frac{z}{\overline{x} - a_{0}}$.  Since $\overline{x}$ is negative and $a_{0} \geq z, \; -1 < \overline{x_{1}} < 0$, showing that $x_{1}$ is reduced. 
\end{proof}

As a consequence of the lemma, if $x$ is strongly reduced, so is $x_{k}$ for every $k$.  The condition that $x$ be strongly reduced is necessary.  For example, $x = \frac{105}{58}$ has maximal expansion $[\, \overline{1, 2, 10} \,]_{z}$ when $z = \frac{7}{4}$.  In this case $x$ satisfies the quadratic equation $348x^{2} - 572x + 105 = (6x + 1)(58x - 105)$.  Thus, $\overline{x} = - \frac{1}{6}$, so $x$ is reduced, but not strongly reduced.  In this case, $x_{1} = \frac{203}{94}$, which satisfies $188x^{2} - 124x - 609 = (2x + 3)(94x - 203)$.  Since $\overline{x_{1}} = - \frac{3}{2}, \; x_{1}$ is not reduced.  It is not important here that $x$ be rational.  For example, $x = [\, \overline{1, 2, 5} \,]_{7/4} = \frac{34}{47} + \frac{11}{94}\sqrt{79}$ has the same property:  $x$ is reduced but $x_{1}$ is not reduced.  However, if $x = \sqrt{3} + 1$ and $z = \frac{11}{5}$ then $x = [\, \overline{2, 3, 418, 3} \,]_{z}$.  Here $x$ is reduced but not strongly reduced.  Nevertheless, all $x_{k}$ are reduced.  Thus, when $x$ is reduced but not strongly reduced, $x_{1}$ may or may not be reduced.  

\begin{theorem}
\label{stronglyReducedPurelyPeriodic}
If $x$ is strongly reduced, then $x$ is purely periodic.  Moreover, $- \frac{z}{\overline{x}}$ is also strongly reduced.
\end{theorem}

\begin{proof}
We proceed by contradiction to show that $x$ must be purely periodic.  So suppose that $x$ is periodic with period $k$, but not purely periodic.  Then for some $j \geq 1, \; x = [a_{0}, a_{1}, \ldots, a_{j - 1}, \overline{a_{j}, \ldots, a_{j + k - 1}} \,]_{z}$, and $a_{j - 1} \neq a_{j + k - 1}$.  By periodicity, $x_{j} = x_{j + k}$, so
\[  \frac{z}{x_{j - 1} - a_{j - 1}} = \frac{z}{x_{j + k - 1} - a_{j + k - 1}}.
\]
Thus,
\[  \frac{z}{\overline{x_{j - 1}} - a_{j - 1}} = \frac{z}{\overline{x_{j + k - 1}} - a_{j + k - 1}},
\]
or $\overline{x_{j - 1}} - a_{j - 1} = \overline{x_{j + k - 1}} - a_{j + k - 1}$.  We write this in the form $a_{j - 1} - a_{j + k - 1} = \overline{x_{j - 1}} - \overline{x_{j + k - 1}}$.  Being reduced, $-1 < \overline{x_{j - 1}} - \overline{x_{j + k - 1}} < 1. $ Since $a_{j - 1} - a_{j + k - 1}$ is an integer, it must be that $a_{j - 1} = a_{j + k - 1}$, a contradiction.

For the second part, we prove that if
\[ x =  [\, \overline{a_{0}, a_{1}, \ldots, a_{k - 1}} \,]_{z}, \quad \text{then} \quad -\frac{z}{\overline{x}} =  [\, \overline{a_{k - 1}, a_{k - 2}, \ldots, a_{0}} \,]_{z}.
\]
We have $x_{j} = \frac{z}{x_{j - 1} - a_{j - 1}}$, which we can rewrite $- \frac{z}{\overline{x_{j}}} = a_{j - 1} - \overline{x_{j - 1}}$.  Since $x_{j}$ is reduced, this shows that for all $j, \; \left \lfloor - \frac{z}{\overline{x_{j}}} \right \rfloor = a_{j - 1}$, with the interpretation that when $j = 0$ the floor is $a_{k - 1}$.  Thus, the maximal expansion of $- \frac{z}{\overline{x}}$ has partial quotients $a_{k - 1}, a_{k - 2}, \ldots, a_{0}, a_{k - 1}, \ldots$.
\end{proof}

The converse of Theorem \ref{stronglyReducedPurelyPeriodic} need not be true, as shown in a previous example.  That is, if $x = \frac{203}{94}$ and $z = \frac{7}{4}$, then the maximal expansion of $x$ is $[\, \overline{2, 10, 1} \,]_{z}$.  Thus, $x$ has a purely periodic maximal expansion.  However, $x$ is neither strongly reduced nor even reduced since $\overline{x} = - \frac{3}{2}$.  Also, in this case, $- \frac{z}{\overline{x}} = \frac{7}{6} = [\, \overline{1, 10, 2} \,]_{z}$, but this is not the maximal expansion of $\frac{7}{6}$.  The maximal expansion is $[1, 10, \overline{3}\,]_{z}$.  Similarly, if $x = [\, \overline{2, 5, 1} \,]_{7/4} = \frac{13}{27} + \frac{11}{54}\sqrt{79}$ then $x$ is purely periodic, $\overline{x} < -1$, and in this case, $- \frac{z}{\overline{x}} = \frac{13}{47} + \frac{11}{94}\sqrt{79}$ does not even appear to be periodic.

If $x$ is reduced but not strongly reduced, one can ask whether the maximal expansion of $x$ still has to be purely periodic.  This will be the case, by the same proof as in Theorem \ref{stronglyReducedPurelyPeriodic}, if all $x_{k}$ are reduced.  However, if any $x_{k} < -1$ then $x$ need not be purely periodic.  For every $z > 1$ which is not an integer, one can construct such $x$.  If we set $a = \lfloor z \rfloor$ and let $y = [\, \overline{a + 1, b, a} \,]_{z}$ then for sufficiently large $b$ and an appropriate $k, \; x = y + k = [a + 1 + k, \overline{b, a, a + 1} \, ]_{z}$ will be reduced but not purely periodic.  To see this, from the quadratic that $y$ satisfies, one can easily calculate that $\overline{y} = - \frac{z}{a} + \mathcal{O}(\frac{1}{b}) < -1 $ for large $b$.  Thus, for sufficiently large $b$, adding $k = \left \lfloor \frac{z}{a} \right \rfloor$ to $y$ gives a reduced $x$ which is not purely periodic.  One should also show that the maximal algorithm of $x$ is as stated.  Since $a + 1$ and $b$ are larger than $z$, this follows if $b = \lfloor [\, \overline{b, a, a + 1} \, ]_{z} \rfloor$, or $[0, a, a + 1, b]_{z} < 1$.  Now
\[  [0, a, a + 1, b]_{z} = \frac{z}{a + \frac{z}{a + 1 + \frac{z}{b}}} = \frac{(a + 1)z + \frac{z^{2}}{b}}{a(a + 1) + \frac{az}{b} + z} < \frac{(a + 1)z + \frac{z^{2}}{b}}{(a + 1)z + \frac{z^{2}}{b} + z} < 1,
\]
as desired.

\section{Periodic expansions for \texorpdfstring{$\sqrt{n}$}{sqrt(n)}}

As shown by Anselm and Weintraub \cite[Theorem 2.2]{AW11}, every quadratic irrational has a periodic $\text{cf}_{z}$ expansion when $z$ is a positive integer.  This follows from the well-known fact that $x$ has a periodic $\text{cf}_{1}$ expansion if and only if $x$ is a quadratic irrational, coupled with formula \eqref{rationalFunctions3} in the form
\begin{equation}
[a_{0}, a_{1}, a_{2}, a_{3}, \ldots]_{1} = [a_{0}, za_{1}, a_{2}, za_{3}, \ldots]_{z}. \label{quadraticIrrationalExpansion}
\end{equation}
However, the right hand side of \eqref{quadraticIrrationalExpansion} is only a maximal expansion when the even terms satisfy $a_{2k} \geq z$ for all $k$.

When $z$ is rational but not an integer, formula \eqref{quadraticIrrationalExpansion} only produces a proper $\text{cf}_{z}$ expansion when $za_{2k+1}$ is an integer for all $k$.  For example, $\sqrt{2} = [1, 2, 2, 2, \ldots]_{1}$ so with $z = \frac{3}{2}$ we have $\sqrt{2} = [1, 3, 2, 3, \ldots]_{z} = [1, \overline{3, 2} \,]_{z}$.  Formula \eqref{quadraticIrrationalExpansion} does not apply if, say,  $z = \frac{4}{3}$ instead.  In this case, $\sqrt{2}$ has maximal expansion $[1, \overline{3, 6, 14, 1, 2, 2} \,]_{z}$.  The algorithm for producing partial quotients matters:  The minimal expansion of $\sqrt{2}$\, does not appear to have a periodic expansion when $z = \frac{4}{3}$.  It seems likely that $\sqrt{8}$ does not have a periodic expansion when $z = \frac{3}{2}$, regardless of the algorithm used to generate the partial quotients.  As Anselm and Weintraub \cite{AW11} mention, although all quadratic irrationals have periodic $\text{cf}_{z}$ expansion for integral $z$, many (most?) do not appear to have periodic maximal $\text{cf}_{z}$ expansions.  For example, $\sqrt{2}$ with $z = 8, \; \sqrt{3}$ with $z = 7$, and $\sqrt{5}$ with $z = 5$ do not become periodic within 10,000 steps of the max algorithm.

When $z$ is rational, and $x = \sqrt{n}$ has a periodic $\text{cf}_{z}$ expansion, the formulas in Theorem \ref{T: periodic} have additional structure.

\begin{lemma}
\label{sqrtNpqStructure}
If $z$ is rational and $\sqrt{n}$ has a periodic $\text{cf}_{z}$ expansion of tail length $j$ and period length $k$ then
\begin{align}
n(q_{j + k - 1}q_{j - 2} - q_{j + k - 2}q_{j - 1}) + p_{j + k - 1}p_{j - 2} - p_{j + k - 2}p_{j - 1} &= 0, \label{sqrtNPeriodicZeroRelation1} \\
p_{j + k - 1}q_{j - 2} + p_{j - 2}q_{j + k - 1} - p_{j + k - 2}q_{j - 1} - p_{j - 1}q_{j + k - 2} &= 0. \label{sqrtNPeriodicZeroRelation2}
\end{align}
In the case where $j = 1, \; a_{0} = a, \; n = a^{2} + b$, these are equivalent to
\begin{align}
q_{k} - aq_{k - 1} - p_{k - 1}  &= 0, \label{sqrtNPeriodicZeroRelationEquivalent1} \\
bq_{k - 1} + aq_{k} - p_{k}  &= 0. \label{sqrtNPeriodicZeroRelationEquivalent2} 
\end{align}
\end{lemma}

\begin{proof}
These are easy consequences of formulas \eqref{periodicQuadraticj1} and \eqref{periodicQuadraticjge2}.
\end{proof}

Burger and his coauthors \cite{BGKWY08} show that quadratic irrationals have infinitely many positive integers $z$ for which the maximal $\text{cf}_{z}$ expansion has period 1.  Nevertheless, as Anselm and Weintraub mention \cite{AW11}, odd period lengths tend to be rare for $\sqrt{n}$.  Several cases of odd period length exist, including infinite families such as $\sqrt{a^{2} + b} = [a, \overline{2a} \,]_{b}$.  However, these only occur when $z$ is an integer.

\begin{theorem}
If $z$ is rational and $\sqrt{n}$ has a $\text{cf}_{z}$ expansion with odd period length then $z$ is an integer.
\end{theorem}

\begin{proof}
Suppose that $\sqrt{n}$ has a periodic $\text{cf}_{z}$ expansion with period $2k + 1$,
\[
\sqrt{n} = [a_{0}, a_{1}, \ldots, a_{j - 1}, \overline{a_{j}, \ldots, a_{j + 2k}} \,]_{z}.
\]
For convenience, we assume that $j \geq 2$, the proof being slightly easier if $j = 0$ or $j = 1$.  We view equation \eqref{sqrtNPeriodicZeroRelation1} as an equation in $z$.  If $j$ is even, then by Theorem \eqref{pnqnproperties}, the terms in \eqref{sqrtNPeriodicZeroRelation1} have degrees $j + k - 1, \; j + k - 2, \; j + k - 1$, and $j + k$, respectively.  That is, the term of highest degree is $p_{j + 2k - 1}p_{j - 1}$.  If $j$ is odd, then the degrees are $j + k - 3, \; j + k - 2, \; j + k$, and $j + k  - 1$, with $p_{j + 2k}p_{j - 2}$ being the term of highest degree.  In each case, the term of highest degree is the product of two $p$'s of odd index.  Again by Theorem \eqref{pnqnproperties}, this means that the left hand side of the equation in \eqref{sqrtNPeriodicZeroRelation1} is a polynomial with leading coefficient $\pm 1$ and integer coefficients.  By the rational root theorem, any zero of this polynomial must be an integer.
\end{proof}

With the general theory of the previous section, we can describe some of the patterns in periodic expansions for $\sqrt{n}$, at least in the case where $z$ is rational and the periodic part of the expansion is strongly reduced.  Again, these results closely parallel those of Anselm and Weintraub \cite{AW11}.

\begin{theorem}
\label{sqrtNStronglyReducedPeriodK}
Suppose that $z$ is rational and $\sqrt{n}$ has a strongly reduced periodic maximal expansion, with period length $k$.  Let $a = \lfloor \sqrt{n} \rfloor$.
\begin{itemize}
\item[(a)] If $z < a + \sqrt{n}$ then $\sqrt{n} = [a, \overline{a_{1}, \cdots, a_{k-1}, 2a} \,]_{z}$.
\item[(b)]  If $z > a + \sqrt{n}$ then $\sqrt{n} = [a, a_{1}, \overline{a_{2}, \cdots, a_{k}, a_{1} + h} \,]_{z}$ where \\ $h = \left \lfloor \frac{z}{a + \sqrt{n}} \right \rfloor$.
\end{itemize}
Thus, if $\sqrt{n}$ has a strongly reduced periodic expansion, then the tail in the maximal expansion has length 1 or 2.
\end{theorem}

\begin{proof}
If $z < a + \sqrt{n}$ and we set $y = a + \sqrt{n}$ then $y > z$, and since $z$ is rational, $\overline{y} = a - \sqrt{n}$ satisfies $-1 < \overline{y} < 0$.  Thus, $y$ is strongly reduced and periodic, so it must be purely periodic.  Since $\lfloor y \rfloor = 2a$, the result follows.

Next, suppose that $z > a + \sqrt{n}$ and set $h = \left \lfloor \frac{z}{a + \sqrt{n}} \right \rfloor$.  We know $\sqrt{n}$ has a maximal expansion $[a, a_{1}, x_{2}]_{z}$, where $a_{1}$ is the floor of $x_{1} = \frac{z}{\sqrt{n} - a}$.  Now $x_{2} = \frac{z}{x_{1} - a_{1}} > z$ and $\overline{x}_{2} = \frac{z}{\overline{x}_{1} - a_{1}}$.  But $\overline{x}_{1} = \frac{z}{-\sqrt{n} - a} < -1$ so $\frac{z}{-1 - a_{1}} < \overline{x}_{2} < 0$.  Since $a_{1} \geq \lfloor z \rfloor, \; -1 < \overline{x}_{2} < 0$ so $x_{2}$ is strongly reduced, and consequently, purely periodic.  It remains to show that $a_{k + 1} = a_{1} + h$.  By the proof of Theorem \ref{stronglyReducedPurelyPeriodic} with $j = 2$ we have $a_{k + 1} - a_{1} = \overline{x_{k + 1}} - \overline{x_{1}}$.  Thus, $a_{k + 1} - a_{1} = \frac{z}{a + \sqrt{n}} + \overline{x_{k + 1}} = h$ since $a_{k + 1} - a_{1}$ is an integer and $-1 < \overline{x_{k + 1}} < 0$.
\end{proof}

In the first case of Theorem \ref{sqrtNStronglyReducedPeriodK}, as in the classical case ($z = 1$) and in \cite{AW11}, more structure is present.

\begin{theorem}
\label{sqrtNStronglyReducedPeriodicPartK}
Suppose that $z$ is rational and $\sqrt{n}$ has a strongly reduced periodic maximal expansion, with period length $k$.  Let $a = \lfloor \sqrt{n} \rfloor$ and assume that $z < a + \sqrt{n}$.  Then
\[ \sqrt{n} = [a, \overline{a_{1}, \cdots, a_{k-1}, 2a} \,]_{z},
\]
where for each $j$ with $1 \leq j \leq k - 1, \; a_{j} = a_{k - j}$.  That is, the sequence $a_{1}, a_{2}, \ldots, a_{k - 1}$ is palindromic.
\end{theorem}

\begin{proof}
Setting $x = x_{0} = a + \sqrt{n}$ we have $x_{1} = \frac{z}{x_{0} - 2a} = \frac{z}{\sqrt{n} - a}$.  This means that $- \frac{z}{\overline{x}_{1}} = - (- \sqrt{n} - a) = x$.  By Theorem \ref{stronglyReducedPurelyPeriodic} the partial quotients of $x_{1}$ are the reverse of the partial quotients of $x$.  That is,
\[ (a_{1}, a_{2}, \ldots, a_{k - 1}, 2a) = (a_{k - 1}, a_{k - 2}, \ldots, a_{1}, 2a),
\]
and the result follows.
\end{proof}

If $\sqrt{n}$ does not have a strongly reduced expansion, the results of Theorem \ref{sqrtNStronglyReducedPeriodicPartK} may or may not hold.  For example,
\[  \sqrt{5} = [2, \overline{4, 1, 6, 11180, 6, 1, 4, 4} \,]_{20/17}
\]
has palindromic behavior but as previously noted,
\[  \sqrt{2} = [1, \overline{3, 6, 14, 1, 2, 2} \,]_{4/3},
\]
and the palindromic pattern is not present.

Case (a) of Theorem \ref{sqrtNStronglyReducedPeriodK} can fail, as well.  That is, $\sqrt{n}$ might have a periodic expansion with a tail of size 1 but the period might not end with $2a$.  For example, if $z = \frac{21}{8}$ then
\[ \sqrt{5} = [2, \overline{11, 21, 2, 3} \,]_{z}.
\]
This example is part of an infinite family:
\begin{equation}  \sqrt{k^{2} + 1} = [k, \overline{2k^{2} + k + 1, \; 4k^{2} + 2k + 1, \; k, \; 2k - 1} \,]_{z}
\end{equation}
when $\displaystyle z = \frac{4k^{2} + 2k + 1}{4k}$.  There are also examples with a tail longer than 2 when the tail is not strongly reduced.  Among them are
\begin{align}
\sqrt{34} = [5, 2, 3, \overline{12, 4, 117, 4} \,]_{z} \quad &\text{ when } \; z = \frac{9}{4}, \\
\sqrt{29} = [5, 8, 3, 4, \overline{12, 5, 688, 5} \,]_{z} \quad &\text{ when } \; z = \frac{24}{7}, \\
\sqrt{178} = [13, 4, 3, 1, 1, \overline{1, 2, 3, 2, 1, 2, 39, 2} \,]_{z} \quad &\text{ when } \; z = \frac{3}{2}.
\end{align}

There is a simplification for general periodic expansions with tail length 1, if they have the palindromic behavior of Theorem \ref{sqrtNStronglyReducedPeriodicPartK}.

\begin{lemma}
\label{ak2a0TailLength1}
As free variables, if $a_{j} = a_{k - j}$ for $1 \leq j \leq k - 1$ and $a_{k} = 2a_{0}$ then $q_{k} - aq_{k - 1} - p_{k - 1} = 0$.  That is, formula \eqref{sqrtNPeriodicZeroRelationEquivalent1} of Lemma \ref{sqrtNpqStructure} is a polynomial identity in this situation.
\end{lemma}

\begin{proof}
This is a simple consequence of the polynomial identities in Theorem \ref{pnqnrelationships}.
\end{proof}

Consequently, by Theorem \ref{repeatingPeriodicPart}, $\sqrt{n}$ will have a $\text{cf}_{z}$ expansion as in Theorem \ref{sqrtNStronglyReducedPeriodicPartK} if and only if formula \eqref{sqrtNPeriodicZeroRelationEquivalent2} is satisfied.  If $a_{j} \geq z$ for all $j \geq 1$ then this will be the maximal expansion for $\sqrt{n}$.  From the first several cases of formula \eqref{sqrtNPeriodicZeroRelationEquivalent2} we have the following expansions.

\begin{theorem}
\label{stronglyReducesPeriodUpTo6Forms}
Let $n = a^{2} + b$ where $1 \leq b \leq 2a$ and let $z$ be rational with $1 \leq z \leq 2a$.  Strongly reduced expansions for $\sqrt{n}$ satisfying formula \eqref{sqrtNPeriodicZeroRelationEquivalent2} of period up to 6 have the following forms.
\begin{itemize}
\item[(a)] $\sqrt{n} = [a, \overline{2a} \,]_{z}$, when $z = b$,
\item[(b)]  $\sqrt{n} = [a, \overline{c, 2a} \,]_{z}$, when $z = \frac{bc}{2a}$, for some $c \geq 1$,
\item[(c)]  $\sqrt{n} = [a, \overline{c, c, 2a} \,]_{z}$, when  $z^{2} + (2ac - b)z - bc^{2} = 0$ for some $c \geq z$,
\item[(d)]  $\sqrt{n} = [a, \overline{c, d, c, 2a} \,]_{z}$, when $(2a + d)z^{2} + 2c(ad - b)z - bc^{2}d = 0$ for some $c, d \geq z$,
\item[(e)]  $\sqrt{n} = [a, \overline{c, d, d, c, 2a} \,]_{z}$, when
\[z^{3} + (2ac + 2ad + d^{2} - b)z^{2} + c(2ad^{2} - bc - 2bd)z - bc^{2}d^{2} = 0\]
for some $c, d \geq z$,
\item[(f)]  $\sqrt{n} = [a, \overline{c, d, e, d, c, 2a} \,]_{z}$, when
\begin{align*}
(2a + 2d)z^{3} &+ (4acd + 2ade + d^{2}e - 2bc - be)z^{2} \\
&+ 2c(2ad^{2}e - bcd - 2bde)z - bc^{2}d^{2}e = 0
\end{align*}
for some $c, d, e \geq z$.
\end{itemize}
\end{theorem}

By Theorem \eqref{T: sym} we may write formula \eqref{sqrtNPeriodicZeroRelationEquivalent2} in the form
\[ bq_{k -1}(a, a_{1}, \ldots, a_{k-1}) - zq_{k - 1}(a_{1}, \ldots, a_{k - 1}, 2a) = 0,
\]
from which it follows that for fixed integers $a_{1}, \ldots, a_{k - 1}$ and fixed $z$ we have a linear Diophantine equation of the form $bx - ay = c$.  This allows for the construction of families of $n$ for which $\sqrt{n}$ has small period length.  For example, in part (d) of Theorem \ref{stronglyReducesPeriodUpTo6Forms} if we let $z = \frac{5}{3}, \, c = 2, \, d = 6$, the resulting equation is $276b - 410a = 150$, with solution $a = 3 + 138t, \, b = 5 + 205t$.  As a consequence, for all non-negative integers $t$ we have
\[  \sqrt{(3 + 138t)^{2} + 5 + 205t} = [138t + 3, \overline{2, 6, 2, 276t + 6} \,]_{5/3}.
\]
For a given $z \geq 1$, if there is an $n$ for which $\sqrt{n}$ has a periodic expansion of length $k$ as in Theorem \ref{sqrtNStronglyReducedPeriodicPartK}, then this construction shows that there are infinitely many $n$ for which $\sqrt{n}$ has period length $k$.

\begin{conjecture}
For every $k \geq 1$ and every rational $z \geq 1$ there are infinitely many integers $n$ for which $\sqrt{n}$ has a maximal $\text{cf}_{z}$ expansion of period $2k$ with palindromic behavior as in Theorem \ref{sqrtNStronglyReducedPeriodicPartK}.  For every $k \geq 0$ and every integer $z \geq 1$ there are infinitely many integers $n$ for which $\sqrt{n}$ has a maximal $\text{cf}_{z}$ expansion of period $2k + 1$ with palindromic behavior as in Theorem \ref{sqrtNStronglyReducedPeriodicPartK}.
\end{conjecture}

This conjecture is obviously true for periods of length 1 or 2, and not too hard to show for period length 3.  For period length 4, if $n$ is fixed, Pell's equation comes into play.  We have the following theorem.

\begin{theorem}
\label{sqrtNPeriodicPellSolution}
Let $n = a^{2} + b$, where $1 \leq b \leq 2a$.  Then $\sqrt{n}$ has maximal expansion of the form $[a, \overline{c, d, c, 2a} \,]_{z}$ if and only if $(x, d)$ is a positive solution to the Pell equation $x^2 - nd^{2} = b^{2}$ for some integer $x$.  When $d$ is such a solution, an expansion will exist for $z = \frac{c}{2a + d}(x + b - ad)$, and $c$ is chosen so that $0 < z \leq \min(2a, d)$.
\end{theorem}

\begin{proof}
The discriminant for $(2a + d)z^{2} + 2c(ad - b)z - bc^{2}d$ is $nd^{2} + b^{2}$, leading to the Pell equation.  When the Pell equation has a solution, solving $(2a + d)z^{2} + 2c(ad - b)z - bc^{2}d = 0$ for $z$ gives the form of $z$ above.  The condition on $c$ is needed for the expansion to be strongly reduced.
\end{proof}

\begin{corollary}
For each $n = a^{2} + b$ with $1 \leq b \leq 2a$, there are infinitely many strongly reduced maximal expansions $\sqrt{n} = [a, \overline{c, d, c, 2a} \,]_{z}$.
\end{corollary}

\begin{proof}
There are infinitely many solutions to the Pell equation $x^2 - nd^{2} = b^{2}$.  As $d$ goes to infinity, $\frac{x + b - ad}{2a + d}$ approaches $\sqrt{n} - a < 1$ so there are infinitely many $d$ with $\frac{x + b - ad}{2a + d} < 1$.  This guarantees that for each such $d$ there exist $c$ and $z$ fulfilling the conditions of Theorem \ref{sqrtNPeriodicPellSolution}.  In particular, $c = 1$ will work.  There is also a smallest $c$ making $z \geq 1$, and for this $c, \; z \leq 2a$ so there are infinitely many expansions with $z \geq 1$ as well.
\end{proof}

The condition on $c$ in Theorem \ref{sqrtNPeriodicPellSolution} is not best possible.  For example, when $a = b = 1, \, n = 2$, the Pell equation is $x^{2} - 2d^{2} = 1$.  One solution to this equation is $d = 12, x = 17$, giving $z = \frac{3}{7}c$.  We have strongly reduced expansions $\sqrt{2} = [1, \overline{c, 12, c, 2} \,]_{z}$ for $1 \leq c \leq 4$.  When $c = 5$, we still have  maximal expansion $\sqrt{2} = [1, \overline{5, 12, 5, 2} \,]_{z}$, with $z = \frac{15}{7} > 2a$.  When $c = 6$, the floor of $z$ is still 2 but the maximal expansion for $\sqrt{2}$ does not have period 4.

When $z > 2a$, strongly reduced periodic expansions have tail length 2.  The formulas in these cases are more complicated because Lemma \ref{ak2a0TailLength1} no longer applies.  We give a short list below, of the requirements for period lengths up to 3.

\begin{theorem}
\label{sqrtNTail2PeriodAtMost3Forms}
Let $n = a^{2} + b$ where $1 \leq b \leq 2a$ and let $z$ be rational with $z > 2a$.  Strongly reduced expansions for $\sqrt{n}$ with tail length 2 and period at most 3 have the following forms.
\begin{itemize}
\item[(a)] $\sqrt{n} = [a, c, \overline{d} \,]_{z}$, when
\begin{align*}
(2a - 2c + d)z - 2ac^{2} + 2acd &= 0, \\
z^{2} - bz + bc^{2} - bcd &= 0,
\end{align*}
for some $c, d \geq z$,

\item[(b)]  $\sqrt{n} = [a, c, \overline{d, e} \,]_{z}$, when
\begin{align*}
(2ae - 2cd + de)z - 2ac^{2}d + 2acde &= 0, \\
dz^{2} - bez + bc^{2}d - bcde &= 0,
\end{align*}
for some $c, d, e \geq z$,

\item[(c)]  $\sqrt{n} = [a, c, \overline{d, e, f} \,]_{z}$, when
\begin{align*}
(2a - 2c + d - e + f)z^{2} &+ (-2ac^{2} + 2acd - 2ace + 2acf + 2aef - 2cde + def)z \\
& - 2ac^{2}de + 2acdef = 0, \\
z^{3} + (de - b)z^{2} &+ (bc^{2} - bcd + bce - bcf - bef)z + bc^{2}de - bcdef = 0,
\end{align*}
for some $c, d, e, f \geq z$.
\end{itemize}
\end{theorem}

\begin{proof}
In each case, the top condition is equation \eqref{sqrtNPeriodicZeroRelation2}, with the tail length $j = 2$.  The bottom equation is the result of $a$ times equation \eqref{sqrtNPeriodicZeroRelation2} subtracted from equation \eqref{sqrtNPeriodicZeroRelation1}, after replacing $n$ by $a^{2} + b$.
\end{proof}

For small period, these formulas allow for the construction of infinite families of expansions.  We mention the following.
\begin{align}
\sqrt{9m^{2} - 2m} &= [3m - 1, 24m - 6, \overline{24m - 4} \,]_{16m - 4}, \\
\sqrt{9m^{2} - 3m + 1} &= [3m - 1, 8m^{2} - 2m, \overline{24m^{2} - 6m} \,]_{12m^{2}}, \\
\sqrt{9m^{2} - m} &= [3m - 1, 9m - 2, \overline{30m - 6, 9m - 1} \,]_{\frac{15}{2}m - \frac{3}{2}}, \label{infiniteFamiliesSqrt9mSquaredMinusM} \\
\sqrt{4m^{2} - m} &= [2m - 1, 8m - 3, \overline{12m - 4, 8m - 2} \,]_{6m - 2}. \label{infiniteFamiliesSqrt4mSquaredMinusM}
\end{align}
The first two of these fit into a doubly infinite family:  $\sqrt{n} = [a, c, \overline{d} \,]_{z}$, for all positive integers $m$ and $k$ with $n = a^{2} + b$ where $a = m(4k-1) - k, \; b = m(4k - 1), \; c = 2m(4m - 1)(4k - 1), \; d = 2m(4m - 1)(4k - 1) + 2m, \; z = 4m^{2}(4k - 1)$.  There appear to be a large number of formulas similar to \eqref{infiniteFamiliesSqrt9mSquaredMinusM} and \eqref{infiniteFamiliesSqrt4mSquaredMinusM}.

In Theorem \ref{sqrtNTail2PeriodAtMost3Forms} parts (a) and (b), Pell's equation again plays a role when $n$ is fixed.

\begin{theorem}
\label{sqrtNPeriod1MaximalExpansionCondition}
If $n = a^{2} + b$ then $\sqrt{n} = [a, c, \overline{d} \,]_{z}$ provided that $nd^{2} + b^{2}$ is a square and
\[ c = \frac{nd + ab + a\sqrt{nd^{2} + b^{2}}}{2n} \qquad \text{and} \qquad z =\frac{b^{2} + b\sqrt{nd^{2} + b^{2}}}{2n}
\]
are both integers.  If $2a < z \leq \min(c, d)$, then this is a maximal expansion.
\end{theorem}

\begin{proof}
Adding $b$ times the top equation to $2a$ times the bottom equation in Theorem 6.12 (a) gives the condition $z = \frac{b}{2a}(2c - d)$.  This coupled with $(2a - 2c + d)z - 2ac^{2} + 2acd = 0$ gives a quadratic equation in $c$ with positive solution $\displaystyle c = \frac{nd + ab + a\sqrt{nd^{2} + b^{2}}}{2n}$, implying that $\displaystyle z =\frac{b^{2} + b\sqrt{nd^{2} + b^{2}}}{2n}$.  Thus, in order for $\sqrt{n}$ to be $[a, c, \overline{d} \,]_{z}$, both $c$ and $z$ must be integers, which also requires $nd^{2} + b^{2}$ to be a square.  If $c$ and $z$ are integers in the given form, it follows that the equations in Theorem  \ref{sqrtNTail2PeriodAtMost3Forms} (a) are satisfied.
\end{proof}

We conjecture that there are integers $c$ and $z$ satisfying the requirements of Theorem \ref{sqrtNPeriod1MaximalExpansionCondition} for any non square $n$, though we do not have a proof.  However, with part (b) of Theorem \ref{sqrtNTail2PeriodAtMost3Forms}, we have more freedom.

\begin{theorem}
\label{sqrtNNotSqrInfinitelyManyPeriod2}
For each positive integer, $n$, not a square, there are infinitely many  $c, d, e$ for which $\sqrt{n} = [a, c, \overline{d, e} \,]_{z}$.  In particular, with $n = a^{2} + b, \, 1 \leq b \leq 2a$, if $m^{2}n + 1 = k^{2}$ then $\sqrt{n}$ has maximal expansion $[a, c, \overline{d, e} \,]_{z}$ with $c = k - 1 + am, \, d = bm, \, e = 2(k - 1), \, z = bm$, for all solutions with $bm > 2a$. 
\end{theorem}

\begin{proof}
Letting $d = mb$, then $nd^{2} + b^{2} = b^{2}(nm^{2} + 1)$, and $nm^{2} + 1$ is a square infinitely often.  Suppose that $nm^{2} + 1 = k^{2}$ for positive integer $k$.  If we write
\[  z = \frac{be(b + \sqrt{nd^{2} + b^{2}})}{2nd} = \frac{eb(k + 1)}{2mn} \qquad \text{and} \qquad c = \frac{e}{2} + \frac{ae(k + 1)}{2mn}
\]
then $a, b, c, d, e, z$ formally satisfy the equations in Theorem \ref{sqrtNTail2PeriodAtMost3Forms} (b).  Note that $c = \frac{1}{2}(e + \frac{2az}{b})$.  Since $b \leq 2a, \; c \geq \frac{1}{2}(e + z)$.  Thus, if $e$ can be selected so that $e \geq z, \; 2a < z \leq d$ and $c$ is an integer, then the maximal expansion of $\sqrt{n}$ will be  $[a, c, \overline{d, e} \,]_{z}$.  Let $(m, k)$ to be a positive integer solution to the Pell equation $x^{2} - ny^{2} = 1$ with $k > 1$.  If $e = 2(k - 1)$ then $\displaystyle z = \frac{2b(k^{2} - 1)}{2mn} = \frac{2bm^{2}n}{2mn} = bm = d$ and $c = am + k - 1 > am - 1 + m\sqrt{n} > 2am - 1$ so $c \geq bm = z$.
\end{proof}

Cases of expansions with longer tails or longer periodic part become more complicated but presumably they could be investigated with similar techniques.


\begin{thebibliography}{99}

    \bibitem{AW11}
          M. Anselm  and S. Weintraub, A generalization of continued fractions, {\it J. Number Theory} \textbf{131}
          (2011), 2442--2460.
    \bibitem{BGKWY08}
          E. Burger, J. Gell-Redman, R. Kravitz, D. Welton, and N. Yates, Shrinking the period length of continued fractions while
          still capturing convergents, {\it J. Number Theory} \textbf{128} (2008), 144--153.
    \bibitem{DKL15}
    	K. Dajani, C. Kraaikamp, and N. Langeveld, Continued fraction expansions with variable numerators, {\it Ramanujan J.} \textbf{37} (2015), 617--639. 
     \bibitem{DKW13}
    	K. Dajani, C. Kraaikamp, and N. van der Wekken, Ergodicity of $N$-continued fraction expansions, {\it J.
	Number Theory} \textbf{133} (2013), 3183--3204. 
    \bibitem{HW79}
        G. Hardy and E. Wright, \emph{An Introduction to the Theory of Numbers}, Oxford University Press, 1979.
    \bibitem{dK69}
        D. Knuth, \emph{The Art of Computer Programming, Vol.~II: Seminumerical Algorithms}, Addison-Wesley, 1969.
    \bibitem{tK09}
        T. Komatsu, Shrinking the period length of quasi-periodic continued fractions, {\it J. Number Theory} \textbf{129}
        (2009), 358--366.
    \bibitem{wL77}
          W. LeVeque, \emph{Fundamentals of Number Theory}, Addison-Wesley, 1977.
    \bibitem{cO63}
          C. D. Olds, \emph{Continued Fractions}, Random House, 1963.
    \bibitem{oP13}
    	O. Perron, \emph{Die Lehre von den Kettenbruchen}, B. G. Teubner, 1913.
     \bibitem{jS15}
          J. Schmieg, \emph{Patterns of Non-Simple Continued Fractions}, UROP project, 2015, \url{http://www.d.umn.edu/~jgreene/masters\_reports/JesseSchmieg\_UROPFinalReport.pdf}         
 \end{thebibliography}
 


\bigskip
\hrule
\bigskip

\noindent 2010 {\it Mathematics Subject Classification}:
Primary 11A55.

\noindent \emph{Keywords: } 
continued fraction, linear Diophantine equation, Pell's equation.

\bigskip
\hrule
\bigskip

\vspace*{+.1in}
\noindent
Received September 18 2016;
revised version received  December 21 2016.
Published in {\it Journal of Integer Sequences}, December 23 2016.

\bigskip
\hrule
\bigskip

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


\end{document}

                                                                                

