SHARE
TWEET

nonlinearIterative

svinoviteran May 23rd, 2019 (edited) 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top