Question

(1) When using an iterative method such as Newtons Method one can be pretty sure that pn is accurate to k decimal places if

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

*Matlab code for finding Root using Newton method clear all close all fun=@(x) x.*3-2; fprintf(Function for which root have

%Matlab code for finding Root using Newton method
clear all
close all
fun=@(x) x.^3-2;
fprintf('Function for which root have to find\n')
disp(fun)
x0=0.5; %Initial guess
tol=10-10; %maximum iteration
[root,iter]=newton_method(fun,x0,tol);
fprintf('Root using Newton method for initial guess %f is %2.15f with iteration count %d.\n\n',x0,root,iter);

%Matlab function for Newton Method
function [root,iter]=newton_method(fun,x0,tol)
syms x
g1(x) =diff(fun,x);   %1st Derivative of this function
xx=x0;            %initial guess]
%Loop for all intial guesses
    n=tol; %error limit for close itteration
    maxit=1000;
    for i=1:maxit
        x2=double(xx-(fun(xx)./g1(xx))); %Newton Raphson Formula
        %cc=abs(fun(x2));                 %Error
        cc=abs(xx-x2);
        err(i)=cc;
        xx=x2;
        if cc<=n
            break
        end
      
    end
    root=xx;
    iter=i;
end

%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
(1) When using an iterative method such as Newton's Method one can be pretty sure that...
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
ADVERTISEMENT