TITLE: $\int_0^{\infty}y^2e^{-y} dy$
QUESTION [5 upvotes]: To calculate $\displaystyle \int_0^{\infty}y^2e^{-y} dy$
=$\displaystyle -y^2e^{-y}-2ye^{-y}-2e^{-y}|_o^{\infty}$
This should fail at $\infty$, but the answer is given as 2. Seems like $e^{-y}$ "wins" over $y^2$. 
So, am I making a mistake here ? Please help.

REPLY [2 votes]: Consider that $\int f(t) e^{-t} dt=-f(t)e^{-t}+\int f'(t) e^{-t}dt$ so $\int_0^\infty f(t) e^{-t} dt=f(0)+f'(0)+f''(0)+\dots$ for functions $f$ such that $f(t)e^{-t}\to0$ as $t\to\infty$. In this case it's then obvious that $\int_0^\infty y^2 e^{-y} dy=0+0+2+0+\dots=2$.