# Simple Fourier Series

$$f(x)=\begin{cases}\tfrac{1}{2a},& 0<|x|<a\\ 0,&\text{otherwise} \end{cases}$$

Note that $a<\pi$.

$$a_0=\frac{2}{a}\int_0^a \frac{1}{2a}dx=\frac{1}{a}$$

$$a_n=\frac{2}{a}\int_0^a \frac{1}{2a}\cos\left(\frac{n\pi x}{a}\right)dx=\frac{\sin(n\pi)}{an\pi}$$

There are no $b_n$ coefficients because the function is strictly even.

Hence the Fourier series representation is:

$$f(x)=\frac{1}{2a}+\sum_{n=1}^\infty \frac{\sin(n\pi)}{an\pi}\cos\left(\frac{n\pi x}{a}\right)$$

But the infinite series on the right collapses to zero, so something must be wrong here. Can someone help me out?

-
Nothing looks wrong. The coefficients you obtained for the Fourier series are $a_0={1\over a}$ and $a_n=b_n=0\,\forall\,n$. It just isn't a very interesting series... – Daryl Nov 13 '12 at 4:53

The answer depends on which Fourier series you are computing. Your above work is correct if the Fourier series you are computing is the Fourier series on the interval $(-a,a)$. This is because you are decomposing a function which is constant (on the interval in question) into sums of cosines and sines. As the function is constant, then all the Fourier coefficients vanish except the very first one, which is the constant term.
However, that is not the only Fourier series possible; if I were to have seen this problem at face value, I would've assumed that you are to compute the Fourier series on the interval $(-\pi, \pi)$. Since $a < \pi$, you'll see very different behavior, because you'll be integrating over a different region. In particular, you'll be integrating $$a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos(nx) \, dx$$ and similarly for $b_n$.
OK, I'm supposed to be on the interval $(-\pi, \pi)$. So what did I do wrong? – Alex Nov 13 '12 at 5:02
Wait. Isn't the function defined to be zero between a and pi? So effectively the integration is done in $(-a, a)$, no? – Alex Nov 13 '12 at 5:13
@Alex: yes the integration is effectively done over $(-a,a)$, but the functions you integrate are different: now you will have $\cos (n\pi)$ without the $a$ in the denominator. This will make the coefficients not come out zero. – Ross Millikan Nov 13 '12 at 5:18
OK, this time I got: $$f(x)=\frac{1}{2\pi}+\sum_{n=1}^\infty \frac{sin(an)}{\pi an} cos(nx)$$. Is that better? – Alex Nov 13 '12 at 5:27