Question: Secant method 6 solutions submitted (max: 10) | View my solutions Problem Summary Implement the secant method as a function: function [p, n] = secant

 Secant method 6 solutions submitted (max: 10) | View my solutions
Problem Summary Implement the secant method as a function: function [p, n]
= secant (f,x0, x1, tol) We seek a root of the anonymous
function f given initial guesses x0 and x1. We will stop iterating

Secant method 6 solutions submitted (max: 10) | View my solutions Problem Summary Implement the secant method as a function: function [p, n] = secant (f,x0, x1, tol) We seek a root of the anonymous function f given initial guesses x0 and x1. We will stop iterating once successive iterates are within tol of each other and will return the final iterate as our approximation p and the number of iterations n it took to get there. As a class convention, we count the two initial guesses as iterations. So, n = 3 is a single implementation of the secant method formula. My Solutions Test Results Solution 6: 0 of 6 tests passed Submitted about 23 hours ago | ID: 57808634 | Size: 63 X X X X X 1 function [p,n] = secant(f,x0, x1, tol) 2 %input f, root finding function 3 %inputs x0, x1, initial guesses 4 %input tol, a tolerance (stop once suo 5 %ouptput p, a root f(p) = 0 6 %output n, the number of iterations to 7 ei=1; 8 while(ei>tol) 9 X2 = x1-((f(x1)/(f(x1)-f(x0)))*(x1-0) 10 ei=abs(x1-x2); 11 x0=X1; 12 x1=x2; 13 end 14 P=x0; 15 end 16 X Newton's Method 3 solutions submitted (max: 10) | View my solutions Problem Summary Implement Newton's method as a function: function [p, n] = myNewton (f, fprime, xo, tol We seek a root of the anonymous function f given an initial guess x0. We input f and its derivative fprime. We will stop iterating once successive iterates are within tol of each other and will return the final iterate as our approximation p. Also output the number of iterations n it took to reach p. As a class convention, we say that the initial guess counts as 1 iteration. So, in a sense, n= 2 would mean we took one step of Newton's method. Function C Reset MATLAB Documentation 1 function [p, n] = myNewton(f, fprime, x0, 2 %input f, anonymous function for root 3 %input fprime, anonlymous function, th 4 %input xo, an initial guess 5 %input tol, a tolerance (method will 6 %output p, a root f(p) = 0 7 %output n, the number of iterations to 8 9 00 Code to call your function C Reset 1 %As a test, the root of f(x) = x+2^x 1 2% define f, fprime, an initial guess 3% send these into the function and ste 4% the method will converge in 6 iterat 5 format long % to display more digits 6 7

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!