School of Mathematics and Statistics MAST30028 Numerical Methods & Scientific Computing Week 5
Drag and drop the folder Week5 from L: \MAST30028 to C:\…\MATLAB and include it in the path. Now MATLAB knows how to find the files in Week5.
1 Error propagation
These relate to material in Lecture 8.
Exercise Set 1
a. A recurrence relation
Prove (it’s easy!) that the integral
In =
satisfies the 2-term recurrence relation (or difference equation)
In = 1/n − 2In−1
Hint: rewrite x/(x + 2).
Prove that I0 = log(3/2) and that 0 < In < 1/n.
This algorithm is implemented in BadRecurrence.m in order to compute I100. Run it.
Explain the magnitude of the error you find.
Explain how you could run the recurrence backwards, starting from an estimate for I200. This algorithm is implemented in GoodRecurrence.m. Run it. What do you find?
b. A numerical derivative.
A reasonable approximation for f′(x) might be expected to be f(x+h)−f(x), at least as h gets small (recall
h
how the derivative is defined ) .
This algorithm is implemented in ForwardDifference.m where f = exp and x = 1. Run it. What do you see?
Explain why the error first falls as h is reduced, then rises.
! 1 0
xn x+2 dx
1
c. I would feel quite justified in asking an exam question like the following: only attempt after you have completed Exercise 1a.
Suppose we want to compute the integrals
In =1−nIn−1 0