While preparing for my numerical analysis exam I encountered the following question
Find a recursive definition $I_n = R(I_{n - 1})$ for $I_n := \int_{0}^{1} x^n e^x dx$ and prove $$ I_n = \sum_{k = 0}^{n} (-1)^{k} \frac{n! e}{(n - k)!} - (-1)^n n! $$ and give an explanation for the behaviour of $I_n$ for $n \to \infty$.
With integration by parts I found $I_n = e - n I_{n - 1}$, $I_0 = e - 1$ and proved the formula with induction. Just for reference, is the following induction step correct? \begin{align} I_{n + 1} = e - (n + 1)I_n & = e - (n + 1)\left( \sum_{k = 0}^{n} (-1)^{k} \frac{n! e}{(n - k)!} - (-1)^n n!\right) \\ & = e - \sum_{k = 0}^{n} (-1)^{k} \frac{(n + 1)! e}{(n - k)!} - (-1)^{n + 1} (n + 1)! \\ & = e\left( 1 - \sum_{k = 0}^{n} (-1)^{k} \frac{(n + 1)!}{(n - k)!} \right) - (-1)^{n + 1} (n + 1)! \\ & = e\left( 1 - \sum_{k = 1}^{n + 1} (-1)^{k - 1} \frac{(n + 1)!}{(n - k + 1)!} \right) - (-1)^{n + 1} (n + 1)! \\ & = \sum_{k = 0}^{n + 1} (-1)^{k} \frac{(n + 1)! e}{(n + 1 - k)!} - (-1)^{n + 1} (n + 1)! \end{align} Now I am trying to investigate the behaviour for $n \to \infty$. First I rewrote $$ I_n = \sum_{k = 0}^{n} (-1)^k n! \left( \frac{e}{(n - k)!} - (-1)^{n - k}\right) $$ Wolfram Alpha yields $$ = (-1)^{n + 1} n! \left( n + 1 - e \sum_{k = 0}^{n} \frac{(-1)^k}{k!} \right), $$ but I don't know how to proceed from here. I though that the last term would cancel out since $\sum_{k = 0}^{\infty} \frac{(-1)^k}{k!} = \frac{1}{e}$ but I am not sure.
On the question paper, we are given the following numerical values:
0.2280015155 for n = 10,
0.1238038308 for n = 20,
0.08502696925 for n = 30,
0.06475689045 for n = 40 and
0.05229363830 for n = 50.
They are all positive and seem to be converging to 0. But because of the $(-1)^{n + 1}$ term I wouldn't expect this to converge.
Intuitively the result make perfect sense because for larger $n$ the $x^n e^x$ is very small for "most of" $[0,1]$ and then "in the last moment" rises steeply to $(1,1)$.
Note that $$I_n = n!(-1)^ne\left(\sum_{k = 0}^{n} \frac{(-1)^{n-k}}{(n - k)!} - e^{-1}\right)=n!(-1)^ne\left(\sum_{k = 0}^{n} \frac{(-1)^{k}}{k!} - e^{-1}\right).$$ Now recall Taylor's theorem with the Lagrange remainder and apply it to $f(x)=e^x$ with $x_0=0$: there is $t_n\in(-1,0)$ such that $$e^{-1}-\sum_{k = 0}^{n} \frac{(-1)^{k}}{k!}=R_n(x)=\frac{e^{t_n}}{(n+1)!}\left(-1\right)^{n+1}.$$ Hence, as $n$ goes to infinity, $$|I_n|=n!e\cdot \frac{e^{t_n}}{(n+1)!}\leq \frac{e}{(n+1)}\to 0.$$