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...

*

*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.


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


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

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}
