Chebyshev projection of a semicircle (source code)

= Chebyshev projection of a semicircle
{c}
{title2=$p_n(x)=\frac2\pi-\frac4\pi\sum_{m=1}^{\lfloor n/2\rfloor}\frac{T_{2m}(x)}{4m^2-1}$}

For weighted <least-squares polynomial in an orthogonal-polynomial basis> with weight $(1-x^2)^{-1/2}$ on $[-1,1]$, the projection of $\sqrt{1-x^2}$ onto <polynomials> of degree at most $n$ is the displayed sum. Put $x=\cos\theta$ to obtain $T_j(x)=\cos j\theta$ and $f(x)=\sin\theta$ on $[0,\pi]$. The constant coefficient is $2/\pi$, odd coefficients vanish, and the coefficient of $T_{2m}$ is $4/[\pi(1-4m^2)]$. For odd $n$ the optimal <polynomial> can have degree $n-1$.