<s>[INST] 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.)
 [/INST] $$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$$
</s>