Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def f(x):
- return [np.sin(x[0] + x[1]) - 1.2 * x[0] + 0.1, x[0] ** 2 + x[1] ** 2 - 1]
- def g(x):
- return [[np.cos(x[0] + x[1]) - 1.2, np.cos(x[0] + x[1])],
- [2 * x[0], 2 * x[1]]]
- def Newts(x, f, g, eps):
- k = 0
- while (True):
- x_ = x - np.linalg.inv(g(x)) @ f(x)
- k += 1
- if np.linalg.norm(x_ - x) < eps:
- return x_, k
- x = x_
- x = [1, 0.7]
- print(g(x))
- ans = Newts(x, f, g, 1e-6, )
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement