MATH 3650 Homework 5
MATH 3650 Homework 5
(a) Use Forward Difference, Backward Difference, and Centered Difference to approximate
the first derivative of the function
f (x) = exp(x3 )
at the point x0 = 1 with values h = 41 , 18 , . . . , 2−10 .
(b) Then compute the absolute error (what is the exact value?) for each of the three
methods and show it as a table with columns h, errF D , errBD , errCD .
(c) Now create a log-log plot for each of those columns (x axis is h, y axis is the error). Is
the result what you expect?
(d) Compute the error rate for each of the columns (ratio between two consecutive entries)
and show it as a table with columns h, rateF D , rateBD , rateCD .
If err is a row vector containing your errors, you can use the expression
rate=[0, err(1:end-1)./err(2:end)];
4. Submit finite_difference_laplace.m and hw05q4.m :
1
(b) Use the code in a) to solve u00 (x) = cos(3x) with u(0) = 0 and u(5) = 1 for different
values of N : N = 7, N = 13, and N = 25. Plot the three solutions together with the
exact solution in a single plot. Include a legend. Hint: make sure that your boundary
values are correct and that your solution for N = 25 is very close to the exact solution.
The exact solution is:
1
u(x) = (8x + x cos(15) − 5 cos(3x) + 5)
45