# Closed Form of $\int x^n e^x~\mathrm{d}x$

My calculus teacher showed us how to solve $$\displaystyle\int x^n e^x~\mathrm{d}x$$ by iteratively doing integration by parts. I figured out that $$\displaystyle\int x^n e^x~\mathrm{d}x$$ is equal to $$x^n e^x - n\int x^{n-1} e^x~\mathrm{d}x.$$ You can then iteratively find out what the solution is for any $n$. My question is whether or not there exists a closed form for this integral. Any help would be much appreciated.

• This might be interesting. – Zubzub Mar 8 '18 at 18:37
• That depends on your definition of "closed form" (no doubt, you don't have one). Please, note that the notation $\displaystyle\sum^n_{k=1}\ldots$ is just a shorthand for a recurrence, too. Is that "closed form"? – Professor Vector Mar 8 '18 at 18:39
• @ProfessorVector The exponential generating function of the polynomials involved does have a nice closed form, though. – Alexander Burstein Mar 8 '18 at 19:20
• I have changed the formatting of the title so as to make it take up less vertical space -- this is a policy to ensure that the scarce space on the main page is distributed evenly over the questions. See here for more information. Please take this into consideration for future questions. Thanks in advance. – GNUSupporter 8964民主女神 地下教會 Mar 12 '18 at 17:13

It is clear that the antiderivative is a polynomial of degree $n$, let $P(x)$.

Then by derivation,

$$(P(x)'+P(x))e^x=x^ne^x$$ or

$$P'(x)+P(x)=x^n.$$

This yields the recurrence relation

$$p_{k-1}=-kp_k$$ with

$$p_n=1.$$

The solution is

$$p_k=(-1)^{n-k}\frac{n!}{k!}.$$

Using General Leibniz Rule for the $n$'th derivative of a product, we have

\begin{align} \int x^ne^x\,dx&=\left.\left(\frac{d^n}{db^n}\int e^{bx}\,dx\right)\right|_{b=1}\\\\ &=\left. \frac{d^n}{db^n}\left(\frac{e^{bx}}{b}\right)\right|_{b=1}+C\\\\ &=\left. \left(\sum_{k=0}^n \binom{n}{k}\left(\frac{d^{n-k}e^{bx}}{db^{n-k}}\right)\left(\frac{d^k b^{-1}}{db^k}\right)\right)\right|_{b=1}+C\\\\ &=\sum_{k=0}^n\binom{n}{k}(-1)^k k! x^{n-k}e^x+C \end{align}

Alternatively, using the recursive relationship, $I_n=x^ne^x-nI_{n-1}$, we have

\begin{align} I_n&=x^ne^x-n(x^{n-1}e^x-(n-1)I_{n-2})\\\\ &=x^ne^x-nx^{n-1}e^x+n(n-1)I_{n-2}\\\\ &\vdots\\\\ &=(x^n-nx^{n-1}+n(n-1)x^{n-2}-n(n-1)(n-2)x^{n-3}\cdots+(-1)^nn!)e^x\\\\ &=\sum_{k=0}^n\binom{n}{k}(-1)^kk!x^{n-k}e^x \end{align}

which is as expected modulo the integration constant.

One may make a simple not of the two solutions provided. One states that $$I_{n} = \int e^{x} \, x^{n} \,~\mathrm{d}x = (-1)^{n} \, n! \, e^{x} \, \sum_{k=0}^{n} \frac{(-x)^{k}}{k!}$$ is a solution and the other is $$I_{n} = \int e^{x} \, x^{n} \,~\mathrm{d}x = e^{x} \, \sum_{k=0}^{n} \binom{n}{k} (-1)^{k} \, k! \, x^{n-k}.$$

By using the finite exponential (truncated exponential) function, $$e_{n}(x) = \sum_{k=0}^{n} \frac{x^k}{k!},$$ then the first becomes $$I_{n} = (-1)^{n} \, n! \, e^{x} \, e_{n}(-x).$$ The second can be placed in hypergeometric form as $$I_{n} = x^{n} \, e^{x} \, {}_{2}F_{0}\left(-n, 1; --; \frac{1}{x}\right).$$

From this the formula $$e_{n}(-x) = \frac{(-x)^{n}}{n!} \, {}_{2}F_{0}\left(-n, 1; --; \frac{1}{x}\right)$$ is obtained.

Let $$\int x^ne^x~\mathrm{d}x = p_n(x)e^x + C$$ for some polynomial $p_n(x)$, then from the integration by parts it follows that $p_n(x)=x^n-np_{n-1}(x)$, $n\ge 1$, and $p_0(x)=1$. Multiply both sides by $\dfrac{t^n}{n!}$ and sum over $n\ge 1$ to get $$\sum_{n\ge 1}{p_n(x)\frac{t^n}{n!}}=\sum_{n\ge 1}{x^n\frac{t^n}{n!}}-t\sum_{n\ge 1}{p_{n-1}(x)\frac{t^{n-1}}{(n-1)!}}.$$ Let $P(x,t)=\displaystyle\sum_{n\ge 0}{p_n(x)\dfrac{t^n}{n!}}$, then $P(x,t)-1=(e^{xt}-1)-tP(x,t)$, i.e. $$P(x,t)=\frac{e^{xt}}{1+t}.$$ It's easy to see that $\left[\dfrac{t^n}{n!}\right]e^{xt}=x^n$ and $\left[\dfrac{t^n}{n!}\right]\dfrac{1}{1+t}=(-1)^n n!$, so $p_n(x)$ is the exponential convolution of those sequences, i.e. $$p_n(x)=\sum_{k=0}^{n}\binom{n}{k}(-1)^{n-k}(n-k)!x^k=(-1)^n n!\sum_{k=0}^{n}(-1)^{k}\frac{x^k}{k!}.$$