Добавил:
ddaren_223
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:коды / 8
.1.py import numpy as np
def newton(f,J,x,eps=0.03):
fx=f(x)
while np.linalg.norm(fx)>eps:x=x-np.linalg.inv(J(x))@fx;fx=f(x)
return x,fx
def f(x):x, y = x;return np.array([np.sin(x+1.5)-y,1.2*np.sqrt(0.16-x**2)+y])
def J(x):x, y = x;return np.array([[np.cos(x+1.5),1],[-(6*x)/(np.sqrt(4-25*x**2)),1]])
print('\n'.join(map(str,newton(f,J,[0.3,0.3]))))
def newton(f,J,x,eps=0.03):
fx=f(x)
while np.linalg.norm(fx)>eps:x=x-np.linalg.inv(J(x))@fx;fx=f(x)
return x,fx
def f(x):x, y = x;return np.array([np.sin(x+1.5)-y,1.2*np.sqrt(0.16-x**2)+y])
def J(x):x, y = x;return np.array([[np.cos(x+1.5),1],[-(6*x)/(np.sqrt(4-25*x**2)),1]])
print('\n'.join(map(str,newton(f,J,[0.3,0.3]))))