[Math] Expansion in terms of legendre polynomial

legendre polynomialslegendre-symbol

Obtain the first three terms in the expansion of function in terms of legendre polynomial
F(x) in a series of the form
$$
F(x) = \sum_{k=0}^{\infty} A_k P_k(x)
$$
where
$$F(x)=\{\cos(x) \text{ for } 0 \le x \le \pi/2 \
$$$$0 \text{ for } \frac{\pi}{2} \le x \le \pi.\}
$$

What I know is I have to use legendre's expansion formula
i.e,$F(x) =\sum A_kP_k(x)$ where $-1≤x≤1$
But obviously I cannot use it directly because the range of $x$ differs. I have tried substituting $x=\cos(\theta)$ but no success so far.

Best Answer

Extended hint: As already noted in your almost identical question Legendre polynomials you should apply a linear transformation, because the Legendre polynomial have the orthogonality interval $[-1,1]$. With $x=\frac{\pi}{2}(t+1)$ and $t=\frac{2x}{\pi}-1,$ define $F(x)=:\tilde{F}(t).$ Now $\tilde{F}$ is defined on $[-1,1]$ and you can compute $$F(x)=\tilde{F}(t) = \sum A_k P_k(t)=\sum A_k P_k\left(\frac{2x}{\pi}-1\right)$$ with $$A_k=\frac{2k+1}{2}\int_{-1}^1 \tilde{F}(t) P_k(t) dt$$

If you use this approach and compute $A_0, \dots, A_3$, you get the following graphics with the original function $F(x)$ in red and the approximation in green: enter image description here