Summation of Fourier Coefficients in Fourier Series Problem First poster!
I have been posed with a problem that is to find the Fourier Series of the periodic function
$$f(x) =
\begin{cases}
0,  & -\pi < x < 0 \\
1, & 0<x<\frac{\pi}{2}\\
0, &\frac{\pi}{2}<x<\pi
\end{cases}$$
$$f(x) = f(x+2\pi)$$
I have found
$$
a_0 = \frac{1}{4},
$$
$$
a_n = \frac{1}{n\pi}\sin\left({n\frac{\pi}{2}}\right),
$$
$$
b_n = \frac{-1}{n\pi}\cos\left({n\frac{\pi}{2}}\right)-1
$$
At the moment my final answer for the problem is
$$
F.S f = \frac{1}{4}+\sum_{n=1}^\infty \left(\left(\frac{1}{n\pi}\sin\left({n\frac{\pi}{2}}\right)\right)\cos(nx)+\left(\frac{-1}{n\pi}\cos\left({n\frac{\pi}{2}}\right)-1\right)\sin(nx)\right)
$$
I realize, for example, for $a_n$: 
For every odd integer of $n$, $\sin\left({n\frac{\pi}{2}}\right) = 1$, but every second odd integer results in $-1$. My question is how would I represent this pattern in the Fourier Series without including
$\sin\left({n\frac{\pi}{2}}\right)$ in the $a_n$ coefficient, an the same for the $b_n$ coefficient. 
How do I simplify this?
Is this a valid answer whether there is or is not a way to simplify it?
Thanks everyone
 A: What you have looks fine, and I likely wouldn't bother trying to simplify it at all (unless you want to take Spencer's suggestion and work with complex numbers).  That being said, one might note that the angle addition formula for the sine function might allow some moderate simplification.  Recall that
$$ \sin(\alpha + \beta) = \cos(\alpha)\sin(\beta) + \cos(\beta)\sin(\alpha) $$
for all $\alpha$ and $\beta$.  With $\alpha = -nx$ and $\beta = \frac{n\pi}{2}$, we obtain
$$ \cos(nx) \sin\left( \frac{n\pi}{2} \right) - \cos\left(\frac{n\pi}{2}\right) \sin(nx)
= \sin\left( -nx + \frac{n\pi}{2} \right)
= \sin\left(n\left(\frac{\pi}{2}-x\right)\right).$$
Your series then becomes
\begin{align}
&\frac{1}{4}+\sum_{n=1}^\infty \left[\left(\frac{1}{n\pi}\sin\left({n\frac{\pi}{2}}\right)\right)\cos(nx) + \left(\frac{-1}{n\pi}\cos\left( {n\frac{\pi}{2}}\right) - 1 \right)\sin(nx)\right] \\
&\qquad\qquad= \frac{1}{4}+\sum_{n=1}^\infty \left[ \frac{1}{n\pi} \left( \cos(nx)\sin\left({n\frac{\pi}{2}}\right) - \cos\left(\frac{n\pi}{2}\right) \sin(nx) \right) - \sin(nx) \right]\\
&\qquad\qquad= \frac{1}{4} + \sum_{n=1}^{\infty} \left[ \frac{1}{n\pi} \sin\left( n\left(\frac{\pi}{2}-x\right) \right) - \sin(nx) \right].
\end{align}
I'm not sure that this is any simpler, really, but it is correct (at least, assuming that your derivation tis correct) and it eats up slightly less ink.
On the other hand, I am slightly worried about your derivation.  Are you sure that you completed the Fourier coefficients correctly?  When I plot the 50th partial sum, I get the following:

Your function is piecewise continuous, hence the Fourier series converges pointwise, and should converge to $\chi_{[0,\frac{\pi}{2}]}$ (i.e. the characteristic function of the interval $[0,\frac{\pi}{2}]$, i.e. the "box" you initially described) almost everywhere.  I don't see the sums converging nicely...  Indeed, you have a bunch of terms that, taken together, look like $\sum \sin(nx)$.  Since $\sin(nx)$ is 1 quite a lot, this is going to cause some major problems for you as $n$ goes to infinity.  I would encourage you to check your work.

There is definitely an error in your derivation of the Fourier coefficients.  For $n=0$ I get $c_0 = \frac{1}{4}$, and for $n \ne 0$ I get the (complex) Fourier coefficients
\begin{align}
c_n
&= \frac{1}{2\pi} \int_{0}^{2\pi} \chi_{[0,\frac{\pi}{2}]}(x) \mathrm{e}^{-inx}\,\mathrm{d}x \\
&= \frac{1}{2\pi} \int_{0}^{\frac{\pi}{2}} \mathrm{e}^{-inx}\,\mathrm{d}x \\
&= \frac{1}{2\pi in} \left( 1 - \mathrm{e}^{-\frac{in\pi}{2}} \right).
\end{align}
This then gives us
\begin{align}
f(x)
\sim \frac{1}{4} + \sum_{n=-\infty}^{\infty} \frac{1}{2\pi in} \left( 1 - \mathrm{e}^{-\frac{in\pi}{2}} \right) \mathrm{e}^{inx}
&= \frac{1}{4} + \sum_{n=-\infty}^{\infty} \frac{1}{2\pi in} \left( \mathrm{e}^{inx} - \mathrm{e}^{inx-\frac{in\pi}{2}} \right) \\
&= \frac{1}{4} + \sum_{n=1}^{\infty} \frac{1}{2\pi i n} \left( \left(\mathrm{e}^{inx} - \mathrm{e}^{-inx} \right) - \left( \mathrm{e}^{in(x-\frac{\pi}{2})} - \mathrm{e}^{in(x-\frac{\pi}{2})} \right) \right) \\
&= \frac{1}{4} + \sum_{n=1}^{\infty} \frac{1}{n\pi} \left( \sin(nx) - \sin\left( n\left(x-\frac{\pi}{2}\right) \right) \right).
\end{align}
Modulo the (expected) Gibbs phenomenon, I'd say this looks pretty good:

