What is $\int\tan^2{x}dx$? what strategy can I use? I'm a bit stuck on how to find the inter
gral of 
$$ \int \tan^2{x}dx$$
if I substitute, with $\tan{x}$, there isn't a $\sec^2{x}$ for me to substitute the dx out with. If I transform $\tan^2{x}$ into $\sec^2{x}-1$, then you subbing gets me nowhere again. Is there an identity I can use? If so, can someone show me the proof of it?
EDIT
I am told I can use this formula:
$$\tan{\frac{x}{2}} = \sqrt{\frac{1 - \cos{x}}{1 + \cos{x}}} $$
but I don't see how this helps me. Can someone show me the proof of how this was obtained via the double angle formula for sin and cosine?
 A: Hint
use$$(\tan x)'=1+\tan^2x$$
A: Hint:
A useful but not so well known formula is
$$(\tan x)'=\tan^2x+1.$$
A: Don't forget that $\tan^2{x}=\sec^2-1$ and that $\int \sec^2x\,dx=\tan{x}+C$ because $\frac{d}{dx}\left(\tan{x}\right)=\sec^2{x}$:
$$
\begin{align}
\int \tan^2{x}\,dx
&=\int (\sec^2x-1)\,dx\\
&=\int \sec^2x\,dx-\int\,dx\\
&=\tan{x}-x+C.
\end{align}
$$
If you want to do this integral using the half-angle formula for the tangent function, you're gong to have to use the so-called Weierstrass substitution.
$$
\tan^2{\frac{x}{2}}=\frac{\sin^2{\frac{x}{2}}}{\cos^2{\frac{x}{2}}}=\frac{\frac{1-\cos{x}}{2}}{\frac{1+\cos{x}}{2}}=\frac{1-\cos{x}}{1+\cos{x}}.
$$
$$
\tan^2{\frac{(2x)}{2}}=\tan^2{x}=\frac{1-\cos{(2x)}}{1+\cos{(2x)}}.
$$
$$
\begin{align}
\int\tan^2{x}\,dx
&=\int \frac{1-\cos{(2x)}}{1+\cos{(2x)}}\\
&=\int\frac{1}{1+\cos{(2x)}}\,dx-\int\frac{\cos{(2x)}}{1+\cos{(2x)}}\,dx\\
&=\frac{1}{2}\int\frac{1}{1+\cos{(2x)}}\frac{d}{dx}\left(2x\right)\,dx-\frac{1}{2}\int\frac{\cos{(2x)}}{1+\cos{(2x)}}\frac{d}{dx}\left(2x\right)\,dx\ (u=2x)\\
&=\frac{1}{2}\int\frac{1}{1+\cos{u}}\,du-\frac{1}{2}\int\frac{\cos{u}}{1+\cos{u}}\,du\\
\end{align}
$$
And now you apply the Weierstrass substitution formulas:
$$
\cos{u}=\frac{1-t^2}{1+t^2},\ du=\frac{2}{1+t^2}dt
$$
$$
\begin{align}
=\frac{1}{2}\int\frac{1}{1+\frac{1-t^2}{1+t^2}}\frac{2}{1+t^2}\,dt-\frac{1}{2}\int\frac{\frac{1-t^2}{1+t^2}}{1+\frac{1-t^2}{1+t^2}}\frac{2}{1+t^2}\,dt
\end{align}
$$
At this point, what you've got are purely algebraic expressions under the integral signs. All you need to do is simplify them, take their integrals and do back-substitution.
PS: I hope I didn't make any mistake.
