Find the function given its Fourier series I am solving an exercise in which I'm asked to show that
$$1=\frac{4}{\pi}\sum_{n=1}^\infty{\frac{\sin((2n-1)x)}{2n-1}}, 0<x<\pi$$
I am considering solving this exercise by finding the function given by this sum, but I am pretty sure there is a more elegant solution.
Thanks!
 A: Hint: Calculate the Fourier Series of 
$$f(x) =\left\{ \begin{array}{c c} 1 & \mbox{ if } 0 \leq x \leq  \pi \\
-1 & \mbox{ if } -\pi \leq x \leq  0
\end{array} \right.$$
A: We may consider tha meromorphic function $f(z)=\frac{1}{1-z^2}$. This function has simple poles at $z=\pm 1$, but it is a holomorphic function over the region $\left\{z:\left|\text{arg}\,z\right|\geq\varepsilon, \left|\pi-\text{arg}\,z\right|\geq\varepsilon\right\}$, for instance. It follows that for any $x\in(0,\pi)$
$$\begin{eqnarray*} \int_{0}^{e^{ix}}f(z)\,dz &=& \int_{0}^{i}f(z)\,dz + \int_{i}^{e^{ix}}f(z)\,dz\\ &=&\frac{i\pi}{4}+\int_{\pi/2}^{x}\frac{i e^{i\theta}}{1-e^{2i\theta}}\,d\theta\\&=&\frac{i\pi}{4}+\frac{1}{2}\int_{x}^{\pi/2}\frac{d\theta}{\sin\theta}\end{eqnarray*} $$
and in particular the imaginary part of the integral equals $\frac{\pi}{4}$. On the other hand, as soon as $z$ lies in the previous region and in $\|z\|\leq 1$,
$$ f(z) = 1 + z^2 + z^4 + \ldots\qquad \int_0^z f(t)\,dt = z+\frac{z^3}{3}+\frac{z^5}{5}+\ldots $$
hence by considering $z=e^{ix}$ and switching to the imaginary parts:
$$ \sum_{n\geq 1}\frac{\sin((2n-1)x)}{2n-1}=\frac{\pi}{4}$$
as wanted. By considering the real parts, instead, we get:
$$ \forall x\in(0,\pi),\qquad \sum_{n\geq 1}\frac{\cos((2n-1)x)}{2n-1}=-\frac{1}{2}\log\tan\frac{x}{2}.$$

Unrelated, but interesting consequence: the functions $\frac{\pi}{2}$ and $-\log\tan\frac{t}{2}$ have the same $L^2$ norm over $(0,\pi)$, hence:
$$\begin{eqnarray*}\frac{\pi^3}{4}=\int_{0}^{\pi}\log^2\tan\left(\frac{t}{2}\right)\,dt &=& 2\int_{0}^{+\infty}\frac{\log^2(u)}{1+u^2}\,du=4\int_{0}^{1}\frac{\log^2(u)}{1+u^2}\,du\end{eqnarray*}$$
and since $\int_{0}^{1}u^{2k}\log^2(u)\,du = \frac{2}{(2k+1)^3}$,
$$\frac{\pi^3}{32}=\sum_{k\geq 0}\frac{(-1)^k}{(2k+1)^3},\qquad \frac{\pi}{2}\sum_{n\geq 0}\frac{1}{(2n+1)^2}=\frac{\pi^3}{16},$$
finding both the value of $\zeta(2)$ and the first case of this identity.
A: let $$f(x)=\sum_{n=1}^\infty \frac{ \sin((2n-1)x ) }{2n-1}
$$
It would suffice to show that $f'(x)=0$ and $f(\frac\pi 2)=\frac\pi 4$
$$f'(x)=\sum_{n=1}^\infty \cos((2n-1)x  )
$$
$$ f(\frac\pi 2)= \sum_{n=1}^\infty \frac{ \sin((2n-1) \frac\pi 2 ) }{2n-1}= \sum_{n=1}^\infty \frac{ (-1)^{n-1}  }{2n-1} =\tan^{-1}(1)$$
A: 
I thought it might be instructive to present a way forward without appealing to Fourier Series, but rather to using the "Feynman-like Trick" for differentiating under the series.  To that end, we proceed.

First, we let $f(\lambda)$ be represented by the series
$$f(\lambda)=\sum_{n=1}^\infty \lambda^{2n-1}\frac{e^{i(2n-1)x}}{2n-1} \tag 1$$
for $\lambda<1$.  Note that $\frac4\pi \text{Im}(f(1))=\frac4\pi \sum_{n=1}\frac{\sin((2n-1)x)}{2n-1}$.
Next, for $\lambda \le r<1$, the series formed by differentiating term-by-term  the series in $(1)$ converges uniformly.  Therefore, we find 
$$\begin{align}
f'(\lambda)&=\frac{1}{\lambda}\sum_{n=1}^\infty (\lambda e^{ix})^{2n-1}\\\\
&=\frac{1}{\lambda}\frac{1}{1-\lambda^2e^{i2x}} \tag 2
\end{align}$$
for $\lambda \le r<1$.
Then, integrating $(2)$ and using $f(0)=0$ reveals
$$f(\lambda)=\frac12\log\left(\frac{1+\lambda e^{ix}}{1-\lambda e^{ix}}\right) \tag 3$$
for $\lambda \le r<1$.
Finally, letting $\lambda \to 1$ in $(3)$, we obtain
$$\frac4\pi\sum_{n=1}^\infty \frac{\sin((2n-1)x)}{2n-1}=\frac4\pi \text{Im}(f(1))=1$$
as was to be shown!
