Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I solve this indefinite integral for an arbitrary integer $n>0$?

$$ \int{x^n e^x dx}$$

I could partially integrate it for small $n$, but that's not really a solution.

Edit: (TB) This question is closely related to: Is there a closed form solution for $\int x^n e^{cx}$?, but it is more elementary, because $n$ is an integer here.

share|cite|improve this question
This is not a duplicate of…, since in the present question $n$ is an integer. – Shai Covo Jun 20 '11 at 14:36
@Shai: Then vote to reopen. – t.b. Jun 20 '11 at 14:38
The "answer" to the other question involves the gamma function, which I don't think is necessary when n is a positive integer. – Tim Jun 20 '11 at 14:48
Why do you say it's not a solution? The answer obviously must contain all the powers of $x^k$ for $0 \leq k \leq n$ so the solution can't be much simpler than this. E.g. for $x > 0$ you might try $\left((-\partial_{\alpha})^n \int e^{-\alpha x}\right) \Big\vert_{\alpha = 1}$ but now you have to differentiate $n$ times so this is essentially the same thing. – Marek Jun 20 '11 at 15:06
up vote 21 down vote accepted

Hint: Use integration by parts.

EDIT: Try several values of $n$. $$ \int {x e^x dx} = (x - 1)e^x + C $$ $$ \int {x^2 e^x dx} = (x^2 - 2x + 2)e^x + C. $$ $$ \int {x^3 e^x dx} = (x^3 - 3x^2 + 6x - 6)e^x + C. $$ $$ \int {x^4 e^x dx} = (x^4 - 4x^3 + 12x^2 - 24x + 24)e^x + C. $$ $$ \int {x^5 e^x dx} = (x^5 - 5x^4 + 20x^3 - 60x^2 + 120x - 120)e^x + C. $$ Conclude that $$ \int {x^n e^x dx} = \bigg[\sum\limits_{k = 0}^n {( - 1)^{n - k} \frac{{n!}}{{k!}}x^k } \bigg]e^x + C. $$

share|cite|improve this answer
how to vote to reopen? – ziyuang Jun 20 '11 at 17:01
@ziyuang: You need 3000 reputation for that. As soon as you have that there is a link right below the question that says "reopen" (if the question is closed) and "close" if the question is open. @Shai: I removed all my previous comments, so you should probably delete yours as well. – t.b. Jun 20 '11 at 17:06
@Theo - done... – Shai Covo Jun 20 '11 at 17:14
In case you haven't noticed, the question is reopened now. – t.b. Jun 20 '11 at 23:21
@Theo, thanks, I have noticed that. – Shai Covo Jun 20 '11 at 23:32

You could use the generating function approach.
$$ \eqalign{\int_0^X e^{tx} e^x \ dx &= \frac{e^{(1+t)X} - 1}{1+t}\cr &= \sum_{k=0}^\infty (-1)^k t^k \left(e^X -1 + \sum_{j=1}^\infty e^X \,\frac{X^j}{j!} t^j\right)\cr &= \sum_{n=1}^\infty \left((-1)^n (e^X - 1) + \sum_{j=1}^n (-1)^{n-j} \frac{X^j}{j!} e^X \right) t^n\cr}$$ But also $$ \int_0^X e^{tx} e^x \, dx = \sum_{n=0}^\infty \frac{t^n}{n!} \int_0^X x^n e^x \, dx$$ Equating coefficients of $t^n$ from both sides, $$ \int_0^X x^n e^x\, dx = (-1)^n n! (e^X - 1) + \sum_{j=1}^n (-1)^{n-j} \frac{n!}{j!} X^j e^X $$

share|cite|improve this answer
Interesting coincidence! We must have been thinking about this in a similar way as I also posted this answer on Mike Spivey's follow up question. (Although it is admittedly more suited as a response here) See… – Eric Naslund Jun 21 '11 at 19:04

I find it a little difficult for me to guess the solution by trying several $n$. I would like to do it as following:

$$\begin{align}\int x^ne^xdx&=x^ne^x+(-1)n\int x^{n-1}e^xdx,\qquad n\geq 1\\ \int x^0e^xdx&=e^x\end{align}$$

Then you get the recurrence relation:

$$\begin{align}a_n(x)&=x^ne^x+(-1)na_{n-1}(x),\qquad n\geq 1\\ a_0(x)&=e^x\end{align}$$

With the recursive formula, it may be easier to find the pattern of the result.

share|cite|improve this answer
+1 for using the structure of the recursion. – Did Jun 21 '11 at 5:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.