Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def F(x):
- return np.array([0.5 - np.cos(x[1] - 1), 3 + np.cos(x[0])])
- def simpleIter(F, x0, eps=1e-6):
- k = 0
- while True:
- x = F(x0)
- if (np.linalg.norm(x - x0) < eps):
- return x0, k
- x0 = x
- k += 1
- x0 = np.array([1, 2])
- ans = simpleIter(F, x0)
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement