SUNY Geneseo Department of Mathematics
Wednesday, March 29
Math 230 02
Spring 2017
Prof. Doug Baldwin
I will be out of town next Friday (April 7). Plans for class that day will be announced soon.
How to write a function that computes the derivative of another function?
Take inspiration from the definition of derivative: make a small change in x, and look at the rate of change in f with respect to x.
In Matlab this looks like this:
function [ y ] = derivative( f, x )
%DERIVATIVE Given a function, f, and an x value, return f'(x)
% Beware: x can't be 0
h = x * 1e-12;
y = ( f(x+h) - f(x-h) ) / (2*h);
end
The tolerance argument to Newton’s method is a number that controls how close to the exact zero Newton’s method will get. Smaller tolerances lead to more accurate zeros, although you can’t really calculate the “right” tolerance value ahead of time. Play around with it instead, e.g., try smaller or larger values and see if they lead to noticeably better or worse results, etc.
Numerical integration using Riemann sums and the trapezoid rule
Watch videos...