TITLE: evaluate $\int \frac{\tan x}{x^2+1}\:dx$
QUESTION [6 upvotes]: $$\int \frac{\tan x}{x^2+1}\,  \mathrm dx$$
I used By-parts method setting $u=\tan x$ and $\,  \mathrm dv=\frac{1}{x^2+1}\,  \mathrm dx$, but then I got an integral that's more complicated
I also thought of trigonometric substitution, setting $x=\tan\theta$, but how am going to substitute that for the $\tan x$ in numerator?
I tried to use websites like symbolab & wolfram to evaluate the integral but I got no result.

REPLY [5 votes]: The Laurent series of tan(x) is
$$\sum_{n=1,3,5..}^{\infty }\frac{8x}{(n\pi )^2-4x^2}$$
so
$$\frac{\tan(x)}{1+x^2}=\sum_{n=1,3,5..}^{\infty }\frac{8x}{\left [(n\pi )^2-4x^2  \right ](1+x^2)}$$
use the partial fraction to get
$$\sum_{n=1,3,5,..}^{\infty }\frac{8x}{((n\pi)^2+4 )(1+x^2)}+\frac{8}{((n\pi)^2+4 )(n\pi -2x)}-\frac{8}{((n\pi)^2+4 )(n\pi +2x)}$$
$$\int \frac{\tan x}{1+x^2}dx=C+\sum_{n=1,3,5,..}^{\infty }\frac{4}{(n\pi )^2+4}\left [ \log(1+x^2)-\log(n\pi -2x)-\log(n\pi +2x) \right ]$$
hence
$$\int \frac{\tan x}{1+x^2}dx=C+\sum_{n=1,3,5,..}^{\infty }\frac{4}{(n\pi )^2+4}\left [ \log(\frac{1+x^2}{(n\pi )^2-4x^2}) \right ]$$