Solution (source code)

= Solution

The matrix recurrence gives $p_{n+1}q_n-p_nq_{n+1}=(-1)^n$ and $q_{n+1}=a_{n+1}q_n+q_{n-1}$. Successive <continued fraction convergents> bracket $x$, hence
$$
\boxed{\left|x-\frac{p_n}{q_n}\right|\leq\left|\frac{p_{n+1}}{q_{n+1}}-\frac{p_n}{q_n}\right|=\frac1{q_nq_{n+1}}\leq\frac1{a_{n+1}q_n^2}.}
$$
The infinite <continued fraction> is irrational: if $x=p/q$ were rational, a distinct convergent would be at distance at least $1/(qq_n)$, contradicting the first bound once $q_{n+1}>q$. If $x^2$ were rational, this irrational $x$ would have degree two. The <Liouville approximation theorem> would then give $|x-p_n/q_n|\geq C/q_n^2$. Comparing with the displayed bound would force $a_{n+1}\leq1/C$ for every $n$, contrary to the unbounded coefficients. Thus \b[$x^2$ is irrational], by the <unbounded continued-fraction coefficients exclude quadratic irrationality> argument.