function x = tutorial1(x,nMax,tol)%it would be easier if everything was just x
f=@(x)x^3-3^x+1;%should place functions outside your loop
df=@(x)3*x^2-3;%not sure why your equation had a log(3)
for i = 1 : nMax
x = x - f(x)/df(x);
fprintf('Iteration = %d, x1 = %.4f, f(x) = %.4f\n',i,x,f(x));
if abs(f(x)) < tol%I assume you are measuring error with respect to the zero root
return;
end
end
