Find the best approximation with Legendre polynomials Can you help me with this problem?
I have the Legendre polynomials $ψ_{k}(x):= \frac{k!}{(2k)!}\frac{d^k}{(dx^k)}(x^2-1)^k$.
They are orthogonal with respect to the $L^2$ scalar product on $[−1, 1]$.
I want to find an orthonormal basis of $span \left \{ψ_0, ψ_2  \right \}$ and of $span \left \{ψ_0, ψ_1, ψ_2  \right \}$.
And how can I calculate the best approximation of
$sin(x)$ with respect to the $L^2$ scalar product on $[−1, 1]$ and the calculated orthonormal basis?
 A: The Legendre polynomials are already orthogonal, so an orthonormal basis just needs to scale them to have norm $1$. $|\psi_n|^2 = 1/(n+1/2)$, so $\sqrt{n+1/2}\psi_n$ will be orthonormal. Thus, $\{\sqrt{2}\psi_0, \sqrt{5/2}\psi_2\}$ and $\{\sqrt{2}\psi_0, \sqrt{3/2}\psi_1, \sqrt{5/2}\psi_2\}$ will be the desired orthonormal bases.
As for approximating $\sin$, the best you're going to do for an orthonormal set $b_i$ is the orthogonal projection onto that set. That is, $\sum_i \langle \sin, b_i\rangle b_i$. Unfortunately for the first set, $\langle\sin, \psi_{2n}\rangle = 0$ for any integer $n$, so the best approximation of $\sin$ is $0$. The addition of $\psi_1$ makes things much better for the second set. The best approximation will be $\langle \sin, \sqrt{3/2}\psi_1\rangle \sqrt{3/2}\psi_1 = 3/2\langle \sin, \psi_1\rangle \psi_1$. Evaluating the inner product integral gives
$$
\int_{-1}^1 \sin(x) \psi_1(x) dx = \int_{-1}^1x\sin(x)dx = 2(\sin 1 - \cos 1)
$$
So the best approximation for $\sin$ in the second basis is $3(\sin 1 - \cos 1)\psi_1$. Which doesn't look too bad for a simple linear approximation.
