Evaluating the Fourier coefficients of $abs(x)$ Let's get started:
$$\hat f(n) = \frac{1}{2\pi}\int_0^{2\pi} |x|e^{-inx} dx$$
since $|x|$ is an even function:
$$= \frac{1}{\pi}\int_0^{\pi} xe^{-inx} dx$$
Integration by parts yields:
$$e^{-inx}\Big|_0^{\pi} + \frac{1}{in} \int_0^\pi e^{-inx} dx = (-1)^n - 1 + \frac{1}{in} \left( \frac{(-1)^n}{-in} + \frac{1}{in} \right) \\ = (-1)^n - 1 + \frac{(-1)^n - 1}{n^2}$$
So if $n$ is even then $\hat f(n) = 0$. Otherwise:
$$\hat f(n) = \frac{1}{\pi} \left( -2 -\frac{2}{n^2} \right)$$
but that doesn't make sense since we know that $\hat f(n) \to 0$.
Where is my mistake? 
EDIT
it should be 
$$x e^{-inx}\Big|_0^{\pi} + \frac{1}{in} \int_0^\pi e^{-inx} dx = \frac{\pi e^{-in\pi}}{-in} + \frac{(-1)^n - 1}{n^2}$$
So $$\hat f(n) = \frac{1}{\pi} \left( \frac{(-1)^n}{-in} + \frac{(-1)^n - 1}{n^2} \right)$$
 A: Since $|x|$ is positive in $[0, 2 \pi]$, then
\begin{align}
\hat f(n) &= \frac{1}{2\pi} \, \int_0^{2\pi} |x|e^{-inx} \, dx \\
&= \frac{1}{2\pi} \, \int_{0}^{2\pi} x \, e^{-i n x} \, dx \\
&= \frac{1}{2\pi} \, \left[ \int_{0}^{\pi} x \, e^{-i n x} \, dx + \int_{\pi}^{2\pi} x \, e^{-i n x} \, dx \right] \\
&= \frac{1}{2\pi} \, \left[ \int_{0}^{\pi} x \, e^{-i n x} \, dx + \int_{0}^{\pi} (x+\pi) \, e^{-i n (x+\pi)} \, dx \right] \\
&= \frac{1}{2\pi} \, \int_{0}^{\pi} \left[ x + (-1)^{n} (x+\pi) \right]  \, e^{-i n x} \, dx \\ 
&= \frac{1}{2\pi} \, \left\{ \left[\frac{i}{n} \left(x + (-1)^{n} (x+\pi)\right) + \frac{1+ (-1)^{n}}{n^{2}}\right] \, e^{-i n x} \right\}_{0}^{\pi} \\
&= \frac{i \, (1 + (-1)^{n})}{2 \, n}  
\end{align}
This leads to
\begin{align}
\hat f(2n) &= \frac{i}{2n} \\
\hat f(2n+1) &= 0.
\end{align}
A: The first mistake is in :
$\frac{1}{2\pi}\int_0^{2\pi} |x|e^{-inx} dx = \frac{1}{\pi}\int_0^{\pi} xe^{-inx} dx\:\:\:$  since $|x|$ is an even function .
This is false because $\:e^{-inx}\:$ is not an even function.
The supposed equality is true if $\:n\:$ is even. It is false if $\:n\:$ is odd.
