Expand the following function in Legendre polynomials on the interval [-1,1] :
$$f(x) = |x|$$
The Legendre polynomials $p_n (x)$ are defined by the formula :
$$p_n (x) = \frac {1}{2^n n!} \frac{d^n}{dx^n}(x^2-1)^2$$
for $n=0,1,2,3,...$
My attempt :
we have using the fact that $|x|$ is an even function. $$a_0 = \frac {2}{\pi}$$ $$ a_n= \frac {2}{π} \int_{-1}^{1}x\cos(nx)\,dx$$
Then what is the next step ?
You are being asked to compute the coefficients $a_n$ in the expansion
$$ f(x)=\sum_{n=0}^\infty a_n P_n(x) $$
See for example here for more information.
Another very useful reference (in general) is Abramowitz and Stegun's Handbook of Mathematical Functions where you will find chapters on Legendre functions and orthogonal polynomials.