function [fixed_point, iterations] = fixed_point_method(g, epsilon, x0) % Find a fixed_point of the function `g` with initial guess x0. % % INPUTS: % % * ``g`` - The function to iterate. % % * ``epsilon`` - We stop when two successive iterations are within % epsilon of each other, taken under the infinity norm. halt the % search and return the current approximation. % % OUTPUTS: % % * ``fixed_point`` - The fixed point that we found. % % * ``iterations`` - The number of iterations that we performed % during the search. % iterations = 0; prev = x0; current = g(x0); while (norm(current - prev, Inf) > epsilon) prev = current; current = g(current); iterations = iterations + 1; end fixed_point = current; end