# What are the Fourier series of the function?

What are the Fourier series of $f(x)$ where $x \in [-\pi, \pi]$ defined by

$$f(n) = \begin{cases} 1, & \text{if x \in [0,\pi)} \\ 0, & \text{if x \in [-\pi,0)} \\ \end{cases}$$

And what are the complex Fourier series?

My result is

$$\frac{\sqrt{2}}{2} + 2\sum_{n=0}^\infty \frac{\sin((2n+1)x)}{(2k+1)\pi}$$

and for the complex Fourier series

$$\frac{\sqrt{2}}{2} + \sum_{n=-\infty}^\infty \frac{-ie^{inx}}{n\pi}$$

• your answer is correct except for the constant term, which should be $1/2$. – Jonathan May 23 '13 at 15:08
• thanks, forgot to multiply by $\frac{1}{\sqrt{2}}$ – Rayhunter May 23 '13 at 15:13

As Jonathan said, your trigonometric series is correct except for the constant term and notational detail ($n$ versus $k$).
The exponential series is not correct, however. If you transform the sines to complex exponentials using $\sin t = \frac1{2i}(e^{it}-e^{-it})$, you will get only odd-indexed terms. Direct calculation confirms this: for $n\ne 0$ $$c_n = \frac{1}{2\pi}\int_0^\pi e^{-i nx}\,dx = -i \frac{1-(-1)^n}{2\pi n }$$ which is $-i/(\pi n )$ when $n$ is odd, and $0$ otherwise.