Fourier Expansion

A periodic function f(x) is defined by:

$f(n) = \begin{cases} {-x^2} & \textrm{ for - π < x ≤ 0} \\ x^2 & \textrm{ for 0 ≤ x < π } \\ \end{cases} \space , \space\space\space f(x+2π)=f(x)$

Determine the Fourier expansion for $f(x)$; $\space$ that is

$f(x) = \frac{a_0}{2} + \sum\limits_{n=1}^\infty a_n\space cos(nx) + \sum\limits_{n=1}^\infty b_n\space sin(nx)$ .

I had first found the needed coefficients $\space a_0 , \space a_n, \space b_n$ using their definitions:

$a_0 = \frac{1}{\pi} \space $$\int_{-\pi}^{\pi} f(x) \space dx$$$

$a_n = \frac{1}{\pi} \space $$\int_{-\pi}^{\pi} f(x) \space cos(nx)\space dx$$$

$b_n = \frac{1}{\pi} \space $$\int_{-\pi}^{\pi} f(x) \space sin(nx)\space dx$$$

I had to use integration by parts for $a_n$ and $b_n$. However $a_0$ was more straightforward to solve by just applying the piecewise function to the integral (no further integration techniques needed).

I kept getting $a_0 = 0$, $\space$ $b_n=0$, $\space$ $a_n=0$. I cannot spot an error in my calculations, could the Fourier expansion for the above piecewise function really be equal to zero? If so, is there a quicker way of determining that instead of evaluating the integrals only to notice to get a zero answer?

Your function is odd and the interval is symmetric about zero, so the $a_n$, including $a_0$, should indeed be zero. But the $b_n$ should not be zero. Something that might help: because $f$ and $\sin$ are both odd, $\int_{-\pi}^\pi f(x) \sin(nx) dx = 2 \int_0^\pi x^2 \sin(nx)$. You can calculate that with integration by parts.
• When I evaluated $2 $$\int_{0}^{\pi} x^2 \space sin(nx) dx$$$ I kept getting $2$$\int_{-\pi}^{\pi} f(x) \space sin(nx) dx$ instead of $\int_{-\pi}^{\pi} f(x) \space sin(nx) dx$. Are you certain the relation you stated holds? – mnmakrets Aug 12 '15 at 4:05
• @mnmakrets Yes. In detail, if $f$ and $g$ are both odd, then $\int_{-a}^a f(x) g(x) dx = \int_{-a}^0 f(x) g(x) dx + \int_0^a f(x) g(x) dx =- \int_a^0 f(-x) g(-x) dx + \int_0^a f(x) g(x) dx=-\int_a^0 f(x) g(x) dx + \int_0^a f(x) g(x) dx = 2 \int_0^a f(x) g(x) dx$. – Ian Aug 12 '15 at 10:45