Indefinite integral of $\frac{\tan{(1+x^2)}}{1+x^2}$

Let $$f(x) = \frac{\tan{(1+x^2)}}{1+x^2}$$ , find $$\int f(x)dx$$ . I've tried many substitutions (including trigonometric substitutions like $$x=\tan \theta$$ ) and also integration by parts but didn't work . We can apply power series but it doesn't solve problem .

• I am afraid that, even using special functions, closed form solutions could be difficult to get. – Claude Leibovici Dec 22 '18 at 8:20
• Hmm.. this guy is fighting back pretty hard.. – InertialObserver Dec 22 '18 at 8:21
• Where did you find this beast? – Mohammad Zuhair Khan Dec 22 '18 at 8:26
• @MohammadZuhairKhan My friend asked that beast! – S.H.W Dec 22 '18 at 8:31
• Are you sure that he/she is a friend ? – Claude Leibovici Dec 22 '18 at 9:00

If the problem was $$\int_0^a \frac{\tan{(1+x^2)}}{1+x^2}\,dx \qquad \text{with} \qquad 0 \leq a \lt \sqrt{\frac{\pi -2}{2}}\approx 0.7555$$ it could be possible to have an approximation of it using a Padé approximant built at $$x=0$$.
Using $$k=\tan(1)$$, we should have $$\frac{\tan{(1+x^2)}}{1+x^2}=\frac {3 k \left(-2 k^2+2 k+1\right)+3 \left(-k^2+k+1\right)x^2 +(2 k-3) \left(k^2+1\right)x^4} {3(-2 k^2+2 k+1)+ 6 (k-1)^2 k x^2+(6 k^3-7 k^2-4)x^4}$$ which can be integrated using partial fraction decomposition (leading to a nasty expression. Numerically, this would be "almost" (making the coefficient rational) $$\int \frac{\tan{(1+x^2)}}{1+x^2}\,dx \simeq \frac{184 }{789}x+\frac{1099} {3526}\tan ^{-1}\left(\frac{529 }{801}x\right)+\frac{1409 }{1667}\tanh ^{-1}\left(\frac{692 }{523}x\right)$$ For a few values of $$a$$, some results (the so called "exact" being obtained by numerical integration) $$\left( \begin{array}{ccc} a & \text{approximation} & \text{exact} \\ 0.05 & 0.07795 & 0.07795 \\ 0.10 & 0.15637 & 0.15637 \\ 0.15 & 0.23577 & 0.23577 \\ 0.20 & 0.31670 & 0.31670 \\ 0.25 & 0.39982 & 0.39982 \\ 0.30 & 0.48593 & 0.48593 \\ 0.35 & 0.57609 & 0.57610 \\ 0.40 & 0.67171 & 0.67172 \\ 0.45 & 0.77482 & 0.77482 \\ 0.50 & 0.88848 & 0.88848 \\ 0.55 & 1.01775 & 1.01775 \\ 0.60 & 1.17192 & 1.17195 \\ 0.65 & 1.37127 & 1.37136 \\ 0.70 & 1.67673 & 1.67722 \\ 0.75 & 2.66909 & 2.68502 \end{array} \right)$$
We can make the approximation better using the fact that $$f(x)=\left(x^2-\frac{\pi }{2}+1\right)\frac{ \tan \left(x^2+1\right)}{x^2+1}$$ is a quite nice function. Using a $$[4,2]$$ Padé approximant, we get $$f(x) \simeq\frac {a_0+a_1 x^2+a_2 x^4 }{b_0+b_1 x^2 }$$ where $$a_0=3 (\pi -2) k \left(\pi (k ((k-1) k+2)-1)-2 \left(k^3+k\right)\right)$$ $$a_1=6 \pi -\left(k^2+1\right) \left(3 (\pi -2) \pi k^2+((8-5 \pi ) \pi -8) k+3 \pi ^2\right)$$ $$a_2=\left(k^2+1\right) \left(2 (\pi -2) (1+\pi ) k^2-2 \pi (1+\pi ) k-(\pi -10) \pi -4\right)$$ $$b_0=6 (k (k (\pi -(\pi -2) k)-2 \pi +2)+\pi )$$ $$b_1=2 \left(k \left(k \left(3 (\pi -2) k^2-3 \pi k+7 \pi -8\right)-6 \pi \right)+4 \pi -2\right)$$ leading to $$\int \frac{\tan{(1+x^2)}}{1+x^2}\,dx \simeq \frac{a_2 }{b_1}x-\frac{2 \left(b_1 (a_0 b_1-a_1 b_0)+a_2 b_0^2\right)}{\sqrt{b_0} b_1^{3/2} (2 b_0+(\pi -2) b_1)}\tan ^{-1}\left(\frac{\sqrt{b_1} }{\sqrt{b_0}}x\right) -\frac{(4 a_0+(\pi -2) (2 a_1+(\pi -2) a_2))}{\sqrt{2 (\pi -2)} (2 b_0+(\pi -2) b_1)}\tanh ^{-1}\left(\sqrt{\frac{2}{\pi -2}} x\right)$$ Making the same table as before $$\left( \begin{array}{ccc} a & \text{approximation} & \text{exact} \\ 0.05 & 0.07795 & 0.07795 \\ 0.10 & 0.15637 & 0.15637 \\ 0.15 & 0.23577 & 0.23577 \\ 0.20 & 0.31670 & 0.31670 \\ 0.25 & 0.39982 & 0.39982 \\ 0.30 & 0.48593 & 0.48593 \\ 0.35 & 0.57610 & 0.57610 \\ 0.40 & 0.67172 & 0.67172 \\ 0.45 & 0.77482 & 0.77482 \\ 0.50 & 0.88848 & 0.88848 \\ 0.55 & 1.01776 & 1.01775 \\ 0.60 & 1.17197 & 1.17195 \\ 0.65 & 1.37142 & 1.37136 \\ 0.70 & 1.67740 & 1.67722 \\ 0.75 & 2.68589 & 2.68502 \end{array} \right)$$ which looks quite better.