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 zerofinding 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 xn newtonffpxtol
where fis a the function you're finding the root for, fpis the derivative of falso a handle xis the starting guess, and tolis an optional argument for the error tolerance default e 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 x 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 xn secantfxtol
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 having the number of iterations required display in your results. Then use newton.mand secant.mon the same function starting at and showing the iteration count.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
