# Expansion in terms of legendre polynomial

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.

## 1 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: • Hi. Thank you for your reply. I have a doubt though. The limits of F(x) as well as Ak should also change right? They should be the limits of t. Also the lower limit of t at x=-1 lies outside [-1,1] right? – Yash Chugh Sep 18 '17 at 14:38
• Yes of course, because your function is not defined for $x=-1$. The transformation associates $x=0 \leftrightarrow t=-1$ and $x=\pi \leftrightarrow t=1$. You should compute the expansion for $\tilde{F}(t), t\in[-1,1].$ – gammatester Sep 18 '17 at 15:08
• Wish I was eligible for up voting! I'll try this :) – Yash Chugh Sep 18 '17 at 15:23
• @yash-chugh: Added a picture for third order approximation. – gammatester Sep 18 '17 at 16:08
• Sorry for the highly delayed reply. I solved it and got an intuition through the graph. Thank you so much! – Yash Chugh Sep 22 '17 at 3:07