x=2*rand();
while(x<1)
x=2*rand();
end
tol=0.00009;
i=0;
while(1)
i=i+1;
f=x^3+x^2-4;
f1=3*x^2+2*x;
x1=x-(f/f1);
if x1==x || abs(x-x1)<=tol
x
i
break;
else
x=x1;
end
end
while(x<1)
x=2*rand();
end
tol=0.00009;
i=0;
while(1)
i=i+1;
f=x^3+x^2-4;
f1=3*x^2+2*x;
x1=x-(f/f1);
if x1==x || abs(x-x1)<=tol
x
i
break;
else
x=x1;
end
end
No comments:
Post a Comment