Computing the following integral: \begin{equation*} I_n = \int_0^1 x^n e^x \: dx, \end{equation*} using the forward recursive formula \begin{align} I_0 &= e-1 \\ I_{n} &= e - n I_{n-1} \end{align} is an unstable calculation. Here we will consider a different approach that is stable.

Solve Equation (2) for $I_{n-1}$ to give a backwards recursive formula (one that expresses $I_{n-1}$ as a function of $I_n$).

$I_{n-1} = \frac{e-I_{n}}{n}$

Running both the recursion formulas in my MatLab program gives the following results

the unstable recursion the rewritten stable recursion

What I don't know how to answer is why does the backward recursive formula work so much better than the forward recursive formula? What is happening to the numerical error?


1 Answer 1


Assume a numerical error at step $n$ to be $\Delta_n$. Assume that the error in $e$ is $0$. Then using the forward formula, the error is increasing in absolute value: $$\Delta_n^F=n\Delta_{n-1}^F$$ In the backward formula $$\Delta_n^B=\frac1n\Delta_{n-1}^B$$ You can see that the backward value gets more precise.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .