how to derive the fact that the integral of $1/\sin^2(x) = -\cot (x)$ I know how that the integral of  $\dfrac{1}{\sin^2(x)} = -\cot (x)$, but how does derive this fact? Can you use half-angle formula to do this integral?

Here's a solution using only the Pythagorean identity, integration by parts, and the derivatives of sine and cosine (and especially, not using knowledge of $\int\sec^2 x\,dx$).
\begin{align*}
\int\frac1{\sin^2 x}\,dx
&= \int\frac{\sin^2 x + \cos^2 x}{\sin^2 x}\,dx \\
&= \int\Big( 1 + \frac{\cos^2 x}{\sin^2 x} \Big)\,dx \\
&= x + \int \frac{\cos^2 x}{\sin^2 x} \,dx \\
&= x + \int \underbrace{\cos x}_u \cdot \underbrace{\frac{\cos x}{\sin^2 x} \,dx}_{dv} \\
&= x + \cos x \Big(\frac{-1}{\sin x}\Big) - \int \frac{-1}{\sin x}\cdot(-\sin x)\,dx \\
&= x - \cot x - \int 1 \,dx \\
&= x - \cot x - x + C \\
&= -\cot x + C
\end{align*}
Finding this requires some luck, but not, I think, a really outrageous amount of luck, by the standards of such problems.
