%finds the root of the function f(x)=exp(-2*x)-log(x);
AM=input('type AM:');
x0=input('type x0:');


while x0<0
    x0=input('wrong input! x0 should be a positive number');
end
tol=10^(-5);
f=exp(-1/AM*x0)-log(x0);
Df=-1/AM*exp(-1/AM*x0)-1/x0;

x1=x0-f/Df;

while abs(x1-x0)>tol
    x0=x1;
    f=exp(-1/AM*x0)-log(x0);
    Df=-1/AM*exp(-1/AM*x0)-1/x0;
    x1=x0-f/Df;
end
disp(['the root of f(x) is ', num2str(x1)])

root=x1;
    
    