# Integrating $\int_0^{\infty} u^n e^{-u} du$

I have to work out the integral of

$$I(n):=\int_0^{\infty} u^n e^{-u} du$$

$$I(n) = nI(n - 1)$$

and then using the Gamma function, this gives $I(n) = n!$

What I do is this:

$$I(n) = \int_0^{\infty} u^n e^{-u} du$$

Integrating by parts gives

$$I(n) = -u^ne^{-u} + n \int u^{n - 1}e^{-u}$$

Clearly the stuff in the last bit of the integral is now $I(n - 1)$, but I don't see how using the limits gives you the answer. I get this

$$I(n) = \left( \frac{-(\infty)^n}{e^{\infty}} + nI(n - 1) \right) - \left( \frac{-(0)^n}{e^{0}} + nI(n - 1) \right)$$

As exponential is "better" than powers, or whatever its called, I get

$$I(n) = (0 + I(n - 1)) + ( 0 + nI(n - 1)) = 2nI(n - 1)$$

Does the constant just not matter in this case?

Also, I do I use the Gamma function from here? How do I notice that it comes into play? Nothing tells me that $\Gamma(n) = (n - 1)!$, or does it?

-
Ok, I see the constant wouldn't change the Gamma function much. I still don't get why you just use the limits on the $-u^n e^{-u}$ and not on the whole thing, so it includes $nI(n - 1)$. Also, I still don't see how you notice the factorial bit for the Gamma function. –  Kaish Dec 23 '12 at 16:22
Well, $nI(n-1)$ is independent of $u$, so it is included in the limit, you just pull it out of the limit. –  dirty derwin Dec 23 '12 at 16:23
What do you mean "pull it out of the limit"? –  Kaish Dec 23 '12 at 16:25
It's a pretty basic fact of limits that $\lim_{x->a}(f(x)+c)=c+\lim_{x->a}f(x)$ as long as $\frac{\partial c}{\partial x}=0$. –  dirty derwin Dec 26 '12 at 6:11

You're doing something very problematic which is "evaluating at $\infty$". Improper integrals are to be evaluated as limits. So, you're looking at

$$I(n)=\lim_{m\to\infty}\int_0^m x^n e^{-x} dx=\int_0^\infty x^n e^{-x}dx$$

You're integrating by parts by writting an extra $nI(n-1)$ term (careful), so you ought to be writting

$$I(n) = \left(\lim_{m\to\infty} \frac{-m^n}{e^{m}} - \frac{-0^n}{e^{0}}\right) + nI(n - 1)$$

$$\underbrace {I(n)}_{udv} = \underbrace {\left( {\mathop {\lim }\limits_{m \to \infty } {{ - {m^n}} \over {{e^m}}} - {{ - {0^n}} \over {{e^0}}}} \right)}_{uv} + \underbrace {nI(n - 1)}_{vdu}$$

So that

$$I(n) = -\lim_{m\to\infty} \frac{m^n}{e^{m}} + nI(n - 1)$$

Now, can you evaluate

$$\lim_{m\to\infty} \frac{m^n}{e^{m}} ?$$

To make simpler, we could even do as follows. Set $$G(m,n)=\int_0^m x^n e^{-x}dx$$

Now, we integrate by parts

$$\displaylines{ G(m,n) = \int_0^m {{x^n}} {e^{ - x}}dx \cr = \left. { - {x^n}{e^{ - x}}} \right|_0^m + n\int_0^m {{x^{n - 1}}} {e^{ - x}}dx \cr = - {m^n}{e^{ - m}} + {0^n}{e^{ - 0}} + n\int_0^m {{x^{n - 1}}} {e^{ - x}}dx \cr = - {m^n}{e^{ - m}} + nG(m,n - 1) \cr}$$

Thus, taking $m\to \infty$,

$$\displaylines{ \Gamma \left( n+1 \right) = \mathop {\lim }\limits_{m \to \infty } G(m,n) \cr = \int_0^\infty {{x^n}} {e^{ - x}}dx \cr = - \mathop {\lim }\limits_{m \to \infty } {m^n}{e^{ - m}} + n\mathop {\lim }\limits_{m \to \infty } G(m,n - 1) \cr = 0 + n\Gamma \left( {n } \right) \cr = n\Gamma \left( {n} \right) \cr}$$

Without even considering the $\Gamma$ function, we get the desired recursion that implies $I(n)=n!$, or $\Gamma(n+1)=n!$. Note we just use $\Gamma$ because we know it "exists" but it'd be senseless to use the fact that $\Gamma(n+1)=n!$ to "solve" this, since we're precisely trying to figure out what $\Gamma(n+1)$ evaluates to.

-
The bit I just don't get is why do you say $\Gamma (n) = ...$. Why Gamma function? What makes you see that this is what you have to use? –  Kaish Dec 23 '12 at 16:35
I am not "using" anything. The Gamma function is defined for positive integers as the given integral. Actually, I should be writting $n+1$ instead of $n$. –  Pedro Tamaroff Dec 23 '12 at 16:39
I; prefer this approach. +1 –  Babak S. Dec 23 '12 at 16:39
Ohhhh, so that integral IS the Gamma function? It's what the Gamma function is defined as? So once I notice that special form of it, I can then write it in terms of $\Gamma (n)$? –  Kaish Dec 23 '12 at 16:42
Yes, for real $s\geq 1$, the Gamma function is usually defined as $$\Gamma(s)=\int_0^\infty x^{s-1}e^{-x}dx$$ which can be proven exists for each $s\geq 1$. –  Pedro Tamaroff Dec 23 '12 at 16:46

There's a nice way using parametric differentiation. Consider $$I_0 = \int_0^{\infty} e^{-\alpha u}\, \mathrm du = \lim_{k\to +\infty} \int_0^{k} e^{-\alpha u}\, \mathrm du = \alpha^{-1}.$$

Differentiate this $n$ times with respect to $\alpha$ to get $$\frac{\mathrm d^n}{\mathrm d\alpha^{n}}I_0 = \frac{\mathrm d^n}{\mathrm d\alpha^{n}}\int_0^{\infty} e^{-\alpha u}\, \mathrm du = \int_0^{\infty} \frac{\partial^n}{\partial\alpha^{n}}e^{-\alpha u}\, \mathrm du = \frac{\mathrm d^n}{\mathrm d\alpha^{n}}\left(\alpha^{-1}\right) \\\implies (-1)^n\int_0^{\infty}u^n e^{-\alpha u}\,\mathrm du = (-1)^n\frac{n!}{\alpha^{n+1}}.$$ Now, take the limit $\alpha \to 1$ to finally get $$\int_0^{\infty} u^n e^{-u}\, \mathrm du = n!$$

-

Once you reincorporate the limits of integration, we get $$I(n)=\left[-u^ne^{-u}\right]_{u=0}^\infty+n\int_0^\infty u^{n-1}e^{-u}\,du=\left[-u^ne^{-u}\right]_{u=0}^\infty+nI(n-1).$$ You've correctly noted that the part in square brackets ends up vanishing, so we're left with $$I(n)=nI(n-1).$$

-
Ohh ok, I get that. So how does the gamma function bit come into it? –  Kaish Dec 23 '12 at 16:31

You have $$I(n) = \lim_{u\to +\infty}u^ne^{-u}-0^ne^{-0}+nI(n-1)$$ But $$\lim_{u\to +\infty}u^ne^{-u}=\lim_{u\to +\infty}\frac{u^n}{e^{u}}=...=0$$ and so $$I(n) =0-0+nI(n-1)=nI(n-1)$$

-