import numpy as np # the package numpy is only required for the definition of the # exponential function below # function defining the fixed point iteration # NB: there is no convergence/divergence check, the function # simply applies n iterations of the fixed point iteration with # starting value s for the function g # it can happen that convergence is reached well before the # number of iterations, but the iteration may also diverge def fix_iter(g,s,n): x = start_point for k in range(1,n): x = g(x) return x ## a small experiment with the function from the lecture # definition of the function def fix_fun(x): return np.exp(x)/3 # you may freely change starting point and number of iterations start_point = 0 n_iter = 50 # run the iteration (and display the result) fix_iter(fix_fun,start_point,n_iter)