Department of Mathematics

Math 300: Mathematical Computing

Matlab ICE

Recall that we can approximate the derivative of a function f at a point x using the formula
f'(x) ~ Fh = (f(x+h)-f(x-h)) / (2h).

For this exercise, you must write a function deriv_test that takes three arguments: the function f, the point where the derivative is to be approximated x, and the correct value of the derivative. Thus, the function will be called as deriv_test(f,x,correct). The function will compute the above approximation to the derivative for values of h going down in powers of ten, with exponent p, from 10-1 to 10-16. It will plot the absolute error |f'(x)-Fh|
for each of those values of p = -1, -2, ..., -16. In other words, the power p of 10 is on the horizontal axis, and the error is on the vertical axis. The function must return the vector of approximations to the derivative.

Assignment C is posted.

The test solution is available.

Department of Mathematics, PO Box 643113, Neill Hall 103, Washington State University, Pullman WA 99164-3113, 509-335-3926, Contact Us
Copyright © 1996-2015 Kevin Cooper