1. General Formula

I'm looking for the general formula of the integral of (x^n*e^x)dx

I know how the general formula begins and it looks something like this:

x^n - nx^(n-1) + n(n-1)x^(n-2) - n(n-1)(n-2)x^(n-3)...

I'm having trouble figuring out what comes at the end. The last number in the answer will always be n! and the second to last will always be n!x.

The signs are changing so, for example, when it is the integral of x^4*e^x the answer is (x^4-4x^3+12x^2-24x+24)e^x and if is the integral of x^3*e^x the answer is (x^3-3x^2+6x-6)e^x. As you can see for x^4*e^x then the second to last term is -24x and the last is +24 but for x^3*e^x the second to last term is +6x and the last term is -6

My point is, the signs, depending upon if n is even or odd, will always change and I'm not sure how to reflect that in the general formula.

2. Originally Posted by nick898
I'm looking for the general formula of the integral of (x^n*e^x)dx
Use integration by parts. Using the tabular method, with $\displaystyle u=x^n$ and $\displaystyle dv=e^x\,dx,$ we have

$\displaystyle \begin{tabular}{ccccc} Alternating&&$u$and its&&$v$and its\\ signs&&derivatives&&antiderivatives\\\hline +&$\rightarrow$&$x^n$&$_\searrow$&$e^x$\\ -&$\rightarrow$&$nx^{n-1}$&$_\searrow$&$e^x$\\ +&$\rightarrow$&$n(n-1)x^{n-2}$&$_\searrow$&$e^x$\\ -&$\rightarrow$&$n(n-1)(n-2)x^{n-3}$&$_\searrow$&$e^x$\\$\vdots$&$\vdots$&$\vdots$&$\vdots$&$\vdots$\\$+(-1)^n$&$\rightarrow$&$n!$&$_\searrow$&$e^x$\\ &&&&$e^x$\end{tabular}$

So the formula should be

$\displaystyle \int x^ne^x\,dx=\sum_{i=0}^n\frac{(-1)^in!\,x^{n-i}e^x}{(n-i)!}$

$\displaystyle =n!\,e^x\sum_{i=0}^n\frac{(-1)^ix^{n-i}}{(n-i)!}$

$\displaystyle =x^ne^x-nx^{n-1}e^x+n(n-1)x^{n-2}e^x-\cdots\mp n!\,xe^x\pm n!\,e^x,$

where the last term is positive for even $\displaystyle n$ and negative for odd $\displaystyle n.$