Question: MAT LAB Write a function, function [x,N] = MyFixedPoint2(g, x1, tol, Nmax) that takes in a contraction function g, the starting x value x1, an
MAT LAB
Write a function, function [x,N] = MyFixedPoint2(g, x1, tol, Nmax) that takes in a contraction function g, the starting x value x1, an error tolerance tol, and a max number of steps Nmax. For this function, your code should end either when it has reached the error tolerance tol or has taken Nmax steps. (Hint: using an if-break statement can help with this. See Example 3 in the example file for more info on if-break loops) 3 This new addition to your code will prevent you from computing an extremely large number of steps for a case when the method is divergent (i.e. when your error keeps getting larger instead of smaller, the tolerance is never satisfied, and the fixed point cannot be found). Now, run this new code for the function from Problem 3, g(x) = 3x 1, with the same error tolerance and initial guess as you used for Problem 3, with Nmax = 30. Display your outputs in a table.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
