Where I made mistake(s) as the integrating of $~\int_{}^{}\frac{1}{\sin^{2}\left(x\right)}\,dx~$?
\begin{align} \int \frac{1}{(\sin x)^2}dx &=\int\frac{(\sin x)^2+(\cos x)^2}{(\sin x)^2}dx \\ &=\int dx + \int (\sin x)^{-2}(\cos x)^2 dx\\ &=x + \int \cos x (\sin x)^{-2} d(\sin x)\\ &=x+\int \cos x d(-\sin x)^{-1}) \end{align}
Integration by parts gives
$=x-(\cos x)(\sin x)^{-1}+\int (\sin x)^{-1}d\cos x$ $=x-ctg x-\int \frac{\sin x}{\sin x}dx=-ctg x$