Question
Write a Python function simple_iteration(g, x0, tol=1e-6, max_iter=100) that implements the Simple Iteration Method:
gis the rearranged function (e.g.,lambda x: (3 + cos(x)) / 2)x0is the initial guess- Stop when $|x_{new} - x_{old}| < tol$ or after
max_iteriterations - Print each iteration: iteration number, $x$ value, and current error
Test it on $2x - 3 = \cos(x)$ with $x_0 = 1.5$.