% Newton Method to Solve f(x)=x*x - 4 Sin(x)=0,
% Date: October 16,2002
% by Yuri V Lvov
format long;
tolerance=.001; %tolerance to the result
pr = 3; next=0;
while ((abs(pr*pr - 4 * sin(pr))>tolerance)),
next=(pr-((pr*pr - 4 * sin(pr))/(2*pr-4*cos(pr))));
% This is x[k+1]=x[k]-f(x)/f'(x)
pr=next;
x=[next, next 2-4*sin(next)]
end