Why does using Leibnitz rule on these two equivalent integrals gives different answers

integration

First taking two equivalent integrals:
\begin{align}\int_{0}^{\pi\over 2}\ln(\sin x)\ dx=x\ln (\sin x)\ dx \biggr|_{0}^{\pi\over2}-\int_{0}^{\pi\over2}x\cot x\ dx\\\implies \int_{0}^{\pi\over 2}\ln(\sin x)\ dx=-\int_{0}^{\pi\over2}x\cot x\ dx \end{align}
Now using Leibnitz rule on the first integral in the following way:
\begin{align}I'(a)=\int_{0}^{\pi\over 2}\frac{\partial}{\partial a}\ln(a\sin x)\ dx=\int_{0}^{\pi\over2}\frac{1}{a}\ dx=\frac{\pi}{2a}\end{align}
Integrating wrt a, we get an infinite negative term ($\ln 0$)

As for the second integral
\begin{align}\int_{0}^{\pi\over2}x\cot x\ dx=\int_{0}^{\pi\over2}\frac{\arctan({\tan x})}{\tan x}\ dx\end{align}
\begin{align}I'(a)=\int_{0}^{\pi\over2}\frac{\partial}{\partial a}\frac{\arctan{(a\tan x)}}{\tan x}\ dx=\int_{0}^{\pi\over2}\frac{1}{a^2\tan^2x+1}\ dx\end{align}
With the substitution $\tan x = \xi$ (and so $dx=\frac{d\xi}{\xi^2+1}$):
\begin{align}\frac{a^2}{a^2-1}\int_{0}^{\infty}\frac{d\xi}{a^2\xi^2+1}-\frac{1}{a^2-1}\int_{0}^{\infty}\frac{d\xi}{\xi^2+1}=\frac{a}{a^2-1}\int_{0}^{\infty}\frac{d\xi}{\xi^2+1}-\frac{1}{a^2-1}\int_{0}^{\infty}\frac{d\xi}{\xi^2+1}\end{align}

As the two integrals in the above expression would both equal$\pi\over2$, we would get:
\begin{align}I'(a)=\frac{\pi}{2(a+1)}\implies I(1)-I(0)=\frac{\pi}{2}\ln (2)\end{align}
Which is correct

So the question is, how can it be that evaluating equivalent integrals leads to an incorrect and a correct answer?

Best Answer

Differentiation under the integral sign lets you say $I(a)=I(a_0) + \int_{a_0}^a I'(b) db$. This splits the problem in two: evaluate $I(a_0)$ for some $a_0$ and then integrate $I'$ from $a_0$ to $a$.

In your first approach, you can write $I(1)=I(a_0)+\int_{a_0}^1 I'(b) db = I(a_0) + \frac{\pi}{2} \ln(1/a_0)$. But this does not help you because no matter what $a_0>0$ you pick, the problem of finding $I(a_0)$ is equally difficult. You cannot select $a_0=0$ here because of the singularity. In effect setting $a_0=0$ or more technically $a_0 \to 0^+$ gives $-\infty=-\infty$ which again doesn't help.

By contrast in your second approach, it is trivial to evaluate $I(0)$ because the integrand is just identically zero (at least in the interior where it is defined). So you can write $I(1)=I(0)+\int_0^1 I'(b) db = \int_0^1 I'(b) db$ which lets you finish the calculation.