Integration of $\int \tan^2 x \ dx $ without the use of trig identities I am trying to integrate $\int \tan^2 x \ dx $  without the use of trig identities, although I know that using $ 1 + \tan^2 x \equiv \sec^2 x $ makes the question trivial.
Using the exponential form of tan(x) I arrived at
$$ -\int \dfrac{(e^{2ix}-1)^2}{(e^{2ix}+1)^2} \ dx $$
I have not studied complex integration, so I am wary of using substitutions of such as $ u = e^{2ix} + 1 $ because I do not know if they are valid.

$$\int\tan^2xdx=\int\frac{\sin^2{x}}{\cos^2{x}}dx=\int\frac{1-\cos{2x}}{2\cos^2{x}}dx=*$$ here we used trigonometric formula $\sin^2{x}=1-\cos{2x},$ $$*= \int\frac{1-\cos{2x}}{2\cos^2{x}}dx=\frac{1}{2}\int\frac{1}{\cos{2x}}dx - \frac{1}{2} \int \frac{\cos{2x}}{\cos^2{x}}dx=*$$ now we will use this one $\cos{2x}=2\cos^2{x}-1,$ $$*= \frac{1}{2} \tan{x} - \frac{1}{2}×2\int\frac{\cos^2{x}}{cos^2{x}}dx + \frac{1}{2}\int\frac{1}{\cos^2{x}}dx= \frac{1}{2}\tan{x} -x + \frac{1}{2}\tan{x} +C=\tan{x} -x +C $$ Thats it. Just trigonometry.
