Syms x
Xnew=zeros (Max, 1);
Y=zeros (Max, 1);
Xold=zeros (Max, 1);
Xold (1)=x0;
Fp=the inline (diff (fun (x)));
For I=1: Max
Xnew (I)=xold (I) - (fun (xold (I))/fp (xold (I)));
Y (I)=feval (fun, xnew (I));
If (abs (xnew (I) - xold (I))
break;
End
If y (I)==0
Fprintf (' Exact solution found \ n ");
break;
End
Iter=I + 1;
End
If (iter> Max)
Fprintf (' Zero not found to desired how within the maximum number of iterations \ n ');
End
% the Output results
K=1: iter.
Fprintf (' iter xold xnew y \ n ');
Disp ([k 'xold (1: iter) xnew (1: iter) y (1: iter)]);