Question: Newton's Method You will create two zero - finding functions newton.m and secant.m . These functions will be similar, but the first will use an

Newton's Method
You will create two zero-finding functions newton.mand secant.m. These functions will be similar, but the first will use an analytical derivative and the second will compute the derivative numerically.
Base your functions around the main Newton's Method iteration formula
to find the root, stopping when , where is the specified tolerance.
Your function declaration for newton.mshould look like
function [x,n]= newton(f,fp,x0,tol)
where fis a the function you're finding the root for, fpis the derivative of f(also a handle), x0is the starting guess, and tolis an optional argument for the error tolerance (default 1e-10). Have your program count the number of iterations for comparisons to bisect.m.
For secant.m, instead of passing an analytical derivative, you will make a subfunction that computes forward differencederivative approximation
.
Your subfunction will take f, x0, and tolas its inputs and return a numerical approximation to the derivative to use in the above formula for Newton's Method. The declaration of the main function secant.mwill look like
function [x,n]= secant(f,x0,tol)
where the variables and the their meanings remain the same as in newton.m.
What to Turn In:
Make a PDF of you testing these functions on our example from class and compare it to bisect.m. Start with bisect.mand find the root in [0.5,1], having the number of iterations required display in your results. Then use newton.mand secant.mon the same function starting at 0.5 and showing the iteration count.

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 Programming Questions!