function HW3_12(p_0,N_0,TOL) g = @(x) 2 + sin(x); fprintf('n=%d, p(%d)=%8.6f\n', 0, 0, p_0); i = 1; while (i <= N_0) p = g(p_0); fprintf('n=%d, p(%d)=%8.6f\n', i, i, p); if (abs(p-p_0) < TOL) fprintf('The approximation solution is %f with %f accuracy after %d iterations.\n', p, TOL, i); return; end i = i + 1; p_0 = p; end fprintf('The method failed after N_0 iterations, N_0=%d\n', N_0); return; end %Result: (octave) %p_0=2. The approximation solution is 2.554200 with 0.000010 accuracy after 63 iterations.