Solution (source code)

= Solution

The convergents satisfy
$$
p_nq_{n-1}-p_{n-1}q_n=(-1)^{n-1},
$$
so $(p_n,q_n)$ and $(p_{n-1},q_{n-1})$ form an integer basis of $\mathbb Z^2$. Put $\delta_j=q_j\alpha-p_j$. Consecutive errors have opposite signs and $|\delta_{n-1}|>|\delta_n|$.

For integers $p,q$ with $0<q\leq q_n$, write
$$
(p,q)=r(p_n,q_n)+s(p_{n-1},q_{n-1}).
$$
If $s>0$, the denominator bound forces $r\leq0$, while if $s<0$ positivity forces $r\geq1$. Because $\delta_n$ and $\delta_{n-1}$ have opposite signs, in either case $s\neq0$ implies
$$
|q\alpha-p|=|r\delta_n+s\delta_{n-1}|>|\delta_n|.
$$
If $s=0$, the denominator bound gives $r=1$ unless the fraction is zero or has the same value as $p_n/q_n$. Thus $p_n/q_n$ is a <best approximation of the second kind>. Dividing by $q\leq q_n$ gives
$$
\boxed{\left|\alpha-\frac pq\right|
=\frac{|q\alpha-p|}{q}
\geq\frac{|q_n\alpha-p_n|}{q_n}
=\left|\alpha-\frac{p_n}{q_n}\right|.}
$$