Finding Fourier series of $\sin^2 x$ (STILL not clear - read comments)

I am attempting to do some sums on Fourier series, but need help with one calculation, after which I can proceed on my own.

The question is:

1. Find the Fourier series for f(x) = $\sin^2x$, on $[-\pi,\pi]$.

I can find $a_0$ by doing the following:

$$a_0=\frac 1{2\pi}\int_{-\pi}^{\pi}\sin^2xdx$$ It works out to be $1/2$.

Important: Is this method of finding $a_0$ correct?

Main question: How can I find $a_n$ (coefficients of cosine terms in the fourier series) for this function? I assume $b_n$ (coefficients of sine terms) does not exist, since this is an even function. I know that $a_n$ will only have a non-zero value for $n=2$, but can someone please show this with full working (all steps). Then I can proceed on my own with the other sums.

I would like to see how the fourier series leads to the answer $\frac 12 - \frac 12\cos(2x)$.

Thank you.

Let's try and find $a_n$. You know what the values of integrals like $\cos (nx)\cos (mx)$ are. Now, if only we could describe $\sin^2 x$ as a function of $\cos$'s we could solve the problem. Now use: $$\sin^2 x = 1 - \cos^2 x = \frac{1}{2}(\cos(2 x)-1)$$ And then you can easily see that other than the constant term ($n=0$), only the $n=2$ term is non-zero.
• Can you explain in further detail? I am not understanding what you mean exactly, please. How is it seen that only $a_n$ for n=2 is non-zero? – user119183 Jan 20 '14 at 18:59
• A small remark: not only the $n=2$ term but also the $n=0$ term is nonzero. – Giuseppe Negro Jan 20 '14 at 19:36
• @user119183 He's just using a trig identity on $\sin^2 x$ which happens to give him a Fourier series. – mathematician Jan 20 '14 at 19:53