Solution (source code)

= Solution
{c}

The <monic orthogonal polynomials> $\phi_0,\ldots,\phi_{r+1}$ form a basis of $P_{r+1}$, ordered by degree. Since $x\phi_r$ is monic of degree $r+1$,
$$
x\phi_r=\phi_{r+1}+\sum_{j=0}^ra_j\phi_j.
$$
For $j\leq r-2$, symmetry of multiplication by $x$ gives $(x\phi_r,\phi_j)=(\phi_r,x\phi_j)=0$, because $\deg(x\phi_j)<r$. Only $a_r$ and $a_{r-1}$ remain. Taking inner products with $\phi_r$ yields $a_r=(\phi_r,x\phi_r)/(\phi_r,\phi_r)$.

Similarly,
$$
a_{r-1}=\frac{(x\phi_r,\phi_{r-1})}{(\phi_{r-1},\phi_{r-1})}
=\frac{(\phi_r,x\phi_{r-1})}{(\phi_{r-1},\phi_{r-1})}
=\frac{(\phi_r,\phi_r)}{(\phi_{r-1},\phi_{r-1})},
$$
since $x\phi_{r-1}-\phi_r$ has degree at most $r-1$. Rearranging proves the <three-term recurrence for monic orthogonal polynomials>:
$$
\boxed{\phi_{r+1}=(x-a_r)\phi_r-
\frac{\|\phi_r\|_2^2}{\|\phi_{r-1}\|_2^2}\phi_{r-1}.}
$$