Question

Use Newton's method to find the root of the equation x^2 - 2 = 0 with...

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.

Add a comment
Know the answer?
Add Answer to:
Use Newton's method to find the root of the equation x^2 - 2 = 0 with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT