% Tund 5, ülesanne 2
f=@(x) x^6-x-1;
fplot(f,[-2,2])
yline(0)
grid on
% alglähendid -0.1 ja 1
x=-0.1;
gtuletis=1/6*(x+1)^(-5/6);
abs(gtuletis)
x=1;
gtuletis=1/6*(x+1)^(-5/6);
abs(gtuletis)

x=-0.1;
i=0;
while abs(f(x))>10^(-5)
    x=-nthroot(x+1,6);  % uus g(x)
    i=i+1;
end
lahend1=x
sammud1=i

x=1;
i=0;
while abs(f(x))>10^(-5)
    x=nthroot(x+1,6);  % uus g(x)
    i=i+1;
end
lahend2=x
sammud2=i

x0=1;
x1=nthroot(x+1,6)
f(x0)
f(x1)