# Evaluating $\int_0^\pi x\frac{\sin{\frac{x}{2}} - \cos{\frac{x}{2}}}{\sqrt{\sin{x}}} dx$

How am I supposed to solve the following definite integral? $$\mathcal{I} = \int_0^\pi x \cdot \frac{\sin{\frac{x}{2}} - \cos{\frac{x}{2}}}{\sqrt{\sin{x}}} dx$$

This definite integral is solved if the minus sign is replaced by a plus sign, and it yields $$\pi^2$$.

$$\mathcal{I} = \int_0^\pi x \cdot \frac{\sin{\frac{x}{2}} + \cos{\frac{x}{2}}}{\sqrt{\sin{x}}} dx \text{ — (I)} \\ \implies \mathcal{I} = \int_0^\pi (\pi - x) \cdot \frac{\cos{\frac{x}{2} + \sin{\frac{x}{2}}}}{\sqrt{\sin{x}}} dx \text{ — (II)}$$

On (I) + (II), we have,

$$\mathcal{I} = \frac{\pi}{2}\int_0^\pi \frac{\sin{\frac{x}{2}} + \cos{\frac{x}{2}}}{\sqrt{\sin{x}}} dx = \frac{\pi}{2} \int_0^\pi \frac{\sin{\frac{x}{2}}+\cos{\frac{x}{2}}}{\sqrt{1 - (\sin{\frac{x}{2}-\cos{\frac{x}{2}}})^2}} dx$$

On substitution, $$\sin{\frac{x}{2}} - \cos{\frac{x}{2}} = u \implies \left(\sin{\frac{x}{2}} + \cos{\frac{x} {2}}\right) dx = 2 \cdot du$$

The upper and lower limits changes to 1 and -1. Now, we have

$$\mathcal{I} = \frac{\pi}{2} \int_{-1}^1 \frac{2 \cdot du}{\sqrt{1 - u^2}} du = \pi \cdot \left[\arcsin{u}\right]_{-1}^1 = \pi^2$$

## But...

1. The sign was not supposed to be changed. We get $$(2x - \pi)$$ instead of $$\pi$$ in the nominator when adding both integrals. It complicates the problem.

2. Using integral-calculator.com or a scientific calculator is helpless.

3. The answer to the original problem should be $$2\pi \cdot \ln{2}$$ (approx 4.35.)

• @HelpMeToUnderstandContours By using the definite integral rule: $\int_a^b f(x) dx = \int_a^b f(a + b - x) dx$ Aug 14, 2022 at 4:57
• I didn't notice the $x$ before $\frac{\cos{\frac{x}{2} + \sin{\frac{x}{2}}}}{\sqrt{\sin{x}}}$. Thanks.
– user1079196
Aug 14, 2022 at 4:58

Here is a solution using real analysis. First, denote the two integrals as

\begin{align*} J & \equiv\int\limits_0^{\pi}\frac {x\left(\sin\frac x2\color{red}-\cos\frac x2\right)}{\sqrt{\sin x}}\,\mathrm dx\\K & \equiv\int\limits_0^{\pi}\frac {x\left(\sin\frac x2\color{red}+\cos\frac x2\right)}{\sqrt{\sin x}}\,\mathrm dx \end{align*}

And from your post, recall that $$K=\pi^2$$. Adding the two integrals together removes the $$\cos\frac x2$$ factor inside the integrand, leaving only

\begin{align*} J+K & =2\int\limits_0^{\pi}\frac {x\sin\frac x2}{\sqrt{\sin x}}\,\mathrm dx\\ & =\sqrt 2\int\limits_0^{\pi}x\sqrt{\tan\frac x2}\,\mathrm dx\\ & =4\sqrt{2}\int\limits_0^{+\infty}\frac {\sqrt t}{1+t^2}\arctan t\,\mathrm dt \end{align*}

Where a double angle identity was utilized in the second equation and the half-angle tangent substitution in the third equation. The last integral has been evaluated here before using Complex Analysis, Feynman's Trick, etc. Here is an alternative approach using double integrals. First, enforce the substitution $$x=\sqrt t$$ so that the integral becomes

$$\int\limits_0^{+\infty}\frac {\sqrt t}{1+t^2}\arctan t\,\mathrm dt=2\int\limits_0^{+\infty}\frac {x^2}{1+x^4}\arctan x^2\,\mathrm dx$$

Next, use the identity

$$\arctan x^2=\int\limits_0^1\frac {x^2}{1+x^4 y^2}\,\mathrm dy$$

Swapping the order of integration and using partial fraction decomposition, then we get

\begin{align*} 2\int\limits_0^{+\infty}\,\int\limits_0^1\frac {x^4}{(1+x^4)(1+x^4y^2)}\,\mathrm dy\,\mathrm dx & =2\int\limits_0^1\frac 1{y^2-1}\int\limits_0^{+\infty}\frac 1{1+x^4}-\frac 1{1+x^4y^2}\,\mathrm dx\,\mathrm dy\\ & =\frac {\pi}{\sqrt 2}\int\limits_0^1\frac 1{y^2-1}\left(1-\frac 1{\sqrt y}\right)\,\mathrm dy\\ & =\frac {\pi^2}{4\sqrt 2}+\frac {\pi\log 4}{4\sqrt 2} \end{align*}

To recap, we have the equation

$$J+\pi^2=4\sqrt{2}\int\limits_0^{+\infty}\frac {\sqrt t}{1+t^2}\arctan t\,\mathrm dt=\pi^2+\pi\log 4$$

Subtracting a $$\pi^2$$ from both sides, then

$$\int\limits_0^{\pi}\frac {x\left(\sin\frac x2-\cos\frac x2\right)}{\sqrt{\sin x}}\,\mathrm dx\color{blue}{=\pi\log 4}$$

• It is the best answer I could understand. Thank you! Aug 15, 2022 at 4:12

$$I=\int_0^\pi\frac{\sin{\frac{x}{2}} - \cos{\frac{x}{2}}}{\sqrt{\sin{x}}}x dx=2\sqrt2\int_0^\frac{\pi}{2}\Big(\sqrt{\tan x}-\sqrt{\cot x}\Big)xdx=2\sqrt2(I_1-I_2)$$ Both terms converge, so we can evaluate them separately.

Making the substitution $$x=\arctan t$$ and $$\arctan t=\int_0^1\frac{t}{1+t^2x^2}dx$$ $$I_1=\int_0^\infty\frac{\sqrt t}{1+t^2}\arctan tdt=\int_0^1\frac{dx}{x^2}\int_0^\infty\frac{t\sqrt t}{(1+t^2)\big(t^2+\frac{1}{x^2}\big)}dt$$ To evaluate the first integral we go in the complex plane and integrate along a keyhole contour. We have four simple poles ($$\,\pm i; \,\,\pm\frac{i}{x}\,$$).

The straightforward evaluation gives $$\int_0^\infty\frac{t\sqrt t}{(1+t^2)\big(t^2+\frac{1}{x^2}\big)}dt=\frac{2\pi i}{2}\underset{z=\pm i; z=\pm\frac{i}{x}}{\operatorname{Res}}\frac{z\sqrt z}{(1+z^2)\big(z^2+\frac{1}{x^2}\big)}=\frac{\pi}{\sqrt2}\frac{1-\sqrt x}{\sqrt x(1-x^2)}x^2$$ Therefore, $$I_1=\frac{\pi}{\sqrt2}\int_0^1\frac{dx}{\sqrt x(1+\sqrt x)(1+x)}=\sqrt2\pi\int_0^1\frac{dt}{(1+t)(1+t^2)}$$ $$=\frac{\pi}{\sqrt2}\int_0^1\Big(\frac{1}{1+t}+\frac{1-t}{1+t^2}\Big)dt$$ Integration is straightforward and gives $$I_1=\frac{\pi}{2\sqrt2}\Big(\frac{\pi}{2}+\ln2\Big)$$ In the similar way we evaluate $$I_2$$ (using $$\sqrt{\cot x}=\frac{1}{\sqrt{\tan x}}$$ and making the same substitution $$x=\arctan t\,$$) $$I_2=\int_0^1\frac{dx}{x^2}\int_0^\infty\frac{\sqrt t}{(1+t^2)\big(t^2+\frac{1}{x^2}\big)}dt=\frac{\pi}{\sqrt2}\int_0^1\frac{dx}{(1+\sqrt x)(1+x)}=\frac{\pi}{2\sqrt2}\Big(\frac{\pi}{2}-\ln2\Big)$$ $$\boxed{\,\,I=2\sqrt2(I_1-I_2)=2\pi\ln2\,\,}$$ And, as a bonus, $$J=2\sqrt2(I_1+I_2)=\pi^2$$

• Thank you for your effort. However, my level of understanding is not that much at the moment. Despite this, it motivated me to learn Mathematics. Aug 15, 2022 at 4:13
• I have a slight objection to your evaluation of the residue. You are trying to evaluate a residue of a function involving sqrt(z), but this is not a holomorphic function - it requires a branch cut etc. Is it valid to ignore this when computing a residue, eg. via taylor approximation around x when x!=0 (so any given branch of sqrt(z) is analytic in a neighborhood around x!=0)? Aug 15, 2022 at 14:32
• @Faraz Masroor Thank you for your comment. In fact, the keyhole contour includes the cut (from $0$ to $\infty$ along the axis $X$) - to make the integrand a single-valued function. We also have to make sure that the integrals around $z=0$ and along a big circle do not contribute. I skipped all these steps, because the given integrand is an appropriate function for the keyhole integration. The detailed examples of keyhole integration may be found, for example, here - math.stackexchange.com/questions/233396/… Aug 15, 2022 at 15:14

$$I=\int_0^\pi x \frac{\sin{\frac{x}{2}} - \cos{\frac{x}{2}}}{\sqrt{\sin{x}}} dx\overset{IBP}=4\int_0^\frac{\pi}{2}\ln(\sqrt{\sin x}+\sqrt{1+\sin x})dx$$

$$\overset{\large x\to \frac{\pi}{2}-2x}=8\int_0^\frac{\pi}{4}\ln\left(\sqrt{\cos(2x)}+\sqrt 2 \cos x\right)dx\overset{\cos x\to x}=8\int_\frac{1}{\sqrt 2}^1\frac{\operatorname{arccosh}(\sqrt 2x)}{\sqrt{1-x^2}}dx$$

$$\require{cancel} \mathcal J(a)=\int_\frac{1}{a}^1\frac{\operatorname{arccosh}(ax)}{\sqrt{1-x^2}}dx\Rightarrow \mathcal J'(a)=\frac{1}{a^2}\frac{\cancelto{0}{\operatorname{arccosh}\left(a\frac{1}{a}\right)}}{\sqrt{1-\frac{1}{a^2}}}+\int_\frac{1}{a}^1\frac{x}{\sqrt{1-a^2x^2}\sqrt{1-x^2}}dx$$

$$\overset{1-x^2\to x^2}=\frac1a\int_0^{\sqrt{1-\frac{1}{a^2}}}\frac{1}{\sqrt{1-\frac{1}{a^2}-x^2}}dx=\frac1a\arcsin\left(\frac{x}{\sqrt{1-\frac{1}{a^2}}}\right)\bigg|_0^\sqrt{1-\frac1{a^2}}=\frac{\pi}{2a}$$

$$I=8\left(\mathcal J(\sqrt 2)-\mathcal J(1)\right)=4\pi\int_1^\sqrt 2\frac{1}{a}da=2\pi \ln 2$$

• Thank you very much for your effort. It helped me understand the $\arccosh(x)$ function. I'm looking forward to learning more. Aug 15, 2022 at 4:16

Evaluate \begin{align} I=& \int_0^{\pi/2} \frac{x(\sin x- \cos x)}{\sqrt{\sin{2x}}} dx =\int_0^{\pi/2} x\ d\bigg(- \tanh^{-1}\frac{\sqrt{2\tan x}}{1+\tan x}\bigg)\\ \overset{ibp}=&\int_0^{\pi/2} \tanh^{-1}\frac{\sqrt{2\tan x}}{1+\tan x} \overset{t= \tan x}{dx} =\int_0^\infty \frac1{1+t^2}\tanh^{-1}\frac{\sqrt{2t}}{1+t^2}dt=J(1) \end{align} where $$J(a)= \int_0^\infty \frac1{1+t^2}\tanh^{-1}\frac{a\sqrt{2t}}{1+t}dt$$ \begin{align} J’(a)=&\int_0^\infty\frac{\sqrt{2t}(t+1)}{(1+t^2)(t^2+2(1-a^2)t+1)}\overset{t\to t^2}{dt}\\ =& \ \frac{\sqrt2}{1-a^2} \int_0^\infty \frac{t^2+1}{t^4+1}- \frac{t^2+1}{t^4+2(1-a^2)t^2+1}\ dt\\ = &\ \frac\pi{1-a^2}\bigg(1-\frac1{\sqrt{2-a^2}}\bigg) \end{align} Then \begin{align} \int_0^\pi x\frac{\sin{\frac{x}{2}} - \cos{\frac{x}{2}}}{\sqrt{\sin{x}}} dx=&\ 4I=4J(1)=4\int_0^1 J’(a)da\\ =&\int_0^1 \frac{4\pi}{1-a^2}\bigg(1-\frac1{\sqrt{2-a^2}}\bigg)da=2\pi\ln 2 \end{align}