Proving a trig infinite sum using integration

How can I prove the following using integration and elementary functions?

Prove that:

$$\sum_{n=1}^{\infty} \frac{\sin(n\theta)}{n} = \frac{\pi}{2} - \frac{\theta}{2}$$

$0 < \theta < 2\pi$


Let, $$S_1 = \sum_{n=1}^{\infty}\frac{\cos n\theta}{n}\\ S_2 = \sum_{n=1}^{\infty}\frac{\sin n\theta}{n}$$

Then $$S_1 + iS_2 = \sum_{n=1}^{\infty}\frac{\cos(n\theta)+i\sin(n\theta)}{n}=\sum_{n=1}^{\infty}\frac{e^{in\theta}}{n}$$

Now, from the Taylor expansion, $\ln (1+x) = x -\frac{x^2}{2}+\frac{x^3}{3} ...$ $$\implies -\ln(1-x) = x+ \frac{x^2}{2}+\frac{x^3}{3} ... = \sum_{n=1}^{\infty}\frac{x^n}{n}$$ $$\begin{align} \therefore S_1+iS_2 &= -\ln(1-e^{i\theta}) \\&=-\ln(1-\cos\theta-i\sin \theta) \\ &=-\ln(2\sin^2\theta/2 - 2i\sin(\theta/2)\cos(\theta/2)) \\ &=-\ln(2\sin\theta/2)-\ln(\sin\theta/2-i\cos\theta/2) \\ &=-\ln(2\sin\theta/2)+\ln(\sin\theta/2+i\cos\theta/2) \\ &=-\ln(2\sin\theta/2)+\ln(e^{i(\pi/2-\theta/2)}) \\ &=-\ln(2\sin\theta/2)+i(\pi/2-\theta/2) \end{align} $$

Taking the imaginary part of both sides, $$S_2 = \frac{\pi}{2} - \frac{\theta}{2}$$


In this answer, I show

$$ \begin{align} \sum_{k=1}^\infty\frac{\sin(2kx)}{k} &=\sum_{k=1}^\infty\frac{e^{i2kx}-e^{-i2kx}}{2ik}\\ &=\frac1{2i}\left(-\log(1-e^{i2x})+\log(1-e^{-i2x})\right)\\ &=\frac1{2i}\log(-e^{-i2x})\\[4pt] &=\frac\pi2-x\quad\text{for }x\in\left(0,\pi\right) \end{align} $$

which is, in essence, milind's answer. However, the question asks about integration. This sounds as if the question is asking to find the Fourier Series of $f(\theta)=\frac\pi2-\frac\theta2$. First, note that $f(\theta)$ is odd; that is, $$ \begin{align} f(2\pi-\theta) &=\frac\pi2-\frac{2\pi-\theta}2\\ &=\frac\theta2-\frac\pi2\\ &=-\left(\frac\pi2-\frac\theta2\right)\\[6pt] &=-f(\theta)\tag{1} \end{align} $$ Equation $(1)$ implies that $$ \begin{align} \color{#00A000}{\int_0^{2\pi}f(\theta)\cos(n\theta)\,\mathrm{d}\theta} &=\int_0^{2\pi}f(2\pi-\theta)\cos(n 2\pi-n\theta)\,\mathrm{d}\theta\\ &=-\color{#00A000}{\int_0^{2\pi}f(\theta)\cos(n\theta)\,\mathrm{d}\theta}\\[6pt] &=0\tag{2} \end{align} $$ because $\color{#00A000}{x}=-\color{#00A000}{x}\implies\color{#00A000}{x}=0$.

Now the question is $$ \begin{align} \int_0^{2\pi}f(\theta)\sin(n\theta)\,\mathrm{d}\theta &=\int_0^{2\pi}\left(\frac\pi2-\frac\theta2\right)\sin(n\theta)\,\mathrm{d}\theta\\ &=-\frac1n\int_0^{2\pi}\left(\frac\pi2-\frac\theta2\right)\,\mathrm{d}\cos(n\theta)\\ &=\left.-\frac1n\left(\frac\pi2-\frac\theta2\right)\cos(n\theta)\right]_0^{2\pi}\\ &\hphantom{=\,}+\frac1n\int_0^{2\pi}\cos(n\theta)\,\mathrm{d}\left(\frac\pi2-\frac\theta2\right)\\[4pt] &=\frac\pi{n}\tag{3} \end{align} $$ $(3)$ says that the Fourier series for $f(\theta)$ on $(0,2\pi)$ is $$ f(\theta)=\sum_{n=1}^\infty\frac{\sin(n\theta)}{n}\tag{4} $$


$$ I=\sum_{n=1}^\infty \frac{\sin(n\theta)}{n} $$ Now, \begin{align} \frac{dI}{d\theta} &= \sum_{n=1}^\infty \cos(n\theta)\\ \frac{dI}{d\theta}\cos(\theta)&=\sum_{n=1}^\infty \cos(n\theta)\cos(\theta)\\ &=\sum_{n=1}^\infty \frac{\cos((n-1)\theta)+\cos((n+1)\theta)}2\\ &=\sum_{n=0}^\infty \frac{\cos(n\theta)}{2}+\sum_{n=2}^\infty\frac{\cos(n\theta)}{2}\\ &=\frac{1}2+\sum_{n=1}^\infty \frac{\cos(n\theta)}{2}+\sum_{n=1}^\infty\frac{\cos(n\theta)}{2}-\frac{\cos(\theta)}2\\ &=\frac{1-\cos(\theta)}{2}+\frac{dI}{d\theta}\\ \frac{dI}{d\theta}(\cos(\theta)-1) &= -\frac{\cos(\theta)-1}{2}\\ \frac{dI}{d\theta} &= -\frac12 \end{align} Noting that $$ I(\pi) = \sum_{n=1}^\infty \frac{\sin(n\pi)}n = 0 $$ we integrate around $\theta=\pi$ to get $$ I = -\frac\theta2 + \frac\pi2 = \frac\pi2-\frac\theta2 $$ Note that this doesn't strictly require that the $\cos$ sum converges, as we may alter the summation process to obtain convergence. What is important is which terms may be extracted for the purposes of the integration.


There are two obvious ways to handle the nonconvergent nature of the sum for $\frac{dI}{d\theta}$.

Option 1: use $$I = \sum_{n=1}^\infty \frac{\sin(n\theta)}n z^n$$ and then take the limit as $z\to1^{-}$. For any $|z|<1$, the sum in the derivative will converge, and in the limit it will be $\frac12$.

Option 2: Change the order of summation. Let $$ I = \sum_{n=1}^\infty \frac{\sin(n\theta)}n \sum_{k=1}^\infty 2^{-k} $$ which is the same as multiplying by $1$. Now change the order of summation to $n+k=m$ first, as $$ I = \sum_{m=2}^\infty \sum_{k=1}^{m-1} \frac{\sin((m-k)\theta)}{m-k}2^{-k} $$ When summed in this order, the derivative converges.