There's a proof of that integral on this website:
I just don't understand why we need the absolute value.
$\endgroup$ 23 Answers
$\begingroup$You cannot take the logarithm of a negative number.
Notice that $\dfrac{d}{dw} \log w = \dfrac1w$ (where $w$ is positive) and $\dfrac{d}{dw}\log(-w)$ (where $w$ is negative, so $-w$ is positive) is also $\dfrac1w$.
So $\dfrac{d}{dx}\log\sin x = \cot x$ for values of $x$ for which $\sin x$ is positive.
And $\dfrac{d}{dx}\log(-\sin x)=\cot x$ for value of $x$ for which $\sin x$ is negative, so that $-\sin x$ is positive.
$\endgroup$ $\begingroup$You want an answer that also works on an interval where $\sin x$ is negative.
$\endgroup$ $\begingroup$Compute the integral of $\cot(x)$ for $x\in[0,\pi]$ to be $\log(\sin(x))+C$. Then note that since $\cot(x)$ is an odd function, its integral will be an even function. Thus, the integral for $x\in[-\pi,\pi]$ will be $\log(\sin(|x|))+C$. By the periodicity, we get that the integral is $\log(|\sin(x)|)+C$.
$\endgroup$ 4