# Integrating $\int_0^{\pi/2} \frac{\sin^2 ax}{\sin^2 x}\,dx$

I am looking for ways to evaluate:

$$\int_0^{\pi/2} \frac{\sin^2 ax}{\sin^2 x}\,dx$$

where, $a$ is any positive real-number. (Real-analytic or complex integration techniques, either will do.)

Sidenote to down/close votes: It was discussed in SE chat room 36 yesterday (incase you haven't checked robjohn's comment) and I decided to post it on main so that robjohn can share his awesome solution!

• Could you link the chat room where related discussion exists? – choco_addicted Mar 17 '16 at 2:39
• @choco_addicted check around the messages here :) – r9m Mar 17 '16 at 15:35

## 4 Answers

We will use $$H(x)=\sum_{k=1}^\infty\left(\frac1k-\frac1{k+x}\right)\tag{1}$$ which Is the standard analytic extension of the Harmonic Numbers. \begin{align} &\int_0^{\pi/2}\frac{\sin^2(ax)}{\sin^2(x)}\,\mathrm{d}x\tag{2}\\ &=\frac12\int_{-\pi/2}^{\pi/2}\frac{\left(e^{iax}-e^{-iax}\right)^2}{\left(e^{ix}-e^{-ix}\right)^2}\,\mathrm{d}x\tag{3}\\ &=\frac1{4i}\int_{-\pi}^\pi\frac{\left(e^{iax}-1\right)^2}{\left(e^{ix}-1\right)^2}e^{-iax}\,\mathrm{d}e^{ix}\tag{4}\\ &=\frac1{4i}\int_\gamma\frac{z^a-2+z^{-a}}{\left(z-1\right)^2}\,\mathrm{d}z\tag{5}\\ &=\frac1{4i}\int_0^1\frac{t^a\left(e^{-\pi ia}-e^{\pi ia}\right)+t^{-a}\left(e^{\pi ia}-e^{-\pi ia}\right)}{\left(t+1\right)^2}\,\mathrm{d}t\tag{6}\\ &=\frac{\sin(\pi a)}2\int_0^1\frac{t^{-a}-t^a}{\left(t+1\right)^2}\,\mathrm{d}t\tag{7}\\ &=\frac{\sin(\pi a)}2\sum_{k=0}^\infty(-1)^k(k+1)\int_0^1\left(t^{k-a}-t^{k+a}\right)\,\mathrm{d}t\tag{8}\\ &=\frac{\sin(\pi a)}2\sum_{k=0}^\infty(-1)^k(k+1)\left(\frac1{k+1-a}-\frac1{k+1+a}\right)\tag{9}\\ &=\frac{\sin(\pi a)}2\sum_{k=0}^\infty(-1)^ka\left(\frac1{k+1-a}+\frac1{k+1+a}\right)\tag{10}\\ &=\frac{a\sin(\pi a)}2\sum_{k=1}^\infty\left(\frac1{2k-1-a}-\frac1{2k-a}+\frac1{2k-1+a}-\frac1{2k+a}\right)\tag{11}\\[3pt] &=\frac{a\sin(\pi a)}4\left(-H\left(\frac{-1-a}2\right)+H\left(\frac{-a}2\right)-H\left(\frac{-1+a}2\right)+H\left(\frac{a}2\right)\right)\tag{12}\\[6pt] &=\frac{a\sin(\pi a)}4\left(-\psi\left(\frac{1-a}2\right)+\psi\left(\frac{-a}2\right)-\psi\left(\frac{1+a}2\right)+\psi\left(\frac{a}2\right)\right)\tag{13} \end{align} Explanation:
$\phantom{1}(3)$: $\sin(x)=\frac{e^{ix}-e^{-ix}}{2i}$
$\phantom{1}(4)$: substitute $x\mapsto x/2$
$\phantom{1}(5)$: $z=e^{ix}$ and $\gamma$ is a ccw unit circle and the negative real axis is a branch cut
$\phantom{1}(6)$: collapse the contour onto the negative real axis
$\phantom{(10)\text{:}}$ set $\color{#C00000}{z=te^{-i\pi}}$ below and $\color{#00A000}{z=te^{i\pi}}$ above the axis
$\phantom{1}(7)$: $\sin(x)=\frac{e^{ix}-e^{-ix}}{2i}$
$\phantom{1}(8)$: apply the power series for $\frac1{(1+x)^2}$
$\phantom{1}(9)$: integrate
$(10)$: algebra
$(11)$: separate the positive and negative terms
$(12)$: apply $(1)$
$(13)$: $H(x)=\gamma+\psi(1+x)=\gamma+\psi(x)+\frac1x$

• May I give a qualifier to this answer ? beautiful is probably an understatement. Thanks. – Claude Leibovici Mar 16 '16 at 7:37
• Thanks. This question had been discussed in chat yesterday. This is how I was able post the answer so quickly. – robjohn Mar 16 '16 at 7:52
• Beautiful answer! (+1) it is not easy to find an alternative solution i have to admit! – tired Mar 16 '16 at 8:20
• i found a way without contour integration, but the resulting sums are the same so i think it's necessary to put it in an answer – tired Mar 16 '16 at 20:31
• @tired: please do! Contour Integration is a powerful tool, but it is not the only way to do things. – robjohn Mar 16 '16 at 20:51

I think i found a way to tackle this integral which is a little bit different from @robjohn's nice answer. To get started we note the following simple algebraic indentity

$$\frac{1}{\sin^2(x)}=\frac{-4}{(e^{i x}-e^{-i x})^2}=\frac{-4 e^{2 ix}}{(e^{i x}-1)^2}=-2 i\partial_x\frac{1}{e^{2 ix}-1}$$

we therefore may rewrite the integral as

$$I(a)=-2i\int_0^{\pi/2}\sin^2(a x)\left(\partial_x\frac{1}{e^{2 ix}-1}\right)$$

this is now ideally suited for an integration by parts which leaves us

$$I(a)=-2 i\color{\red}{\sin^2(a \pi/2)}+2ia\underbrace{\int_0^{\pi/2}\frac{\sin(2a x)}{e^{2 ix}-1}}_{J(a)} \quad \color{\red}{(*)}$$

expanding the denominator in a geometric series and swapping integration and summation we obtain

$$J(a)=-\sum_{n=0}^{\infty}\int_0^{\pi/2}\sin(2a x)e^{2 i xn}$$

the resulting integrals are readily performed

$$J(a)=\frac{1}{2}\left[a\underbrace{\sum_{n=0}^{\infty}\frac{1}{ (a^2-n^2)}}_{\color{\orange}{S_1(a)}}-a\cos (\pi a)\underbrace{\sum_{n=0}^{\infty}\frac{(-1)^n }{(a^2-n^2)}}_{\color{\green}{S_2(a)}}+i\sin (\pi a)\underbrace{\sum_{n=0}^{\infty}\frac{(-1)^n n }{(a^2-n^2)}}_{\color{\violet}{S_3(a)}}\right]$$

The sum $\color{\violet}{S_3(a)}$ was already calculated by Rob, and we don't repeat the corresponding steps here.

What is then left to show is essentially that $\frac{a}{2}\left(\color{\orange}{S_1(a)}-\cos(\pi a)\color{\green}{S_2(a)}\right)=\color{\red}{\sin^2(a \pi/2)}$ so that the imaginary parts in $\color{\red}{(*)}$ cancel out. We start with $\color{\green}{S_2(a)}$:

$$\color{\green}{S_2(a)}=\frac{1}{2a}\left(\sum_{n=0}^{\infty}\frac{(-1)^n}{n+a}-\frac{(-1)^n}{n-a}\right)=\frac{1}{2a}\left(\sum_{n\in\mathbb{Z}}\frac{(-1)^n}{a-n}-\frac{1}{a}\right)$$

Now we can employ for example the pole expansion of $\frac{1}{\sin(z)}$ and obtain $$\color{\green}{S_2(a)}=\frac{1}{2a^2}+\frac{\pi}{2\sin(\pi a)a}$$

To calculate $\color{\orange}{S_1(a)}$ we use the pole expansion of $\cot(z)$ and obtain

$$\color{\orange}{S_1(a)}=\frac{1}{2a^2}+\frac{\pi \cot(\pi a) }{ 2a}$$

Using the fact that $1-\cos(x)=2\sin^2(x/2)$ and $\cot(x)=\frac{\cos(x)}{\sin(x)}$ we may indeed conclude that

$$\frac{a}{2}\left(\color{\orange}{S_1(a)}-\cos(\pi a)\color{\green}{S_2(a)}\right)=\frac{a}{2}\left(2 \frac{\color{\red}{\sin^2(a \pi/2)}}{a}\right)=\color{\red}{\sin^2(a \pi/2)}$$

so the imaginary part of $\color{red}{(*)}$ is zero and therefore

$$I(a)=-a\sin (\pi a)\color{\violet}{S_3(a)}$$

which agrees with the other answer given

There appears to be lots of methods to throw at this one.

Use parts by letting

$u=\sin^{2}(ax), \;\ dv=\frac{1}{\sin(x)}dx, \;\ du=2a\sin(ax)\cos(ax)dx, \;\ v=-cot(x)dx$

$$-\sin^{2}(ax)\cot(x)|_{0}^{\frac{\pi}{2}}+2a\int_{0}^{\frac{\pi}{2}}\sin(ax)\cos(ax)\cot(x)dx$$

Since the left part is $0$, and using the identity $2\sin(u)\cos(u)=\sin(2u)$, then we have:

$$a\int_{0}^{\frac{\pi}{2}}\sin(2ax)\cot(x)dx\tag{1}$$

This looks as if there are many ways to go about it. I am going to use the famous relation:

$$\int_{a}^{b}p(x)\cot(x)dx=2\sum_{n=1}^{\infty}\int_{a}^{b}p(x)\sin(2nx)dx$$

It is OK in this case by letting $p(x)=\sin(2ax), \;\ p(0)=0$

Thus,

$$2a\sum_{n=1}^{\infty}\int_{0}^{\frac{\pi}{2}}\sin(2ax)\sin(2nx)dx$$

$$\frac{a}{2}\underbrace{\sum_{n=1}^{\infty}\frac{\sin(\pi(a-n))}{a-n}}_{[1]}-\frac{a}{2}\underbrace{\sum_{n=1}^{\infty}\frac{\sin(\pi(a+n))}{a+n}}_{[2]}$$

I cut to the quick by using tech, but these sums are kind of famous and summing [1]-[2] results in:

$$[1]=\frac{a}{2}\left(\frac{-1}{2}\sin(\pi a)\left(\psi\left(1/2-a/2\right)-\psi\left(1-a/2\right)\right)\right)$$

$$[2]=\frac{a}{2}\left(\frac{-1}{2}\sin(\pi a)\left(\psi\left(a/2+1\right)-\psi\left(a/2+1/2\right)\right)\right)$$

$$[1]-[2]=\text{required result}$$

Other thoughts:

use parts again on (1)

or

Consider $1/2\int_{0}^{\pi}\frac{1-\cos(ax)}{1-\cos(x)}dx$\newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{\mathrm{i}} \newcommand{\iff}{\Leftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left(\, #1 \,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\, #2 \,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}$Question:$\ds{\int_{0}^{\pi/2}{\sin^{2}\pars{ax} \over \sin^{2}\pars{x}}\,\dd x\,,\quad a \in \mathbb{R}}\begin{align} &\color{#f00}{\int_{0}^{\pi/2}{\sin^{2}\pars{ax} \over \sin^{2}\pars{x}}\,\dd x} = \int_{0}^{\pi/2}{1 - \cos\pars{2ax} \over 1 - \cos\pars{2x}}\,\dd x = \half\int_{0}^{\pi}{1 - \cos\pars{ax} \over 1 - \cos\pars{x}}\,\dd x \\[3mm] = &\ {1 \over 4}\int_{-\pi}^{\pi}{1 - \cos\pars{ax} \over 1 - \cos\pars{x}}\,\dd x = {1 \over 4}\,\Re\int_{-\pi}^{\pi}{1 + \verts{a}x\ic - \expo{\verts{a}x\ic} \over 1 - \cos\pars{x}}\,\dd x \\[3mm] = &\ {1 \over 4}\,\Re\oint_{\verts{z} = 1}{1 + \verts{a}\ln\pars{z} - z^{\verts{a}} \over 1 - \pars{z + z^{-1}}/2}\,{\dd z \over \ic z} = \half\,\Im\oint_{\verts{z} = 1} {z^{\verts{a}} - \verts{a}\ln\pars{z} - 1 \over \pars{z - 1}^{2}}\,\dd z \end{align} We'll choose thez^{\verts{a}}$and$\ln\pars{z}$branch-cuts along the negative$x$-axis with$z = 0as their branch points. Then, the integration contour is a key-hole one which doesn't enclose any pole such that the whole contribution to the integral comes from integrals above and below the branch-cuts. Namely, \begin{align} &\color{#f00}{\int_{0}^{\pi/2}{\sin^{2}\pars{ax} \over \sin^{2}\pars{x}}\,\dd x} \\[5mm] = &\ -\,\half\,\Im\int_{-1}^{0}{\pars{-x}^{\verts{a}}\exp\pars{\pi\verts{a}\ic} - \verts{a}\bracks{\ln\pars{-x} + \ic\pi} - 1 \over \pars{x - 1}^{2}}\,\dd x \\[3mm] & -\ \half\,\Im\int_{0}^{-1}{\pars{-x}^{\verts{a}}\exp\pars{-\pi\verts{a}\ic} - \verts{a}\bracks{\ln\pars{-x} - \ic\pi} - 1 \over \pars{x - 1}^{2}}\,\dd x \\[5mm] = &\ -\,\half\,\Im\int_{0}^{1}{x^{\verts{a}}\exp\pars{\pi\verts{a}\ic} - \verts{a}\bracks{\ln\pars{x} + \ic\pi} - 1 \over \pars{1 + x}^{2}}\,\dd x \\[3mm] & +\ \half\,\Im\int_{0}^{1}{x^{\verts{a}}\exp\pars{-\pi\verts{a}\ic} - \verts{a}\bracks{\ln\pars{x} - \ic\pi} - 1 \over \pars{1 + x}^{2}}\,\dd x \\[5mm] = &\ -\sin\pars{\pi\verts{a}}\int_{0}^{1}{x^{\verts{a}} \over \pars{1 + x}^{2}} \,\dd x + \pi\verts{a}\int_{0}^{1}{\dd x \over \pars{1 + x}^{2}} \\[3mm] & = \half\,\pi\verts{a} - \sin\pars{\pi\verts{a}}\int_{0}^{1}{x^{\verts{a}} \over \pars{1 + x}^{2}}\,\dd x \end{align} Integrating by parts: \begin{align} &\color{#f00}{\int_{0}^{\pi/2}{\sin^{2}\pars{ax} \over \sin^{2}\pars{x}}\,\dd x} \\[3mm] = &\ \half\,\pi\verts{a} + \half\,\sin\pars{\pi\verts{a}} - \verts{a}\sin\pars{\pi\verts{a}}\int_{0}^{1}{x^{\verts{a} - 1} \over 1 + x} \,\dd x \\[3mm] = &\ \half\,\pi\verts{a} + \half\,\sin\pars{\pi\verts{a}} + \verts{a}\sin\pars{\pi\verts{a}}\int_{0}^{1}{1 - x^{\verts{a} - 1} \over 1 + x} \,\dd x - \verts{a}\sin\pars{\pi\verts{a}}\int_{0}^{1}{\dd x \over 1 + x} \\[3mm] = &\ \half\,\pi\verts{a} + \bracks{\half - \verts{a}\ln\pars{2}} \sin\pars{\pi\verts{a}} + a\sin\pars{\pi a}\color{#00f}{\int_{0}^{1}{1 - x^{\verts{a} - 1} \over 1 + x} \,\dd x}\tag{1} \end{align} The "\color{#00f}{blue\ integral}" is evaluated as follows: \begin{align} &\color{#00f}{% \int_{0}^{1}{1 - x^{\verts{a} - 1} \over 1 + x}\,\dd x} = \int_{0}^{1}\pars{1 - x^{\verts{a} - 1}} \pars{{1 \over 1 + x} + {1 \over 1 - x}}\,\dd x - \int_{0}^{1}{1 - x^{\verts{a} - 1} \over 1 - x}\,\dd x \\[3mm] = &\ 2\int_{0}^{1}{1 - x^{\verts{a} - 1} \over 1 - x^{2}}\,\dd x - \int_{0}^{1}{1 - x^{\verts{a} - 1} \over 1 - x}\,\dd x = \int_{0}^{1}{x^{-1/2} - x^{\verts{a}/2 - 1} \over 1 - x}\,\dd x - \int_{0}^{1}{1 - x^{\verts{a} - 1} \over 1 - x}\,\dd x \\[3mm] & = \int_{0}^{1}{1 - x^{\verts{a}/2 - 1} \over 1 - x}\,\dd x - \int_{0}^{1}{1 - x^{-1/2} \over 1 - x}\,\dd x - \int_{0}^{1}{1 - x^{\verts{a} - 1} \over 1 - x}\,\dd x \\[3mm] = &\ \bracks{\Psi\pars{{\verts{a} \over 2}} + \gamma}\ -\ \overbrace{\bracks{\Psi\pars{\half} + \gamma}}^{\ds{-2\ln\pars{2}}}\ -\ \bracks{\Psi\pars{\verts{a}} + \gamma} \\[3mm] = &\ \color{#00f}{% 2\ln\pars{2} + \bracks{\Psi\pars{{\verts{a} \over 2}} - \Psi\pars{\verts{a}}}} \end{align} In replacing this results in\pars{1}\$, we find: \begin{align} &\color{#f00}{\int_{0}^{\pi/2}{\sin^{2}\pars{ax} \over \sin^{2}\pars{x}}\,\dd x} \\[3mm] = &\ \color{#f00}{\half\,\pi\verts{a} + \bracks{\verts{a}\ln\pars{2} + \half}\sin\pars{\pi\verts{a}} + a\sin\pars{\pi a} \bracks{\Psi\pars{{\verts{a} \over 2}} - \Psi\pars{\verts{a}}}} \end{align}