function HW3_7(p_0,N_0,TOL) g = @(x) pi + 0.5 * sin(x/2); 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: %p_0=pi. The approximation solution is 3.626996 with 0.010000 accuracy after 3 iterations. %p_0=4*pi/3. The approximation solution is 3.626763 with 0.010000 accuracy after 3 iterations. %p_0=3*pi/2. The approximation solution is 3.626527 with 0.010000 accuracy after 3 iterations.