Constructing a Fourier Series I need to find the Fourier series of 
$$
f(x)=\begin{cases}a,& 0<x<\frac{\pi}{3}\\ 0,&\frac{\pi}{3}<x<\frac{2\pi}{3}\\-a,& \frac{2\pi}{3}<x<\pi\\ \end{cases}
$$
$$
f(x)= a_0+\sum_{n=1}^{\infty}a_n\cos\frac{n\pi x}{L}+\sum_{n=1}^{\infty}b_n\sin\frac{n\pi x}{L},
$$
$$
a_0 = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) dx
$$
$$
a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)cos(nx)dx
$$
$$
b_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)sin(nx)dx
$$
I found That An and A0 are both equal to 0 which meant i only had Bn to find
$$
b_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)sin(nx)dx
$$
$$
b_n = \frac{1}{\pi} \int_{0}^{\frac{\pi}{3}} asin(nx)dx + \frac{1}{\pi} \int_\frac{2\pi}{3}^{{\pi}} -asin(nx)dx
$$
$$ 
b_n =  \frac{a}{n\pi}\left[-\cos(nx)\right]_0^{\frac{\pi}3} + \frac{a}{n\pi}\left[\cos(nx)\right]_\frac{2\pi}3^{\pi}
$$
When n is odd
$$
b_n = 0 
$$
When n = 2 , 4
$$ 
b_n =  \frac{a}{n\pi}\left[1-\cos(n\frac{\pi}{3}) + \cos(n\pi) -\cos(\frac{2n\pi}{3})\right]
$$
$$ 
b_n =  \frac{3a}{n\pi}
$$
When n = 6 bn = 0
So this gives me a Fourier Series of
$$
f(x)=\frac{3a}{\pi}\left[\frac{1}{2}\sin(2x)+\frac{1}{4}\sin(4x)+\frac{1}{8}\sin(8x)....  \right]
$$
But the book has a solution of 
$$
f(x)=\frac{3a}{\pi}\left[\sin(2x)+\frac{1}{2}\sin(4x)+\frac{1}{4}\sin(8x)....  \right]
$$
Not sure where im going wrong !
 A: The standard Fourier series is on an interval of length $2\pi$, whereas your problem is posed on $[0,\pi]$. $L$ has to figure into the coefficients, which you can see just by looking at the constant term.
In other words, if you are going to expand $f$ on $[0,\pi]$, then the standard expansion will involve a constant, and $\sin(2nx)$, $\cos(2nx)$. Assuming you have such an expansion
$$
                 f(x) = a_{0} + \sum_{n=1}^{\infty} a_{n}\cos(2nx)+\sum_{n=1}^{\infty}b_{n}\cos(2nx),
$$
then you multiply by one of these functions, on both sides, integrate over $[0,\pi]$, use the fact that the integrals of unlike terms are zero, in order to obtain
$$
\begin{align}
 \int_{0}^{\pi}f(x)dx & = a_{0}\int_{0}^{\pi}dx =\pi a_{0}\\
 \int_{0}^{\pi}f(x)\cos(2nx)dx & = a_{n}\int_{0}^{\pi}\cos^{2}(2nx)\,dx=a_{n}\frac{\pi}{2},\;\;\; n > 0,\\
 \int_{0}^{\pi}f(x)\sin(2nx)dx & = b_{n}\int_{0}^{\pi}\sin^{2}(2nx)\,dx=b_{n}\frac{\pi}{2}.
\end{align}
$$
The values of integrals of $\sin^{2}$ and $\cos^{2}$ are easily determined: both types of integrals are over a full period and, so must be equal; and $\sin^{2}(2nx)+\cos^{2}(2nx)=1$, which means that the integrals of $\sin^{2}$ and $\cos^{2}$ are half of the period (period=$\pi$, so integrals of $\sin^{2}$ and $\cos^{2}$ are $\pi/2$.) So your series becomes
$$
\begin{align}
   f(x)  & \sim \frac{1}{\pi}\int_{0}^{\pi}f(x)\,dx + \\
         & + \sum_{n=1}^{\infty}\left(\frac{2}{\pi}\int_{0}^{\pi}f(x)\cos(2nx)\,dx\right)\cos(2nx) \\
         & +\sum_{n=1}^{\infty}\left(\frac{2}{\pi}\int_{0}^{\pi}f(x)\sin(2nx)\,dx\right)\sin(2nx).
\end{align}
$$
The normalization constants $\frac{2}{\pi}$ and ${1}{\pi}$ come from dividing by the integrals of the squares of $1$, $\sin(2nx)$ and $\cos(2nx)$.
Your function $f$ is $a$ times a part which is odd about the $x=\pi/2$. The $\sin$ terms are odd about $x=\pi/2$ and the $\cos$ terms are even about $x=\pi/2$. That helps simplify. The cosine terms require integrating only the part of $f$ which is even about $x=\pi/2$, while the sine terms require integrating only the part of $f$ which is odd about $x=\pi/2$. So the $\cos$ terms drop out. In this particular case, you need only integrate the correct part over $[0,\pi/2]$ and double the value. So,
$$
     a_{n} = 0,\;\; b_{n}=2a\int_{0}^{\pi/3}\sin(2nx)\,dx.
$$
