# Integrating $x^2e^{-x}$ using Feynman's trick? [duplicate]

In the second episode of season $8$ of "The Big Bang Theory," which aired yesterday night, it is stated that one can integrate $x^2e^{-x}$ by using Feynman's trick of differentiating under the integral. Is this actually true, and if so, how to do it? And is it "better," in any sense, than the usual way of doing it by integration by parts?

• I wasn't the only one who immediately went to try this when I heard that?! Sep 23 '14 at 16:48
• This is the second question today that comes from this episode. Funny. Sep 23 '14 at 16:52
• What's the first? Sep 23 '14 at 19:54
• Sep 23 '14 at 20:22

If we just compute without thinking about problems such as interchanging integration and differentiation, the derivation is very simple. $$\int_0^{\infty} x^2e^{-x}dx=\left.\left(\frac{d}{d\alpha}\right)^2\right|_{\alpha=1}\int_0^{\infty} e^{-\alpha x}dx=\left.\left(\frac{d}{d\alpha}\right)^2\right|_{\alpha=1} \frac{1}{\alpha}=\left.\frac{2}{\alpha^3}\right|_{\alpha=1}=2.$$
If you want limits other than the positive real axis, the same trick allows you to arrive at $$\int_a^{b} x^2e^{-x}dx=\left.\left(\frac{d}{d\alpha}\right)^2\right|_{\alpha=1}\int_a^{b} e^{-\alpha x}dx=\left.\left(\frac{d}{d\alpha}\right)^2\right|_{\alpha=1} \frac{1}{\alpha}(e^{-a\alpha}-e^{-b\alpha}).$$ Of course, this can also be evaluated explicitly by using the Leibniz rule, but I will leave that up to you.
• Gives: $a^2 e^{-a}-b^2 e^{-b} + 2 \left(e^{-a}-e^{-b}\right)-2 \left(b e^{-b}-a e^{-a}\right)$ Sep 23 '14 at 17:11
• @UserX It is a two-fold application of Theorem 5 in the notes I linked to. The integrals are uniformly convergent because you have a bound of the type $x^n e^{-\alpha x}\leq C_n e^{-\alpha x/2}$ on the positive axis. As for setting $\alpha=1$, this is an application of Theorem 4 in the notes I linked to. Sep 26 '14 at 10:01
• Almost right. We use $$\frac{\partial^2}{\partial a^2} e^{-ax} =x^2 e^{-ax}.$$ Sep 26 '14 at 11:09