How does $\int_{0}^{\pi/2} \sin x \ln (\sin x)~ dx $ converge to $\ln(2/e)?$ I can solve this integral, 
$$I=\int_{0}^{\pi/2} \sin x \ln (\sin x)~ dx $$
by parts as
$$I=\int_{0}^{\pi/2} \sin x \ln (\sin x) dx=\left (\cos x +\ln \tan \left(\frac{x}{2}\right)- \cos x \ln (\sin x) \right)_{0}^{\pi/2}=-1,$$ as the divergent parts  $\pm \infty$ cancel out. But Mathematica gives $I=\ln(2/e).$ How to resolve this?
 A: Note that $\infty -\infty$ is indeterminate it may or may not be zero.
Therefore, here you have to  take limit as $x\rightarrow 0^+$. Near zero $\tan x \sim x, \sin x \sim x$ and $\cos x\sim (1-x^2/2)$, then $$\lim_{x\rightarrow 0^+} \ln \tan (x/2)- \cos x \ln \sin x =\lim_{x \rightarrow 0^+} \ln (x/2)-(1-x^2/2) \ln x
=\lim_{x \rightarrow 0^+} \left( -\ln 2+(x^2/2) \ln x \right)=-\ln 2.$$ Then $I=-1+\ln 2=\ln(2/e)$.
A: Here's an exact calculation of the indeterminate part of your solution.  My concern with the answer above is that it's not obvious (at least, not to me) that the approximations are good enough to justify the first equality.
First, use double-angle formulas and the property of logarithms to get:
$$\lim_{x \to 0^+} [\cos x \ln(\sin x)-\ln(\tan \frac x2)]\\= \lim_{x \to 0^+}[\cos x(\ln 2 + \ln (\sin \frac x2) + \ln (\cos \frac x2))-\ln (\sin \frac x2)+\ln (\cos \frac x2)].$$
We can evaluate many of these terms immediately, leaving:
$$\ln 2 + \lim_{x \to 0^+}(\cos x -1)\ln (\sin \frac x2).$$
To evaluate this limit, we convert it to a form suitable for the use of L'Hopital's Rule and eliminate another term we can evaluate immediately:
$$\lim_{x \to 0^+}\frac{\ln(\sin \frac x2)}{\frac{1}{\cos x -1}}= \lim_{x \to 0^+}\frac{\frac{\cos \frac x2}{2 \sin \frac x2}}{\frac{\sin x}{(\cos x -1)^2}}= \lim_{x \to 0^+} \frac{(\cos x - 1)^2}{2\sin \frac x2 \sin x}.$$
Now we use double-angle formulas again:
$$\lim_{x \to 0^+} \frac{(\cos x - 1)^2}{2\sin \frac x2 \sin x}=\lim_{x \to 0^+}\frac{4 \sin^4 \frac x2}{4\sin^2 \frac x2 \cos \frac x2}=\lim_{x \to 0^+} \frac{\sin^2 \frac x2}{\cos \frac x2}=0.$$
Thus, the difference of the indeterminate forms is $\ln 2$.
A: I appreciate you may not be seeking this, but you can find the exact value for the integral using the Beta and by extension Gamma Function and it's derivative. 
Here we will to address your integral:
\begin{equation}
I = \int_0^{\frac{\pi}{2}} \sin(x)\ln\left|\sin(x) \right|\:dx
\end{equation}
Here we will approach this integral by considering a general form:
\begin{equation}
 J_{n,m}(a,b) = \int_0^{\frac{\pi}{2}} \ln^n\left|\sin(x) \right| \ln^m\left|\cos(x)\right|\sin^a(x)\cos^b(x)\:dx
\end{equation}
Where $n,m \in \mathbb{Z}$ with $n,m \geq 0$ and $a,b \in \mathbb{R}$. We observe that $I = J_{1,0}(1,0)$. From here we employ the property:
\begin{align}
 \frac{\partial}{\partial c} \left[ \sin^c(x) \right]= \ln\left|\sin(x)\right| \sin^c(x) \Longrightarrow \frac{\partial^n}{\partial c^n} \left[ \sin^c(x) \right]= \ln^n\left|\sin(x)\right| \sin^c(x)  
\end{align}
And so:
\begin{equation}
 \lim_{c \rightarrow a} \frac{\partial^n}{\partial c^n} \left[ \sin^c(x) \right] = \ln^n\left|\sin(x) \right|\sin^a(x)
\end{equation}
Similarly:
\begin{equation}
  \lim_{d \rightarrow b}\frac{\partial^m}{\partial b^m} \left[ \cos^b(x) \right]= \ln^m\left|\cos(x)\right| \cos^b(x)
\end{equation}
Thus, 
\begin{align}
J_{n,m}(a,b)&= \int_0^{\frac{\pi}{2}} \ln^n\left|\sin(x) \right| \ln^m\left|\cos(x)\right|\sin^a(x)\cos^b(x)\:dx \nonumber \\
& = \int_0^{\frac{\pi}{2}} \lim_{c \rightarrow a} \frac{\partial^n}{\partial c^n} \left[ \sin^c(x) \right] \lim_{d \rightarrow b}\frac{\partial^m}{\partial b^m} \left[ \cos^b(x) \right]\:dx
\end{align}
Employing Leibniz's Integral Rule and the Dominated Convergence Theorem, we can draw the partial derivatives and limits outside of the integrand:
\begin{align}
J_{n,m}(a,b) &= \int_0^{\frac{\pi}{2}}\lim_{c \rightarrow a} \frac{\partial^n}{\partial c^n} \left[ \sin^c(x) \right] \lim_{d \rightarrow b}\frac{\partial^m}{\partial b^m} \left[ \cos^b(x) \right]\:dx \nonumber \\
& = \lim_{c \rightarrow a} \lim_{d \rightarrow b} \frac{\partial^n}{\partial c^n} \frac{\partial^m}{\partial d^m} \int_0^{\frac{\pi}{2}}\sin^c(x)\cos^d(x)\:dx \nonumber \\
&= \lim_{(c,d)\rightarrow (a,b)}\frac{\partial^{n+m}}{\partial c^n \partial d^m} \left[ \frac{1}{2}B\left(\frac{c + 1}{2}, \frac{d + 1}{2} \right) \right] 
\end{align}
Where $B(x,y)$ is the Beta Function. Employing the relationship between the Beta and Gamma Function this becomes:
\begin{align}
J_{n,m}(a,b) &= \frac{1}{2}  \lim_{(c,d)\rightarrow (a,b)}\frac{\partial^{n+m}}{\partial c^n \partial d^m} \left[ \frac{\Gamma\left( \frac{c + 1}{2}\right)\Gamma\left( \frac{d + 1}{2}\right)}{\Gamma\left( \frac{c + d}{2} + 1\right)} \right] 
\end{align}
Returning to your integral $I$:
\begin{align}
I &= J_{1,0}(1,0) = \frac{1}{2}\lim_{(c,d)\rightarrow (1,0)} \frac{\partial}{\partial c} \left[ \frac{\Gamma\left( \frac{c + 1}{2}\right)\Gamma\left( \frac{d + 1}{2}\right)}{\Gamma\left( \frac{c + d}{2} + 1\right)} \right] \nonumber \\
&= \frac{1}{2}\lim_{(c,d)\rightarrow (1,0)} \Gamma\left(\frac{d + 1}{2}\right)\left[\frac{\Gamma^{'}\left( \frac{c + 1}{2}\right)\cdot \frac{1}{2}}{\Gamma\left( \frac{c + d}{2} + 1\right)} -\frac{\Gamma\left( \frac{c + 1}{2}\right) \Gamma^{'}\left( \frac{c + d}{2} + 1\right) \cdot \frac{1}{2}}{\Gamma^2\left( \frac{c + d}{2} + 1\right)}  \right] \nonumber \\
&= \frac{1}{4}\Gamma\left( \frac{1}{2}\right)\left[ \frac{\Gamma^{'}\left(\frac{1}{2} \right)}{\Gamma\left(\frac{3}{2}\right)} - \frac{\Gamma\left(\frac{1}{2}\right)\Gamma^{'}\left(\frac{3}{2}\right)}{\Gamma^2\left(\frac{3}{2}\right)} \right]
\end{align}
Now:
\begin{equation}
\Gamma\left(\frac{1}{2} \right) = \sqrt{\pi}, \quad \Gamma\left(\frac{3}{2} \right) = \frac{\sqrt{\pi}}{2} \quad \Gamma^{'}\left(\frac{1}{2} \right) = \sqrt{\pi}\left( - \gamma - 2\ln(2)\right),\quad \Gamma^{'}\left(\frac{3}{2} \right) = \frac{\sqrt{\pi}}{2}\left(2 - \gamma - 2\ln(2)\right)
\end{equation}
Thus, 
\begin{align}
 I & \frac{1}{4} \cdot \sqrt{\pi}\left[\frac{\sqrt{\pi}\left( - \gamma - 2\ln(2)\right)}{\frac{\sqrt{\pi}}{2}} - \frac{\sqrt{\pi} \cdot \frac{\sqrt{\pi}}{2}\left(2 - \gamma - 2\ln(2)\right)}{\left(\frac{\sqrt{\pi}}{2} \right)^2}\right] \nonumber \\
& = \ln(2) - 1 = \ln\left(\frac{2}{e}\right)
\end{align}
