% Newton method for finding roots of functions of a single variable using
% a numeric approximation of the derivative of F
function root=newton_num(F, guess)
iter=1;
maxiter=100;
x=guess;
accuracy=1;
tolerance=1e-12;
h = 1e-8;
while accuracy>tolerance && iter<maxiter
    Fp = (F(x+h) - F(x))/h;
    x=x-F(x)/Fp;
    accuracy=abs(F(x));
    iter=iter+1;
end
root=x;
end