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.
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&amp;=\sum_{n=1}^{\infty}\frac{t_{n+1}}{(2n)!}\int x^{2n}dx\\
&amp;=\sum_{n=1}^{\infty}\frac{t_{n+1}}{(2n)!}\frac{x^{2n+1}}{2n+1}dx\\
&amp;=\sum_{n=1}^{\infty}\frac{t_{n}}{(2n-1)!}x^{2n-1}dx-t_1 x\\
&amp;=\sum_{n=1}^{\infty}\frac{t_{n}}{(2n-1)!}x^{2n-1}dx- x\\
&amp;=\tan x -x
\end{align}
$$\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$$