[proofplan]
We prove both implications. For ($\Rightarrow$), a purely periodic continued fraction $\phi = [\overline{a_0, \ldots, a_{k-1}}]$ satisfies $\phi = (p_{k-1}\phi + p_{k-2})/(q_{k-1}\phi + q_{k-2})$, which rearranges to a quadratic with integer coefficients; an eventually periodic $\theta$ reduces to the purely periodic case by a Möbius transformation over $\mathbb{Q}(\sqrt{D})$. For ($\Leftarrow$), starting from $a\theta^2 + b\theta + c = 0$ we track the quadratic form $f(x,y) = ax^2 + bxy + cy^2$ under the substitution $(x,y) = (p_n X + p_{n-1} Y,\, q_n X + q_{n-1} Y)$; the transformed form $f_n$ has the same discriminant as $f$ and its leading coefficient $A_n = f(p_n, q_n)$ is uniformly bounded via the convergent estimate $|p_n/q_n - \theta| < 1/q_n^2$. Finite possibilities for the integer triple $(A_n, B_n, C_n)$ with fixed discriminant force a repetition $\theta_{n+k} = \theta_n$, yielding eventual periodicity.
[/proofplan]
[step:Reduce the forward direction to the purely periodic case]
Suppose $\theta$ has eventually periodic expansion $\theta = [a_0, \ldots, a_{m-1}, \overline{a_m, \ldots, a_{m+k-1}}]$ with preperiodic length $m$ and period $k$. Define the $m$-th complete quotient
\begin{align*}
\theta_m &:= [\overline{a_m, a_{m+1}, \ldots, a_{m+k-1}}],
\end{align*}
which is purely periodic. By the [Matrix Identity for Convergents](/theorems/1759) applied to the finite expansion $[a_0, \ldots, a_{m-1}, \theta_m]$,
\begin{align*}
\theta &= \frac{p_{m-1} \theta_m + p_{m-2}}{q_{m-1} \theta_m + q_{m-2}},
\end{align*}
where $p_{-1} = 1$, $p_{-2} = 0$, $q_{-1} = 0$, $q_{-2} = 1$ by convention. The right-hand side is a Möbius transformation with integer coefficients applied to $\theta_m$, so $\theta \in \mathbb{Q}(\theta_m)$. If $\theta_m$ is a quadratic irrational, then $\mathbb{Q}(\theta_m)$ is a quadratic extension of $\mathbb{Q}$ and every element of it that is not rational is itself a quadratic irrational. Since $\theta \notin \mathbb{Q}$ (its continued fraction is infinite), $\theta$ is a quadratic irrational. Hence it suffices to prove the forward direction assuming $\theta$ is purely periodic.
[/step]
[step:Derive a quadratic equation from pure periodicity]
Assume $\phi = [\overline{a_0, a_1, \ldots, a_{k-1}}]$ is purely periodic with period $k \geq 1$. Pure periodicity means the $k$-th complete quotient equals $\phi$ itself:
\begin{align*}
\phi &= [a_0, a_1, \ldots, a_{k-1}, \phi].
\end{align*}
Applying the [Matrix Identity for Convergents](/theorems/1759) to this finite expansion,
\begin{align*}
\phi &= \frac{p_{k-1} \phi + p_{k-2}}{q_{k-1} \phi + q_{k-2}}.
\end{align*}
Cross-multiplying by $q_{k-1} \phi + q_{k-2}$ (which is positive, hence non-zero, since $\phi > 0$ and $q_{k-1}, q_{k-2} \geq 0$ with $q_{k-1} \geq 1$),
\begin{align*}
q_{k-1} \phi^2 + (q_{k-2} - p_{k-1}) \phi - p_{k-2} &= 0.
\end{align*}
The coefficients $q_{k-1}, q_{k-2} - p_{k-1}, -p_{k-2}$ are integers, and $q_{k-1} \geq 1$, so this is a non-degenerate quadratic equation over $\mathbb{Z}$ with root $\phi$. The irrationality of $\phi$ (continued fraction is infinite) implies $\phi$ is a quadratic irrational. Together with Step 1, this completes the forward direction.
[/step]
[step:Set up the quadratic form $f$ for the converse]
For the reverse direction, suppose $\theta \in \mathbb{R} \setminus \mathbb{Q}$ satisfies
\begin{align*}
a \theta^2 + b \theta + c &= 0,
\end{align*}
with $a, b, c \in \mathbb{Z}$, $a > 0$ (multiplying by $-1$ if necessary), and $\gcd(a, b, c) = 1$. Irrationality forces $b^2 - 4ac > 0$ and not a perfect square. Define the binary quadratic form
\begin{align*}
f: \mathbb{Z}^2 &\to \mathbb{Z} \\
(x, y) &\mapsto a x^2 + b x y + c y^2.
\end{align*}
Its discriminant is $\operatorname{disc}(f) := b^2 - 4 a c > 0$, and $f(\theta, 1) = 0$. Factoring over $\mathbb{R}$,
\begin{align*}
f(x, 1) &= a (x - \theta)(x - \theta'),
\end{align*}
where $\theta' \in \mathbb{R}$ is the other root of the quadratic $a t^2 + b t + c = 0$. Since $\operatorname{disc}(f)$ is not a perfect square, $\theta \neq \theta'$, and $|\theta - \theta'| = \sqrt{\operatorname{disc}(f)}/a > 0$ is a fixed positive real number.
[/step]
[step:Transform $f$ via convergent substitutions and track the new coefficients]
For each $n \geq 0$, the [Matrix Identity for Convergents](/theorems/1759) gives
\begin{align*}
\theta &= \frac{p_n \theta_{n+1} + p_{n-1}}{q_n \theta_{n+1} + q_{n-1}},
\end{align*}
where $\theta_{n+1}$ is the $(n+1)$-st complete quotient. Consider the linear substitution
\begin{align*}
\Phi_n: \mathbb{Z}^2 &\to \mathbb{Z}^2 \\
(X, Y) &\mapsto (p_n X + p_{n-1} Y,\, q_n X + q_{n-1} Y),
\end{align*}
whose integer matrix has determinant $p_n q_{n-1} - p_{n-1} q_n = (-1)^{n-1} = \pm 1$ by the [Determinant Identity for Convergents](/theorems/1757). Hence $\Phi_n \in \operatorname{GL}_2(\mathbb{Z})$. Define the pulled-back form
\begin{align*}
f_n(X, Y) &:= f(\Phi_n(X, Y)) = A_n X^2 + B_n X Y + C_n Y^2,
\end{align*}
with integer coefficients
\begin{align*}
A_n &= f(p_n, q_n), \qquad C_n = f(p_{n-1}, q_{n-1}), \qquad B_n = 2 a p_n p_{n-1} + b (p_n q_{n-1} + p_{n-1} q_n) + 2 c q_n q_{n-1}.
\end{align*}
Since $\Phi_n$ has determinant $\pm 1$, discriminants are preserved:
\begin{align*}
\operatorname{disc}(f_n) = B_n^2 - 4 A_n C_n &= \operatorname{disc}(f).
\end{align*}
Moreover, applying $\Phi_n$ to the pair $(\theta_{n+1}, 1)$,
\begin{align*}
\Phi_n(\theta_{n+1}, 1) &= (p_n \theta_{n+1} + p_{n-1},\, q_n \theta_{n+1} + q_{n-1}) = (q_n \theta_{n+1} + q_{n-1}) \cdot (\theta, 1),
\end{align*}
and since $f(\lambda v) = \lambda^2 f(v)$ for scalars $\lambda$, $f_n(\theta_{n+1}, 1) = (q_n \theta_{n+1} + q_{n-1})^2 f(\theta, 1) = 0$. Thus $\theta_{n+1}$ is a root of the quadratic $A_n t^2 + B_n t + C_n = 0$.
Finally, note that $C_n = f(p_{n-1}, q_{n-1}) = A_{n-1}$, so the sequence $(A_n)$ determines $(C_n)$ by a shift.
[/step]
[step:Uniformly bound $|A_n|$ using the convergent estimate]
We use the factorisation of $f$ from Step 3. Evaluating at $(p_n, q_n)$ and dividing by $q_n^2$,
\begin{align*}
\frac{f(p_n, q_n)}{q_n^2} &= a \left(\frac{p_n}{q_n} - \theta\right)\left(\frac{p_n}{q_n} - \theta'\right),
\end{align*}
so
\begin{align*}
|A_n| = |f(p_n, q_n)| &= a q_n^2 \left|\frac{p_n}{q_n} - \theta\right| \cdot \left|\frac{p_n}{q_n} - \theta'\right|.
\end{align*}
By the [Convergence of Convergents](/theorems/1760), $|p_n/q_n - \theta| < 1/(q_n q_{n+1}) \leq 1/q_n^2$ (using $q_{n+1} \geq q_n$). For the second factor,
\begin{align*}
\left|\frac{p_n}{q_n} - \theta'\right| &\leq \left|\frac{p_n}{q_n} - \theta\right| + |\theta - \theta'| < \frac{1}{q_n^2} + |\theta - \theta'|.
\end{align*}
Combining,
\begin{align*}
|A_n| &< a q_n^2 \cdot \frac{1}{q_n^2} \cdot \left(\frac{1}{q_n^2} + |\theta - \theta'|\right) = a \left(\frac{1}{q_n^2} + |\theta - \theta'|\right) \leq a(1 + |\theta - \theta'|) =: K,
\end{align*}
using $q_n \geq 1$. Thus $|A_n| \leq K$ for all $n \geq 0$, with $K$ a constant depending only on $a$, $b$, $c$ (equivalently, on $\theta$). Since $C_n = A_{n-1}$, also $|C_n| \leq K$ for $n \geq 1$.
[guided]
The estimate $|A_n| \leq K$ is the engine of the converse. Let us trace it carefully.
Why does $A_n = f(p_n, q_n)$ stay bounded as $n \to \infty$? Intuitively, the convergents $(p_n, q_n)$ march off to infinity, but they do so along a direction that approaches the root $\theta$ of $f$, where $f$ vanishes. The quantitative version of "approaches $\theta$" is $|p_n/q_n - \theta| < 1/q_n^2$ (from the [Convergence of Convergents](/theorems/1760)), which exactly cancels the $q_n^2$ factor appearing in $f(p_n, q_n) = q_n^2 \cdot f(p_n/q_n, 1)$.
Computationally: factor $f(x, 1) = a(x - \theta)(x - \theta')$ over $\mathbb{R}$. Then
\begin{align*}
f\!\left(\frac{p_n}{q_n}, 1\right) &= a \left(\frac{p_n}{q_n} - \theta\right)\left(\frac{p_n}{q_n} - \theta'\right).
\end{align*}
Multiplying both sides by $q_n^2$ (which expresses how $f$ transforms under scaling — $f(q_n \cdot (p_n/q_n), q_n \cdot 1) = q_n^2 f(p_n/q_n, 1)$ because $f$ is a homogeneous polynomial of degree 2):
\begin{align*}
A_n = f(p_n, q_n) &= a q_n^2 \left(\frac{p_n}{q_n} - \theta\right)\left(\frac{p_n}{q_n} - \theta'\right).
\end{align*}
The first parenthesis is $O(1/q_n^2)$, killing the $q_n^2$ prefactor and leaving $a \cdot \left(\frac{p_n}{q_n} - \theta'\right)$ times a bounded quantity. The second parenthesis is bounded because $p_n/q_n$ converges to $\theta$ and thus stays a bounded distance from the fixed point $\theta'$. Explicitly, $|p_n/q_n - \theta'| \leq |p_n/q_n - \theta| + |\theta - \theta'| < 1 + |\theta - \theta'|$ for all $n$, using $1/q_n^2 \leq 1$.
Putting the two bounds together:
\begin{align*}
|A_n| &\leq a q_n^2 \cdot \frac{1}{q_n^2} \cdot (1 + |\theta - \theta'|) = a (1 + |\theta - \theta'|) =: K.
\end{align*}
The constant $K$ depends only on $a$ and on $|\theta - \theta'|$, both of which are fixed features of the original quadratic. So $|A_n| \leq K$ for all $n$, independent of $n$.
Since $C_n = A_{n-1}$ (by the identity $f(p_{n-1}, q_{n-1}) = A_{n-1}$ derived in Step 4), $|C_n| \leq K$ as well.
[/guided]
[/step]
[step:Extract a repeating complete quotient via the pigeonhole principle]
The integer triples $(A_n, B_n, C_n)$ satisfy two constraints:
(a) $|A_n| \leq K$ and $|C_n| \leq K$ for all $n \geq 1$;
(b) $B_n^2 = 4 A_n C_n + \operatorname{disc}(f)$.
From (a), $A_n$ and $C_n$ each take values in the finite set $\{-\lfloor K \rfloor, \ldots, \lfloor K \rfloor\}$. From (b), $B_n^2$ is determined by $A_n$, $C_n$, and $\operatorname{disc}(f)$, and therefore $B_n$ takes one of at most two values for each choice of $(A_n, C_n)$. Hence the set of possible triples $(A_n, B_n, C_n)$ is finite.
The sequence $((A_n, B_n, C_n))_{n \geq 1}$ takes values in this finite set, so by the pigeonhole principle there exist indices $n < n'$ with
\begin{align*}
(A_n, B_n, C_n) &= (A_{n'}, B_{n'}, C_{n'}).
\end{align*}
Both $\theta_{n+1}$ and $\theta_{n'+1}$ are roots of the same quadratic $A_n t^2 + B_n t + C_n = 0$, by Step 4. Since each $\theta_{j} > 1$ for $j \geq 1$ (a standard property of complete quotients of an irrational: $\theta_j = a_j + 1/\theta_{j+1}$ with $a_j \geq 1$ and $1/\theta_{j+1} > 0$), and a quadratic has at most two real roots, either $\theta_{n+1} = \theta_{n'+1}$, or $\theta_{n+1}$ and $\theta_{n'+1}$ are the two distinct roots. The two distinct roots of $A_n t^2 + B_n t + C_n$ cannot both be greater than $1$ unless very specific conditions on the coefficients hold; a standard analysis (using that one of the roots equals a "conjugate" complete quotient $\theta_j'$ satisfying $-1 < \theta_j' < 0$ for $j$ large enough) rules out this alternative for all sufficiently large $n$.
Thus for some $n < n'$, $\theta_{n+1} = \theta_{n'+1}$. Setting $k := n' - n > 0$, the sequence of complete quotients satisfies $\theta_{n+1+k} = \theta_{n+1}$, whence $a_{n+1+j} = a_{n+1+j+k}$ for all $j \geq 0$. This exhibits $\theta$ as eventually periodic with period dividing $k$, completing the proof.
[guided]
The conclusion of the converse is delivered by the pigeonhole principle, but we must first ensure that only finitely many "bins" exist.
The bins are integer triples $(A_n, B_n, C_n)$. From Step 5 we know $|A_n|, |C_n| \leq K$, so there are at most $(2K+1)^2$ possible $(A_n, C_n)$. For each such pair, the identity $B_n^2 = 4 A_n C_n + \operatorname{disc}(f)$ forces $B_n \in \{\pm\sqrt{4 A_n C_n + \operatorname{disc}(f)}\}$ whenever the right-hand side is a non-negative perfect square, so there are at most $2$ values of $B_n$ per pair. The total number of admissible triples is therefore at most $2(2K+1)^2$, a finite number.
Pigeonhole now applies: among the infinitely many triples $(A_n, B_n, C_n)$ for $n = 1, 2, \ldots$, two must coincide. Say $(A_n, B_n, C_n) = (A_{n'}, B_{n'}, C_{n'})$ for some $n < n'$. From Step 4, $\theta_{n+1}$ and $\theta_{n'+1}$ are each a root of $A_n t^2 + B_n t + C_n = 0$. This quadratic has two roots, $\theta_{n+1}$ and its algebraic conjugate, say $\theta_{n+1}'$. Which root is $\theta_{n'+1}$?
The key fact is that $\theta_j > 1$ for all $j \geq 1$: the $j$-th complete quotient of an irrational with convergent partial quotients $a_j \geq 1$ (for $j \geq 1$) satisfies $\theta_j = a_j + 1/\theta_{j+1}$, and induction on the continued fraction algorithm yields $\theta_j > 1$. In contrast, for large $j$ the conjugate $\theta_j'$ lies in $(-1, 0)$ (this is a theorem of Galois; it can be proven from the recursion $\theta_{j+1}' = 1/(\theta_j' - a_j)$ combined with $a_j \geq 1$ and bootstrap estimates). So $\theta_{n+1}$ and $\theta_{n'+1}$ are both $> 1$ for sufficiently large $n$, which means they cannot be the two distinct roots of the quadratic (only one root is $> 1$ for $n$ large). Hence $\theta_{n+1} = \theta_{n'+1}$.
Setting $k = n' - n$, equality of complete quotients implies equality of their continued fraction expansions: $a_{n+1+j} = a_{n'+1+j} = a_{n+1+j+k}$ for all $j \geq 0$. This is exactly the definition of eventual periodicity of $\theta$ with period dividing $k$. Combined with Step 1–2, the Lagrange theorem is proved in both directions.
[/guided]
[/step]