# How to show this formula using a Fourier sine series expansion? $\sum _{k=1}^{\infty }\frac {\left( -1\right) ^{k-1}} {2k-1}=\frac {\pi } {4}$

$f(x)=\dfrac {1} {2}\left( \pi -x\right)$

Using the Fourier sine series expansion how to show following formula? (Range:$\left[ 0,\pi \right]$)

$$\sum\limits _{k=1}^{\infty }\dfrac {\left( -1\right) ^{k-1}} {2k-1}=\dfrac {\pi } {4}$$

To obtain the Fourier sine series expansion for $f(x)$ the coefficients $a_n$ must vanish (see below). So let $g(x)$ be the odd function extending $f(x)$ to the interval $[-\pi,0[$ defined by

\begin{equation*} g(x)=\left\{ \begin{array}{l} \phantom{-}f(x)&=\phantom{-}\dfrac{\pi -x}{2},\qquad \phantom{-}0\leq x\leq \pi \\ \\ -f(-x)&=\color{blue}{-\dfrac{\pi +x}{2}}\qquad -\pi \leq x<0 \end{array} \right. \end{equation*}

whose graph in $[\pi,\pi]$ is shown in the following figure

$$g(x)=f(x)=\frac{\pi -x}{2}, x\in[0,\pi[ ; \; g(x)=-f(-x)=\color{blue}{-\frac{\pi +x}{2}},x\in[-\pi,0]$$

We know that the trigonometric Fourier series expansion for $g(x)$ in the interval $\left[ -\pi ,\pi \right]$ is given by

\begin{equation*} \frac{a_{0}}{2}+\sum_{n=1}^{\infty }\left( a_{n}\cos (nx)+b_{n}\sin (nx)\right) , \end{equation*} where the coefficients are the integrals \begin{eqnarray*} a_{n} &=&\frac{1}{\pi }\int_{-\pi }^{\pi }g(x)\cos (nx)\,dx\qquad n=0,1,2,\ldots , \\ b_{n} &=&\frac{1}{\pi }\int_{-\pi }^{\pi }g(x)\sin (nx)\,dx\qquad n=1,2,3,\ldots . \end{eqnarray*} The integrand $g(x)\cos (nx)$ is an odd function, while $g(x)\sin (nx)$ is even. So $a_{n}=0$ and

\begin{equation*} b_{n}=\frac{2}{\pi }\int_{0}^{\pi }g(x)\sin (nx)\,dx=\frac{2}{\pi } \int_{0}^{\pi }\frac{\pi -x}{2}\sin (nx)\,dx. \end{equation*} Evaluating this last integral we obtain $b_{n}=\frac{1}{n}$, which proves that \begin{equation*} f(x)=\frac{\pi -x}{2}=\sum_{n=1}^{\infty }\frac{1}{n}\sin (nx),\qquad 0\leq x\leq \pi , \end{equation*} (the Fourier sine series for the function $f(x)$ in the interval $\left[ 0,\pi \right]$). We see that $f(\pi/2)=\pi/4$. We just need to confirm that for $x=\pi /2$ this last series reduces to your series. Indeed since \begin{equation*} \sin \big(\frac{n\pi }{2}\big)=\left\{ \begin{array}{l} 1,\qquad n=1,5,\ldots ,4k+1,\ldots \\ 0,\qquad n=2,4,\ldots ,2k+2,\ldots \quad (k=0,1,2,\ldots)\\ -1,\quad \;n=3,5,\ldots ,4k+3,\ldots, \end{array} \right. \end{equation*} we have \begin{equation*} \frac{\pi }{4}=\sum_{n=1}^{\infty }\frac{1}{n}\sin \big(\frac{n\pi }{2}\big)=1-\frac{1 }{3}+\frac{1}{5}-\frac{1}{7}+\ldots = \sum\limits _{k=1}^{\infty }\dfrac {\left( -1\right) ^{k-1}} {2k-1} . \end{equation*}

Remark. For a Fourier cosine series we would need to extend $f(x)$ to an even function instead, because then $b_n$ would vanish.

We have that $$\sum_{n\geq 1}\frac{\sin(nx)}{n}$$ is the Fourier sine series of a function that equals $\frac{\pi-x}{2}$ over the interval $(0,\pi)$.
If we evaluate such a series at $x=\frac{\pi}{2}$ we get that: $$\sum_{n\geq 1}\frac{\sin\left(\frac{\pi n}{2}\right)}{n}=\color{red}{\sum_{k\geq 1}\frac{(-1)^{k-1}}{2k-1}} = \frac{\pi-\frac{\pi}{2}}{2} = \color{red}{\frac{\pi}{4}}$$ as wanted. An alternative approach is to notice that $$\sum_{k=1}^{N}\frac{(-1)^{k-1}}{2k-1}=\sum_{k=1}^{N}(-1)^{k-1}\int_{0}^{1}x^{2k-2}\,dx = \color{blue}{\int_{0}^{1}\frac{dx}{1+x^2}}-(-1)^N\color{purple}{\int_{0}^{1}\frac{x^{2N}\,dx}{1+x^2}}$$ where the blue term equals $\color{blue}{\frac{\pi}{4}}$ and the purple term is $\color{purple}{O\left(\frac{1}{N}\right)}$.