## ganeshie8 one year ago show that $\int x^ne^x\,dx = e^x\left[x^n-nx^{n-1}+n(n-1)x^{n-2}-n(n-1)(n-2)x^{n-3}\\~~~~~~~~~+\cdots + (-1)^nn!\right]$

1. ganeshie8
2. ganeshie8

+C ofcourse..

3. amoodarya

$I_n=\int\limits x^n e^xdx =\\x^n e^x -\int\limits e^x (nx^{n-1})dx =\\$

4. amoodarya

$I_n=x^n*e^x -n*I_{n-1}$

5. amoodarya

$I_{n}=x^n*e^x- n*(x^{n-1}*e^x -(n-1)I_{n-2})$

6. amoodarya

and so on ... to get formula

7. ganeshie8

Ahh IBP works out smoothly!! Any alternatives ? This feels like a famous integral, I'm pretty sure there must be many ways to work this...

8. ganeshie8

The numbers happen to be coming from the columns of below inverse matrix http://www.wolframalpha.com/input/?i=inverse+%7B%7B1%2C1%2C0%2C0%2C0%2C0%7D%2C%7B0%2C1%2C2%2C0%2C0%2C0%7D%2C%7B0%2C0%2C1%2C3%2C0%2C0%7D%2C%7B0%2C0%2C0%2C1%2C4%2C0%7D%2C%7B0%2C0%2C0%2C0%2C1%2C5%7D%2C%7B0%2C0%2C0%2C0%2C0%2C1%7D%7D for example, the last column gives the coeffieitnes for $$\int x^5 e^x\,dx$$ and the fifth column gives the coefficients for $$\int x^4e^x\, dx$$ etc... makes me wonder if there is a direct formula to work that inverse, that matrix itself looks pretty patterny...

9. thomas5267

\begin{align*} R&=e^x\left[x^n-nx^{n-1}+n(n-1)n^{x-2}-n(n-1)(n-2)x^{n-3}+\cdots+(-1)^nn!\right]\\ &=e^x\sum_{k=0}^n\frac{(-1)^k n!}{(n-k)!}x^{(n-k)}\\ R'&=e^x\sum_{k=0}^n\frac{(-1)^k n!}{(n-k)!}x^{(n-k)}+e^x\sum_{k=0}^{n-1}\frac{(-1)^k n!}{(n-1-k)!}x^{(n-k-1)}\\ R'&=e^x\sum_{k=0}^n\frac{(-1)^k n!}{(n-k)!}x^{(n-k)}+e^x\sum_{k=1}^{n}\frac{(-1)^{k+1} n!}{(n-k)!}x^{(n-k)}\\ &=e^xx^n \end{align*} The idea is correct but the index shift in sum is probably not.

10. ganeshie8

I thought you would take left hand side and replace $$e^x$$ by its series. But your method looks interesting!

11. thomas5267

Just find a closed form sum of the right hand side and differentiate both sides.

12. Kainui

Here this looks less painful: $\int x^ne^x dx = \int x^n \sum_{k=0}^\infty \frac{x^k}{k!} dx = \int \sum_{k=0}^\infty \frac{x^{k+n}}{k!} dx = \sum_{k=0}^\infty \int \frac{x^{k+n}}{k!} dx$ $\sum_{k=0}^\infty \int \frac{x^{k+n}}{k!} dx = \sum_{k=0}^\infty \frac{x^{k+n+1}}{k!(k+n+1)} + C$ $= x^{n+1} \sum_{k=0}^\infty \frac{x^{k}}{(k+1)!+n k!} + C$

13. ganeshie8

is it easy to get a finite sum out of that, looks that has to break up as some weird combinations of $$e^x$$ and polynomials

14. Kainui

Yeah I'm sorta working on breaking that up using partial fractions right now instead of factoring it like I did. This is a fun problem I tried about 3 years ago but sorta gave up on it. It's sorta related to the gamma function I think, it's pretty interesting, what makes you interested in it? :D

15. ganeshie8

linear transformations ofcourse! i remember something similar from one of your posts : $\int e^{ax}\sin(bx) \,dx$ If I recall correctly, you had worked it by choosing basis as $$\{e^{ax}\cos(bx),~e^{ax}\sin(bx)\}$$ or something similar to that

16. Kainui

Ahhh yeah that's a fun one. :P

17. Kainui

I think specifically when I was showing mathslover that XD

18. ganeshie8

Oh yeah right! that post

19. ikram002p

you guys have elephant memory :-\ i cant even remember what food i had for dinner xD

20. Kainui

Hahaha ok but that was a fun thread though so that's why it stands out so much, even if it was like 1 or 2 years ago XD

21. thomas5267

No I am not expanding $$e^x$$ but rewriting the polynomial on the right hand side using sigma notation and differentiate term by term.

22. thomas5267

$\left[x^n-nx^{n-1}+n(n-1)n^{x-2}-n(n-1)(n-2)x^{n-3}+\cdots+(-1)^nn!\right]\\ =\sum_{k=0}^n\frac{(-1)^k n!}{(n-k)!}x^{(n-k)}\\$

23. Kainui

Ok here's a possible linear transformation way, I think it'll work: So I'll just write the basis in two different ways: B={$$e^x,xe^x,x^2e^x,x^3e^x,\dots$$} = {$$y_0,y_1,y_2,y_3, \dots$$} $Dy_n = y_n+ny_{n-1}$ So you can try that out, and then see we have two matrices sorta working here, the first is an identity matrix and the second is sorta like a shift matrix and has n in it. This is actually just the regular derivative matrix for if our basis didn't have $$e^x$$ in there (you can kinda believe this from the product rule just multiplying $$e^x$$ and then differentiating the polynomial): $Dy_n = I y_n+Ay_n$ So to be clear about what I'm writing: $Iy_n = y_n$$Ay_n = n y_{n-1}$ $D=I+A$ Ok so the problem we have is that $$A$$ is an infinite matrix. Luckily though, we don't need to know all the entries, just enough up to what we're interested in, since we can see that the derivative matrix will only map from our basis at the place $$n$$ to $$n-1$$ that means the inverse matrix which exactly reverses this can at most map backwards to $$n$$ and $$n+1$$. So that means we just need to find the derivative matrix up to $$n+1$$ more than what we want to integrate, simple as that. I'll show an example. $\int x^2e^x dx$ So we have to calculate the derivative matrix for up to 3. So that means we have: $D = I+ A = \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} + \begin{bmatrix} 0& 1 & 0 & 0\\ 0 & 0& 2& 0\\ 0 & 0 & 0 & 3\\ 0 & 0 & 0 & 0 \end{bmatrix} =\begin{bmatrix} 1& 1 & 0 & 0\\ 0 & 1& 2& 0\\ 0 & 0 & 1 & 3\\ 0 & 0 & 0 & 1 \end{bmatrix}$ Now we invert this matrix... with matlab... $D^{-1} = \begin{bmatrix} 1& -1 &2 & -6 \\ 0 & 1& -2& 6\\ 0 & 0 & 1 & -3\\ 0 & 0 & 0 & 1 \end{bmatrix}$ Multiply by the vector representing our integral: $\begin{bmatrix} 1& -1 &2 & -6 \\ 0 & 1& -2& 6\\ 0 & 0 & 1 & -3\\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 0\\ 0\\ 1\\ 0 \end{bmatrix} = \begin{bmatrix} 2\\ -2\\ 1\\ 0 \end{bmatrix}$ Ok moment of truth, hopefully I didn't mess this up... $\int x^2e^xdx = e^x(2-2x+x^2) + C$ Hey it checks out :P Also, maybe we can possibly find a general form for the inverse of this matrix?

24. Kainui

Looking through this it appears that maybe my reasoning was off, since if we throw in the vector corresponding to $$\int x^3e^xdx$$ it seems to work as well. So perhaps for that last example we could have done it with a 3x3 matrix.

25. thomas5267

$B=\{x^ne^x,x^{n-1}e^x,x^{n-2}e^x,\dots,xe^x,e^x\}=\{y_1,y_2,y_3,\dots,y_{n+1}\}\\ D_{n}y_n=y_n+ny_{n-1}\\ D_{n}= \begin{bmatrix} 1 &0&\cdots&\cdots&\cdots&\cdots&0\\ n&1&\ddots &\ddots&\ddots&\ddots&\vdots\\ 0&n-1&1&\ddots &\ddots&\ddots&\vdots\\ \vdots&0&n-2&1&\ddots &\ddots&\vdots\\ \vdots&\vdots&0&\ddots &\ddots&\ddots &\vdots \\ \vdots&\vdots &\vdots&\ddots&2&1&0 \\ 0&0&0&0&0&1&1 \end{bmatrix}\;(n+1)\times (n+1)\text{ matrix}\\ D_n^{-1}\text{ exists as }\det(D_n)=1 \text{ as }D_n\text{ is lower triangular.}\\ \text{Moreover, }D_n^{-1}\text{ is an integer matrix as }\det(D_n)=1\text{ (1 is invertible in }\mathbb{Z}\text{)}$