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?
 A: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
\begin{align}
&\color{#66f}{\large\int{\dd x \over \sin^{2}\pars{x}}}
=\int{\sec^{2}\pars{x}\,\dd x \over \tan^{2}\pars{x}}
=\int{\dd\bracks{\tan\pars{x}}\, \over \tan^{2}\pars{x}}
=-\,{1 \over \tan\pars{x}} = \color{#66f}{\large -\,\cot\pars{x}}
\end{align}
A: If you like cracking walnuts with sledgehammers, you could try using the Weierstraß substitution!
Substituting $u=\tan{\frac{x}{2}}$, have $\sin{x}=\frac{2u}{1+u^2}$ and $dx=\frac{2}{1+u^2}du$, and thus,
$$\int\frac{1}{\sin^2{x}}\mathrm{d}x=\int\frac{1+u^2}{2u^2}\mathrm{d}u\\
=\frac12\left(u-\frac{1}{u}\right)+\text{constant}\\
=\frac12\left(\tan{\frac{x}{2}}-\frac{1}{\tan{\frac{x}{2}}}\right)+\text{constant}.$$
From there it's just a matter of juggling trig identities to show that this antiderivative is equivalent to $-\cot{x}$.
A: We can use the tangent half-angle substitution to get rid of any trigonometric expression during the integration.
Let $\sin x=\dfrac{2t}{1+t^2}$. Then $\cos x=\dfrac{1-t^2}{1+t^2}$ and $dx=\dfrac{2dt}{1+t^2}$, and we have
$$\int\frac{1}{\sin^2x}dx=\int\frac{(1+t^2)^2}{4t^2}\frac{2}{1+t^2}dt=\int\frac{1+t^2}{2t^2}dt=\int\frac{1}{2}+\frac{1}{2t^2}dt=\frac{t}{2}-\frac{1}{2t}.$$
Now 
$$\frac{t}{2}-\frac{1}{2t}=\frac{t^2-1}{2t}=\frac{-\frac{1-t^2}{1+t^2}}{\frac{2t}{1+t^2}}=\frac{-\cos x}{\sin x}=-\cot x.$$
A: When you asked how to "derive" the fact that $\int \frac{1}{\sin^2 x} dx = -\cot x$, I thought maybe someone had suggested that this fact might be true, and asked if you could prove it. If that were so, then you would merely need to differentiate $-\cot x$.
In fact I would not be at all surprised to learn that the first person to discover how to
integrate $\frac{1}{\sin^2 x}$ was not actually trying to solve that problem specifically, but rather was simply interested in finding the derivative of $f(x) = \cot x$. Once they had done that, they knew the integral of $f'(x)$, which means they also knew how to integrate $-f'(x) = \frac{1}{\sin^2 x}$.
Most of the other methods described here are useful things to know about. But it all comes down to remembering a formula. I remember hating this part of first-year calculus, because it seemed like too much rote memorization of facts, especially the ones that said "the integral of ... is ...". I didn't want to have to remember all that. I probably would have been happier if I had just decided to make the best of it and had made myself a set of flash cards.
What you might do is to remember that $\int \sec^2 x dx = \tan x$ and that
$\sec^2 x = \frac{1}{\cos^2 x}$, and you might ask yourself whether the integral of $\frac{1}{\cos^2 x}$ might not be closely related to the integral of $\frac{1}{\sin^2 x}$.
In fact the derivatives and integrals of trigonometric functions are closely related to those of their cofunctions, since $\sin x = \cos\left(\frac{\pi}{2} - x\right)$ and so forth.  Well, then, given that $\tan x$ is the answer to $\int\frac{1}{\cos^2 x} dx$,
will $\cot x$ solve the new problem? Almost; it turns out that
$$\frac{d}{dx} \cot x = -\frac{1}{\sin^2 x},$$
so the solution to your problem is $-\cot x$.
Another method that seems slightly less like guesswork: 
knowing that $\sin x = \cos\left(\frac{\pi}{2} - x\right)$ and that we can integrate
$\frac{1}{\cos^2 x} = \sec^2 x$,
substitute $u = \frac{\pi}{2} - x$.
Then $x = \frac{\pi}{2} - u$ and $dx = -du$, so
$$
\begin{eqnarray*}
\int \frac{1}{\sin^2 x} dx &=& \int -\frac{1}{\sin^2 \left(\frac{\pi}{2} - u\right)} du \\
&=& -\int \frac{1}{\cos^2 u} du \\
&=& -\tan u \\
&=& -\tan \left(\frac{\pi}{2} - x\right) \\
&=& -\cot x.
\end{eqnarray*}
$$
Or you might use the tangent substitution method explained by @Felix Marin, especially if it's on an exam and you think of that method first.
I was happier in second-year calculus and much happier in third-year real analysis, by the way, because it became more about "big ideas" and not so much about the details of how to compute this or that function. (And along the way, a lot of the techniques I had to memorize in high school came to make a lot more sense in light of other patterns I was learning.)
A: $$
\frac{d}{dx} \cot x = \frac{d}{dx} \frac{\cos x}{\sin x} = \frac{[\text{etc. : Apply the quotient rule.}]}{\sin^2 x} = \frac{-1}{\sin^2 x}.
$$
A: 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.
