<s>[INST] evaluating the integral $\int \frac{e^x(x^4+2)dx}{(x^2+1)^{5/2}}$ It accidentally came out like this but I need a fine proof for it.
$$\int e^x\frac{d}{dx}\left(\ln\left(x+\sqrt{x^2+1}\right)+\dfrac{x}{(x^2+1)^{3/2}}\right) dx$$
I am unable to figure out why $$\int\dfrac{1-2x^2}{\left(1+x^2\right)^{5/2}}dx =\dfrac{x}{\left(x^2+1\right)^{3/2}}$$ (It comes in the middle of solving)
Please give hints on how to solve it.
 [/INST] So you want to find a way to show:

$$\int\frac{1-2x^2}{\left(1+x^2\right)^{5/2}} \,\mbox{d}x =\dfrac{x}{\left(x^2+1\right)^{3/2}}$$

Let $x = \tan t$, then:
$$\int\dfrac{1-2x^2}{\left(1+x^2\right)^{5/2}} \,\mbox{d}x \to \int\dfrac{1-2\tan^2t}{\left(1+\tan^2t\right)^{5/2}} \sec^2 t \,\mbox{d}t$$
Now use $1+\tan^2 = \sec^2t$ and simplify:
$$\int\dfrac{1-2\tan^2t}{\sec^3 t}  \,\mbox{d}t 
= \int \cos t \left( 1-3\sin^2 t \right) \,\mbox{d}t =\sin t - \sin^3t + C$$
First rewrite (this will make it easier to substitute back and simplify):
$$\sin t - \sin^3t = \sin t \left( 1 - \sin^2t \right)  = \sin t\cos^2t$$
Now you can substitute $t = \arctan x$ again and simplify:
$$\sin \left( \arctan x \right) \left( \cos \left( \arctan x \right) \right)^2 = \frac{x}{\sqrt{1+x^2}}\left( \frac{1}{\sqrt{1+x^2}} \right)^2 = \frac{x}{(1+x^2)^{3/2}}$$
</s>