Easy Fourier series example: where is my mistake? I'm doing exercise 15 on page 255 in Kreyszig:


*

*To illustrate that a Fourier series of a function $f$ may converge even at a point where $f$ is discontinuous, find the Fourier series of


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

My solution:
(i) For the $n$-th character, $n \in \mathbb N$, we compute the $n$-th coefficient as follows:
$$ \hat{f}(e^{inx}) =  \langle f, e^{inx} \rangle = \int_0^\pi e^{-inx} dx = \frac{i}{n}(e^{in \pi} - 1)$$
(ii) For the $-n$-th character we compute 
$$\hat{f}(e^{inx}) = \langle f, e^{-inx} \rangle = \frac{-i}{n}(e^{in \pi}-1)$$
(iii) For the $0$-character $e^{i0x} = 1$ we compute
$$\hat{f}(e^{i0x}) = \langle f, e^{-i0x} \rangle = \int_0^\pi 1 dx = \pi$$
So that the Fourier series of $f$ is
$$ F(f(x)) = \pi , \hspace{1cm} x \in [-\pi, \pi)$$
Which is clearly wrong. What did I do wrong? Thanks for your help.
 A: @AD. gave the usual formula for the Fourier series.
The Fourier coefficients are $\hat{f}_0 = \frac{1}{2}$, and $\hat{f}_n = - \frac{1}{2 i \pi n} (e^{-in \pi} -1) = \frac{1}{2 i \pi n} (1-(-1)^n)$, for $n \neq 0$. So, for $n\neq 0$, only the odd coefficients are non zero.
Now let
$\phi(x) = f_0 + \sum_{n>0} f_n e^{inx} + f_{-n} e^{-inx} = \frac{1}{2} + \sum_{n>0,\, n\ \mathbb{odd}} \frac{2}{2 i \pi n}(e^{inx}-e^{-inx})$. Continuing gives $\phi(x) = \frac{1}{2} + \frac{2}{\pi} \sum_{n>0,\, n\ \mathbb{odd}} \frac{\sin nx}{n} $. This is the Fourier series of the periodic step function, and converges to $f(x)$ at all points except for $x=0,\pi$, where it converges to the average of the right and left limits of $f$ (inasmuch as left and right make sense in a periodic setting!).
A: I think you missed some point in the definition.
The definition of the Fourier coefficient of a function $f$ defined on $[-\pi,\pi]$ with respect to $x\mapsto e^{inx}$ where $n\in\mathbb{Z}$ is given by
$$\hat{f}(n)=\frac{1}{2\pi}\int_{-\pi}^\pi f(x)e^{-inx}dx$$
and the Fourier series of $f$ is then given by 
$$f(x) \sim\sum_{n\in\mathbb{Z}} \hat{f}(n)e^{inx}.$$
The normalizing constant $\frac{1}{2\pi}$ is needed in order for $n\mapsto e^{inx}$ to be an ON-basis (otherwise they will not have norm 1).
Please, go through your calculations with the above in mind.
A: I re-computed the Fourier series:
$$ a_0 = \langle f, e^{-i0} \rangle = \frac{1}{2 \pi} \int_0^\pi 1 dx = \frac12$$
$$ a_n = \frac{1}{2 \pi} \int_0^\pi e^{-inx} dx = \frac{1}{2 \pi} \left [ \frac{i}{n} e^{-inx} \right ]_0^\pi$$
If $n$ is even: $a_n = \frac{1}{2 \pi}(\frac{i}{n} - \frac{i}{n}) = 0$
If $n$ is odd: $a_n = \frac{1}{2 \pi}(\frac{i}{n}(-1) - \frac{i}{n}) = \frac{-i}{2 \pi n}$
So that 
$$ f(x) = \sum_{k=-\infty}^\infty \frac{-i}{2 \pi (2k + 1)} e^{(2k + 1)ix}$$
and hence 
$$ |f(x)| \leq \frac{1}{2 \pi } \sum_{k=-\infty}^\infty \frac{1}{ (2k + 1)} = 0$$
So that the Fourier series converges at $0$ absolutely. 
