Question: The book has two different MATLAB versions of Newton's method. One is a program (on page 162) and the other is a function (page 170).

The book has two different MATLAB versions of Newton's method. One is a program (on page 162) and the other is a function (page 170). The comments on page 162 indicate the algorithm does not work on zero roots (i.e., it does not work when the true root is equal to zero). This is the case because of the form of "myrel".

Create a variation on the function m-file (page 170) in which the zero-root restriction is removed by changing the definition of "myrel." Specifically, do not divide by x; but leave the rest the same.

Then test your modified code on the MATLAB pre-defined "sin" function (and remember your differential calculus: the derivative of sine is simply cosine).

Set the initial guess to pi/4. [You can still name the function "newtfun_LastName.m"].

Create a driver routine named "test_newtfun_LastName.m" that specifies the input arguments and calls newtfun_LastName.m.

The book has two different MATLAB versions of Newton's method. One is

a program (on page 162) and the other is a function (page

% Newton's method in general % excludes zero roots! steps0; x input ( 'Initial guess: , ); re 1e-8; myre1 = 1; % iteration counter % estimate of root % required relative error while myrel re & (steps

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!