Determine the coefficient for fourier sine series of f(x) = cos ${\pi x\over L}$ Determine the coefficient for  Fourier sine series of f(x) = cos  ${\pi x\over L}$
I know how to solve it but I get stuck at the end.
$$B_n = \int_{0}^{L} \cos\frac{\pi x}{L} \, \sin\frac{n\pi x}{L}$$
We use the identity  $$\sin a \, \cos b=\frac{1}{2}  \left(\sin(a+b)+ \sin(a−b) \right).$$
 I solved it twice and I always end up with $$ \frac {-(n+1)-(n-1)}{(n^2 -1)\pi } (\cos{(n-1)\pi x\over L} + \cos{(n+1)\pi x\over L})$$
The solution in the book has the end result which is 
0 if n odd
$\frac{4n}{\pi(n^2 -1)}$ if n even But I cant seem to figure out how even after i Substitue 0 and L
 A: Consider 
\begin{align}
B_{n} = \frac{2}{L} \int_{0}^{L} \cos\left( \frac{\pi x}{L} \right) \sin\left( \frac{n \pi x}{L} \right) \, dx.
\end{align}
For the case $n=1$ it is seen that
\begin{align}
B_{1} &= \frac{1}{L} \int_{0}^{L} \sin\left( \frac{2 \pi x}{L} \right) \, dx \\
&= \frac{1}{L} \left[ - \frac{L}{2 \pi} \cos\left( \frac{2 \pi x}{L} \right) \right]_{0}^{L} \\
&= 0.
\end{align}
Now, for $n > 1$ it is seen that
\begin{align}
B_{n} &= \frac{1}{L} \int_{0}^{L} \left(\sin\left(\frac{(n+1) \pi x}{L}\right) + \sin\left(\frac{(n-1)\pi x}{L} \right) \right) \, dx \\
&= \frac{-1}{L} \left[ \frac{L}{(n+1) \pi} \cos\left( \frac{(n+1)\pi x}{L} \right) + \frac{L}{(n-1) \pi} \cos\left( \frac{(n-1) \pi x}{L} \right) \right]_{0}^{L} \\
&= - \left[ \frac{\cos(n+1)\pi - 1}{(n+1) \pi } + \frac{\cos(n-1)\pi -1}{(n-1) \pi } \right] \\
&= \frac{(-1)^{n} +1}{\pi} \left[ \frac{1}{n+1} + \frac{1}{n-1} \right] \\
&= \frac{ 2 (1 + (-1)^{n}) \, n}{(n^{2} -1) \pi}. 
\end{align}
The sine series then becomes
\begin{align}
\cos\left( \frac{\pi x}{L} \right) &= \sum_{n=1}^{\infty} B_{n} \, \sin\left( \frac{n \pi x}{L} \right) \\
&= B_{1} \sin\left( \frac{\pi x}{L} \right) + \sum_{n=2}^{\infty} B_{n} \, \sin\left( \frac{n \pi x}{L} \right) \\
&= \frac{2}{\pi} \sum_{n=2}^{\infty} \frac{(1+(-1)^{n}) \, n}{n^{2} -1} \, \sin\left( \frac{n \pi x}{L} \right) \\
&= \frac{8}{\pi} \sum_{n=1}^{\infty} \frac{n}{4 n^{2} -1} \, \sin\left( \frac{2 n \pi x}{L} \right).
\end{align}
A: So your function is $f(x)=\left|\cos\frac{\pi x}{L}\right|$ with period $L$.
Note that $\cos k\pi=(-1)^k$.
A: You should be able to see that
$$ b_n  = \frac{2}{L}\int_{0}^{L} \cos\left(\frac{\pi x}{L}\right)\sin\left(\frac{n\pi x}{L}\right)dx = \frac{2n((-1)^n+1)}{\pi(n^2-1)} $$
which gives the Fourier series
$$ f(x)=\sum_{n=1}^{\infty} b_n\sin\left(\frac{n\pi x}{L}\right).$$
Note that $a_n=0$.
