<s>[INST] How to evaluate this integral $\int^{\infty}_{-\infty} \frac{t^{2}}{2s^{2}} e^{-(t+ \frac{t^{2}}{2s^{2}} )} dt$ If the question was $\int^{\infty}_{-\infty} e^{-(t+ \frac{t^{2}}{2s^{2}} )} dt$, I'd have gone with completing the square of $(t+ \frac{t^{2}}{2s^{2}} )$ and using the normal density trick, but I am stumped with the additional factor. Integration by parts doesn't work either. Please help.
 [/INST] Note
\begin{align}
I &= \int^{\infty}_{-\infty} \frac{t^{2}}{2s^{2}} e^{-(t+ \frac{t^{2}}{2s^{2}} )} dt
= \int^{\infty}_{-\infty} \frac{t^{2}}{2s^{2}} e^{-\frac1{2s^2}(t+ s^2 )^2 +\frac12s^2}dt\\
& \overset{x=t+s^2}=\frac{e^{\frac{s^2}{2}}}{2s^2} \int^{\infty}_{-\infty} (x-s^2)^2 e^{-\frac{x^2}{2s^2}} dx
= \frac{e^{\frac{s^2}{2}}}{2s^2} \int^{\infty}_{-\infty} (x^2+s^4)e^{-\frac{x^2}{2s^2}} dx
\end{align}
Let $a=\frac1{2s^2}$ and use
$$J(a)=\int^{\infty}_{-\infty} e^{-ax^2}dx= \sqrt{\frac\pi a},\>\>\>\int^{\infty}_{-\infty} x^2e^{-ax^2}dx=-J’(a) = \frac{\sqrt\pi}{2a^{3/2}}$$
to obtain
$$I=  \frac{e^{\frac{s^2}{2}}}{2s^2} 
\left( \sqrt{2\pi}s^3 + \sqrt{2\pi} s^5\right)=\sqrt{\frac\pi2} e^{\frac{s^2}{2}}s(1+s^2)
$$
</s>