Optimizing continued fraction of square root From this question, I learned that the square root of a number $n$ can be written as a continued fraction of the form:
$$\sqrt n=a+\frac{n-a^2}{a+\sqrt n}$$
where $a$ can have any value. By jumping to conclusions and testing, I believe that the optimal value for $a$ for a rapid convergence is the largest integer such that $a^2 < n$, but I haven't even been able to start trying to prove this.
Any insight would be helpful. Thanks!

\begin{align*}
  \frac{p_{n}}{q_{n}} &= \sqrt{n}+e_{n} \\
  &= a+\frac{n-a^2}{a+\frac{p_{n-1}}{q_{n-1}}} \\
  &= \frac{a\left(a+\frac{p_{n-1}}{q_{n-1}} \right)+n-a^2}
          {a+\frac{p_{n-1}}{q_{n-1}}} \\
  &= \frac{a \frac{p_{n-1}}{q_{n-1}}+n}{\frac{p_{n-1}}{q_{n-1}}+a} \\
  &= \frac{a (\sqrt{n}+e_{n-1})+n}{\sqrt{n}+e_{n-1}+a} \\
  &= \frac{\sqrt{n}(\sqrt{n} \color{red}{+e_{n-1}}+a)+
           (a \color{red}{-\sqrt{n}})e_{n-1}}
          {\sqrt{n}+e_{n-1}+a} \\
  &= \sqrt{n}+\frac{(a-\sqrt{n})e_{n-1}}{a+\sqrt{n}+e_{n-1}} \\
  \frac{p_{n}}{q_{n}}-\sqrt{n} &=
  \frac{(a-\sqrt{n})e_{n-1}}{a+\sqrt{n}+e_{n-1}} \\
  e_{n} &=
  \frac{(a-\sqrt{n})e_{n-1}}{a+\sqrt{n}+e_{n-1}} \\
  \frac{e_{n}}{e_{n-1}} & \approx \frac{a-\sqrt{n}}{a+\sqrt{n}} \\
\end{align*}
In usual practice, we take $a=\lfloor \sqrt{n} \rfloor \implies a-\sqrt{n}<0 $,
so that
$$\frac{p_n}{q_n} \lessgtr \sqrt{n} \lessgtr \frac{p_{n+1}}{q_{n+1}}$$
