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.
 A: Taking a look here would be great. 
Note that $$\tan^2 x=\sum_{n=1}^{\infty}\frac{t_{n+1}}{(2n)!}x^{2n},$$ with $t_n$ being tangent numbers and defined as $\displaystyle t_n=\frac{2^{2n}(2^{2n}-1)|B_{2n}|}{2n}, n=1,2,...$. Therefore 
\begin{align}
\int \tan^2x dx&=\sum_{n=1}^{\infty}\frac{t_{n+1}}{(2n)!}\int x^{2n}dx\\
&=\sum_{n=1}^{\infty}\frac{t_{n+1}}{(2n)!}\frac{x^{2n+1}}{2n+1}dx\\
&=\sum_{n=1}^{\infty}\frac{t_{n}}{(2n-1)!}x^{2n-1}dx-t_1 x\\
&=\sum_{n=1}^{\infty}\frac{t_{n}}{(2n-1)!}x^{2n-1}dx- x\\
&=\tan x -x
\end{align}
A: $$\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.
A: $$\int\tan^2(x)\,dx$$
With IBP
$$\int \tan^2(x)\,dx=x \tan^2(x)-\int 2x \sec^2 x \tan x\,dx\tag{1}$$
$u=\tan(x)$
$$\int 2x \sec^2 x \tan x\,dx=\int 2 u \tan^{-1} u\,du\tag{2}$$
With IBP again
$$\int 2 u \tan^{-1} u\,du=\frac{u^2 \tan^{-1} u}{2}-\frac 12 \int \frac{u^2}{1+u^2}\,du\tag{3}$$
With PFD
$$\int \frac{u^2}{1+u^2}\,du=\int 1- \frac{1}{1+u^2}\,du=u-\tan^{-1}u\tag{4}$$
Plugging into $(3)$
$$\int 2 u \tan^{-1} u\,du={u^2 \tan^{-1} u}- {u+\tan^{-1} u} \tag{5}$$
Back substituting from $(2)$
$$\int 2x \sec^2 x \,dx\tan x={x\tan^2 x}-{\tan(x)+x}$$
Plugging into $(1)$
$$\int \tan^2(x)\,dx=x \tan^2(x)-{x\tan^2 x}+{\tan(x)+x}$$
Plugging into the original integral:
$$\int \tan^2(x)\,dx= \tan(x) + x$$
