clc; clear; close all
%MÉTODO DA SECANTE
f=@(x) exp(x)-2*x-1;
phi=@(x,y) x - (x-y).*f(x)./(f(x)-f(y));
E=1e-5;
D=1e-5;
Dr=D+1;
cont=0;
contmax=100;

x0=1; x1=2;
f0=f(x0); f1=f(x1);

while Dr>tau  && cont<=contmax && abs(f1)>E
    cont=cont+1;
    d=(f1-f0)/(x1-x0);
    xx=x1-f1/d;
    Dr=abs(xx-x1);
    x0=x1; x1=xx;
    f0=f1; f1=f(x1);
end

raiz=x
fraiz=f(x)
iteracoes=cont