function [root]=N_R(x0,AM)
%finds the root of the function f(x)=exp(-2*x)-log(x);


    if x0<0
        disp('wrong input! x0 should be a positive number')
        root=NaN;
    else
        tol=10^(-5);
        x1=x0-f(x0,AM)/Df(x0,AM);

        while abs(x1-x0)>tol
            x0=x1;

            x1=x0-f(x0,AM)/Df(x0,AM);
        end
        disp(['the root of f(x) is ', num2str(x1)])
        
        root=x1;
    end
    
end

function [x]=f(x0,AA)
    x=exp(-1/AA*x0)-log(x0);
end

function [x]=Df(x0,AA)
    x=-1/AA*exp(-1/AA*x0)-1/x0;
end