Polynomial approximation to a step function

145 Views Asked by At

Approximation to the function $f(x)$ by a second degree polynomial $$ f(x)=\begin{cases}-1\quad,\quad-1\leq x<-1/2\\1\quad,\quad-1/2\leq x<0\\-1\quad,\quad0\leq x<1/2\\1\quad,\quad1/2\leq x<1\end{cases} $$ Using the inner product $\int_{-1}^{+1}fg.dx=<f,g>$

My Attempt

Using the first 3 Legendre polynomials $p_0(x)=1,p_1(x)=x,p_2(x)=\frac{1}{2}(3x^2-1)$ the function can be approximated as $f(x)=\sum_{k=0}^\infty A_kp_k(x)$ where $A_k=\frac{2k+1}{2}\int_{-1}^{+1}p_k(x)f(x)dx $

$A_k=0$ for all k in our case. So looks like the best polynomial approximation to the function is $f(x)=0$.

Is it the best possible solution ? Or is there a better approach to this ?