Advertisement
svinoviteran

nonlinearIterative

May 23rd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. import numpy as np
  2. def F(x):
  3.     return np.array([0.5 - np.cos(x[1] - 1), 3 + np.cos(x[0])])
  4. def simpleIter(F, x0, eps=1e-6):
  5.     k = 0
  6.     while True:
  7.         x = F(x0)
  8.         if (np.linalg.norm(x - x0) < eps):
  9.             return x0, k
  10.         x0 = x
  11.         k += 1
  12. x0 = np.array([1, 2])
  13. ans = simpleIter(F, x0)
  14. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement