Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- f = lambda x: np.sin(x ** 2) - 6 * x + 1
- phi = lambda x: (np.sin(x ** 2) + 1) / 6
- def fixed_point_iter(f, x0, eps):
- x = x0
- k = 0;
- while True:
- y = f(x)
- k+=1;
- if abs(y - x) < eps:
- return y, k
- else:
- x = y
- my_sol, i = fixed_point_iter(phi, 0.5, 1e-6)
- print(my_sol)
- print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement