# Why doesn't this work for integrating $x^2e^{-ax^2}$ by parts?

So I'm trying to integrate $$\int_{-\infty}^\infty{ }x^2e^{-ax^2}dx$$ by parts with the formula

$$\int{udv} = uv - \int{vdu}$$

I'm selecting

$$u = x^2$$ $$du = 2xdx$$ $$v = \sqrt{\pi/\lambda}$$ $$dv = e^{-ax^2} dx$$

This gives me

$$\Biggr|_{-\infty}^{\infty}{x^2 \sqrt{\pi/\lambda} } - \int_{-\infty}^\infty{ } \sqrt{\pi/\lambda} * 2x dx$$

Which equates to $$0$$.

This particular integral has been asked about before and I know how to solve it through integration by parts the "right way", but my question is why isn't the above a "legal move"? I solved another integral by evaluating the Gaussian integral during an integration by parts set-up just like this and it gave me the correct answer. I know I'm wrong, just not why.

Edit: My apologies, made an error in the type-up that made the whole thing nonsense, had $$x^2$$ as a factor of $$dv$$ by mistake.

• I think it must be $$a>0$$! – Dr. Sonnhard Graubner Jan 27 at 9:09
• Your $\;v'\;$ and thus your $\;v\;$ must be actual functions', not merely numbers! If $\;v'=k\in\Bbb R\;$ , then clearly $\;v=kx\;$ ...! – DonAntonio Jan 27 at 9:09
• @DonAntonio Why do they have to be functions? – Bookie Jan 27 at 9:12
• @Dr. Sonnhard Graubner I don't understand what you're saying here. – Bookie Jan 27 at 9:12
• $$\int_a^budv=(uv)\Big|_a^b-\int_a^bvdu$$You have to apply the limits to the aggregate $uv$, not to $u,v$ separately – Shubham Johri Jan 27 at 9:31

Assuming $$\;\alpha >0\;$$ , put
$$\begin{cases}u=x,&u'=1\\{}\\ v'=xe^{-\alpha x^2},&-\frac1{2\alpha}e^{-\alpha x^2}\end{cases}\;\;\;\implies\int_{-\infty}^\infty x^2 e^{-\alpha x^2}dx=\overbrace{-\left.\frac1{2\alpha}xe^{-\alpha x^2}\right|_{-\infty}^\infty}^{=0}+\frac1{2\alpha}\int_{-\infty}^\infty e^{-\alpha x^2}dx=$$
$$=\frac1{2\alpha^{3/2}}\int_{-\infty}^\infty d(\sqrt\alpha\,x)\,e^{-\left(\sqrt\alpha\,x\right)^2}=\frac{\sqrt\pi}{2\alpha^{3/2}}$$