Use Newton's method to find the root of the equation x^2 - 2 = 0 with the accuracy too = 0.001 and tok = 0.00001. Compare the number of iterations. Draw the graphs. Use MATLAB.
Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
clc
clear all
close all
f = @(x) x^2-2;
g=@(x) 2*x;
er=[0.001 0.00001];
for i=1:2
e=er(i);
fprintf(' For tol = %f ',e);
x0=10;
maxit=100;
x1=x0;
x0=0;
N=0;
err=[];
while 1
if abs((f(x1)))>e
x0=x1;
x1=x0-(f(x0)/g(x0));
N=N+1;
err(N)=abs(x1-x0)/x1;
fprintf('Iteration %d, root=%2.8f ',N,x1);
else
break;
end
if(N==maxit)
break;
end
end
root=x1;
iter=N;
disp('So, net number of iterations needed are')
disp(iter)
disp('So, finl approximation is')
disp(root)
figure;
plot(err);
end

Kindly revert for any queries
Thanks.
Use Newton's method to find the root of the equation x^2 - 2 = 0 with...