# Finding coefficients, Legendre polynomials.

Say I have a function

$f(\theta) = 1 + \cos^2(\theta)$

that can be expressed terms of the Legendre polynomials. When calculating coefficients should I change the Legendre polynomials from $x$ variables to theta variables? e.g. The third Legendre usually written:

$(0.5(3x^2-1))$ would have theta rather than $x$? (since my function is a function of theta not $x$).

If I am correct would it also make sense to then change the limits of integration $-1, 1$ to $-\pi, \pi...$

My third coefficient equation then looks like (sorry I don't know how to write this out correctly):

$c_3 = \frac52 \int_{-\pi} ^ \pi (1+\cos^2(\theta))(0.5(3\theta^2-1))d \theta$

Sorry if this is hard to read. Any help?

The answer depends on what you're seeking. Legendre polynomials $P(x)$ form an orthonormal basis on $[-1,1]$, so any nice function $f(x)$ on $[-1,1]$ can be written as a linear combination of them. Your $f(\theta)=1+\cos(\theta)^2$, while nice, will have a pretty awful expansion in terms of $P(\theta)$, but a much nicer expansion in terms of $P(\cos(\theta))$.
Most likely, the question asks you to expand in $P(\cos(\theta))$ because these are the basis functions on the unit circle for the Newtonian potential. To make your life easier, write $x=\cos(\theta)$ so you are trying to expand $1+x^2$ in terms of $P(x)$. Then yes you can compute the coefficients $c_i$ by taking inner products $\int_{-1}^1(1+x^2)P_n(x)dx$
• Right, and by the looks of it you won't need legendre polynomials past $n=2$. – Alex R. Apr 29 '15 at 17:55