# Integral $\int \exp\left(-\frac{z^2}{2}\right) \frac{z^4+2z^2-1}{(z^2+1)^2}dz$

Integrate $$\int \exp\left(-\frac{z^2}{2}\right) \frac{z^4+2z^2-1}{(z^2+1)^2}dz$$

This function has exponential factor and rational factor.

I know already that the solution is

$$-\frac{z\exp\left(-\frac{z^2}{2}\right)}{z^2+1} + C$$

But I have no idea on what method should I use to find it.

• @MorganRodgers No, there are no typos. – Nick Feb 10 at 17:08

$$I=\int e^{\large-\frac{z^2}{2}}\, \frac{z^4+2z^2-1}{(z^2+1)^2}dz$$ With some algebra we have: $$z^4+z^2+z^2-1=z^2(z^2+1) +z^2-1$$ $$\Rightarrow \frac{z^4+2z^2-1}{(z^2+1)^2}=\frac{z^2}{z^2+1}+\frac{z^2-1}{(z^2+1)^2}$$ $$\Rightarrow I= \color{blue}{\int e^{-\frac{z^2}{2}}\frac{z^2}{z^2+1}dz}+\color{red}{\int e^{-\frac{z^2}{2}} \frac{z^2-1}{(z^2+1)^2}dz}$$ Now since we have similarly to here:$$\int \frac{z^2-1}{(z^2+1)^2}dz=-\frac{z}{z^2+1}+C$$ Integrating by parts the second integral gives us: $$\int e^{-\frac{z^2}{2}} \, \frac{z^2-1}{(z^2+1)^2}dz=\color{red}{-e^{-\frac{z^2}{2}}\frac{z}{z^2+1}-\int e^{-\frac{z^2}{2}}\frac{z^2}{z^2+1}dz}$$ $$\require{cancel}\Rightarrow I= \cancel{\color{blue}{\int e^{-\frac{z^2}{2}}\frac{z^2}{z^2+1}dz}}\color{red}{-e^{-\frac{z^2}{2}}\frac{z}{z^2+1}-\cancel{\int e^{-\frac{z^2}{2}}\frac{z^2}{z^2+1}dz}}$$ $$\Rightarrow \int e^{\large-\frac{z^2}{2}}\, \frac{z^4+2z^2-1}{(z^2+1)^2}dz=-e^{-\frac{z^2}{2}}\frac{z}{z^2+1}+C$$
• Just for clarification to others, the integration by parts was $dv=\frac{z^2-1}{(z^2+1)^2} dz$,$u=e^{-z^2/2}$. This is sort of the "magic choice" to avoid having any arctan term, and then the problem itself was set up "magically" to have the second term of the integration by parts exactly cancel the blue term that you separated to begin with. – Ian Feb 10 at 19:36
If $$f$$ and $$g$$ are differentiable functions, as $$\frac{d}{dx} (e^{f(x)} g(x)) = e^{f(x)}[f'(x) g(x) + g'(x)],$$ it is immediate that $$\int e^{f(x)} \left (f'(x) g(x) + g'(x) \right ) \, dx = e^{f(x)} g(x) + C.$$
In the case of the integral $$\int e^{-\frac{x^2}{2}} \frac{x^4 + 2x^2 - 1}{(x^2 + 1)^2}, dx,$$ Here $$f(x) = -x^2/2$$, $$f'(x) = -x$$. For the function $$g$$ we have $$f'(x) g(x) + g'(x) = - x g(x) + g'(x) = \frac{x^4 + 2x^2 - 1}{(x^2 + 1)^2}.$$
Conjuring up the function $$g(x)$$ is the hard bit. The squared term appearing in the denominator suggests we try something like: $$g(x) = h(x)/(x^2 + 1)$$. After a little trial and error it is not too hard to see that $$h(x)$$ must be $$-x$$ and we have $$g(x) = -\frac{x}{x^2 + 1}.$$ Thus $$\int e^{-\frac{x^2}{2}} \frac{x^4 + 2x^2 - 1}{(x^2 + 1)^2}, dx = -\frac{x}{x^2 + 1} e^{-\frac{x^2}{2}} + C.$$