function [y] = derivative( f, x )
% Solution to question 3, approximate f'(x) using a difference quotient and
% an "h" that depends on x, but is never 0.

    if -1e-20 <= x & x <= 1e-20
        h = 1e-30;
    else
        h = x * 1e-9;
    end
    
    y = ( f(x+h) - f(x) ) / h;
end
