TITLE: Integral of $\cot^2 x$?
QUESTION [7 upvotes]: How do you find $\int \cot^2 x \, dx$? Please keep this at a calc AB level. Thanks!

REPLY [2 votes]: Since the integrand $$\cot^2 x=\frac{\cos^2 x}{\sin^2 x}$$ is a rational fraction of $\sin x,\, \cos x$, you could use a universal standard substitution  called the Weirstrasse substitution
$$
\begin{equation*}
\tan \frac{x }{2}=t,\qquad x =2\arctan t,\qquad dx =\frac{2}{1+t^{2}}dt
\end{equation*},
$$
which converts the integrand into a rational function of $t$ whose evaluation is by partial fractions expansion. From the double-angle formulas and the identity $\cos ^{2}\frac{x}{2}+\sin ^{2}\frac{x}{2}=1$ we get:
$$
\begin{eqnarray*}
\cos x &=&\cos \left(2\cdot\frac{x}{2}\right)=\cos ^{2}\frac{x}{2}-\sin ^{2}\frac{x}{2}=\frac{\frac{\cos ^{2}
\frac{x}{2}-\sin ^{2}\frac{x}{2}}{\cos ^{2}\frac{x}{2}}}{\frac{\cos ^{2}
\frac{x}{2}+\sin ^{2}\frac{x}{2}}{\cos ^{2}\frac{x}{2}}}=\frac{1-\tan ^{2}
\frac{x}{2}}{1+\tan ^{2}\frac{x}{2}}=\frac{1-t^2}{1+t^2}, \\
&& \\
\sin x &=&\sin \left(2\cdot\frac{x}{2}\right)=2\sin \frac{x}{2}\cos \frac{x}{2}=\frac{\frac{2\sin \frac{x}{2}
\cos \frac{x}{2}}{\cos ^{2}\frac{x}{2}}}{\frac{\cos ^{2}\frac{x}{2}+\sin ^{2}
\frac{x}{2}}{\cos ^{2}\frac{x}{2}}}=\frac{2\tan \frac{x}{2}}{1+\tan ^{2}
\frac{x}{2}}=\frac{2t}{1+t^2}.
\end{eqnarray*}
$$
Then
$$
\begin{eqnarray*}
\int \cot ^{2}xdx &=&\int \frac{\left( t^{2}-1\right) ^{2}}{2t^{2}\left(
1+t^{2}\right) }\,dt=\int \frac{1}{2}+\frac{1}{2t^{2}}-\frac{2}{1+t^{2}}dt \\
&=&\frac{1}{2}t-\frac{1}{2t}-2\arctan t+C \\
&=&\frac{1}{2}\tan \frac{x}{2}-\frac{1}{2\tan \frac{x}{2}}+C \\
&=&-\cot x+C,
\end{eqnarray*}
$$
because
$$
\begin{equation*}
\cot x=\frac{\cot ^{2}\frac{x}{2}-1}{2\cot \frac{x}{2}}=\frac{1}{2}\cot 
\frac{x}{2}-\frac{1}{2\cot \frac{x}{2}}=\frac{1}{2\tan \frac{x}{2}}-\frac{1}{2}\tan \frac{x}{2}.
\end{equation*}$$