<s>[INST] How can I evaluate $\int_{-\infty}^{\infty}\frac{e^{-x^2}(2x^2-1)}{1+x^2}dx$? How can I solve this integral: $$\int_{-\infty}^{\infty}\frac{e^{-x^2}(2x^2-1)}{1+x^2}dx.$$ Can I solve this problem using the Laplace transform? How can I do this?
 [/INST] To find $I=\int_{-\infty}^{\infty}\frac{e^{-x^2}(2x^2-1)}{1+x^2}dx$,
let us start by defining for $n \in \mathbb{N}$
$$
I_n = \int_{-\infty}^{\infty} x^{2n} e^{-x^2}\,dx
$$
and note that
$I_0=\sqrt{\pi}$, also called the Gaussian integral,
can be solved either by a beautiful polar coordinate trick
or by this technique, and that
$I_1=\frac{\sqrt{\pi}}{2}$ was shown
here. We can find the rest using
integration by parts. With
$$
\begin{array}{lcl}
v=-\frac{1}{2}e^{-x^2} && dv=xe^{-x^2}dx \\
u=x^{2n-1} && du=(2n-1)x^{2n-2}dx,
\end{array}
$$
for $n>1$ we have
$$
\begin{array}{lcl}
I_n &=& \int udv = uv - \int vdu \\
    &=& -\frac{1}{2} \left[ x^{2n-1} e^{-x^2} \right]_{-\infty}^{\infty}
        + \frac{2n-1}{2} \int_{-\infty}^{\infty} x^{2n-2} e^{-x^2} \\
    &=& \frac{2n-1}{2} I_{n-1}
\end{array}
$$
where the first right-hand term vanishes because
the exponential term dominates all polynomial terms.
This shows that, inductively,
$$
I_n = \frac{(2n)!}{2^{2n}n!} I_0
$$
But using $\frac{1}{1-t}=\sum_{n=0}^{\infty}t^n$,
we can expand the integrand of $I$:
$$
\frac{2x^2-1}{1+x^2} =
(2x^2-1) \sum_{n=0}^{\infty} (-1)^n x^{2n} =
2-3\sum_{n=0}^{\infty} (-1)^n x^{2n}
$$
and hence we get (noting that the integrals all
converge because of the dominating exponential term)
$$
\begin{array}{lcl}
I &=& 2I_0-3(I_0-I_1+\dots) = 2I_0-3 \sum_{n=0}^{\infty} (-1)^n I_n \\
  &=& \left( 2-3 \sum_{n=0}^{\infty} (-1)^n \frac{(2n)!}{2^{2n}n!} \right) I_0
\end{array}
$$
where the series
$$
  \sum_{n=0}^{\infty} (-1)^n \frac{(2n)!}{2^{2n}n!} = 
  1 - \frac{1}{2} + \frac{1 \cdot 3}{2 \cdot 2}
  - \frac{1 \cdot 3 \cdot 5}{2 \cdot 2 \cdot 2}
  + \cdots = e \sqrt\pi\; \text{erfc}(1)
$$
can also be expressed using
$\Gamma(\frac{1}{2}-n)=(-1)^n\frac{(2n)!}{4^{n}n!}\sqrt\pi$
and a series expansion for the complementary error function
as
$$
I = 2\sqrt\pi - 3 \; \sum_{n=0}^{\infty} \; \Gamma(\tfrac{1}{2}-n)
  = 2\sqrt\pi - 3e\pi\;\text{erfc}(1) \;.
$$
</s>