Originally Posted by

**Silverflow** Hey all,

I've been working on a question, and I was whether someone could go through my work and see where I went wrong.

The problem is:

Find the fourier series of the box function on the domain $\displaystyle [-\pi,\pi]$:

$\displaystyle f(x)=\left\{\begin{array}{cc}1,& |x|\leq \frac{\pi}{2}

\\0, & \frac{\pi}{2}\leq |x| \leq \pi \end{array}\right.$

I need to find the coefficients $\displaystyle A_m$ & $\displaystyle B_m$ for the fourier series on the domain $\displaystyle [-L,L]$ $\displaystyle \phi (x)=\frac{1}{2} A_0 + \displaystyle \sum _{m=1} ^{\infty}( A_m cos(\frac{m\pi x}{L})+B_m sin(\frac{m\pi x}{L}))$.

I can find the coefficients by using the following equations:

$\displaystyle A_m=\frac{1}{L}\int_{-L} ^L \phi (x) cos(\frac{m \pi x}{L})dx, m=0,1,2,...$ and

$\displaystyle B_m=\frac{1}{L}\int_{-L} ^L \phi (x) sin(\frac{m \pi x}{L})dx, m=1,2,...$

I decided, because the function is piecewise continuous, to complete the following integrals

$\displaystyle A_m=\frac{1}{\pi}\int_{-\frac{\pi}{2}} ^{\frac{\pi}{2}} \phi (x) cos(\frac{m \pi x}{\pi})dx$ and

$\displaystyle B_m=\frac{1}{\pi}\int_{-\frac{\pi}{2}} ^{\frac{\pi}{2}} \phi (x) sin(\frac{m \pi x}{\pi})dx$

Not from $\displaystyle -\pi$ to $\displaystyle \frac{-\pi}{2}$ and not from $\displaystyle \frac{\pi}{2}$ to $\displaystyle \pi$ as $\displaystyle \phi (x) = 0$ in these domains.

I find that $\displaystyle B_m=0$, and $\displaystyle A_m = \frac{2sin(m\pi )}{m \pi}$. I can find $\displaystyle A_0 =\frac{1}{\pi} \int_{-\frac{\pi}{2}} ^{\frac{\pi}{2}} dx= 1$.

Thus, my fourier series is the following:

$\displaystyle \phi (x) = \frac{1}{2} + \displaystyle \sum _{m=1} ^{\infty}( \frac{2sin(m\pi )}{m \pi} cos(m x))$.

The answer supplied is the following series.

$\displaystyle \phi (x)=\frac{1}{2}+\frac{2}{\pi} \displaystyle \sum _{m=1} ^{\infty}( \frac{(-1)^m}{2M+1} cos((2m+1) x)) $

I feel my solution can not be transformed into that solution. Is there something wrong with my working?

Thanks for your time.