Загрузка данных


import numpy as np

def broyden(f, x, eps=1e-5):
    it = 0
    e = np.eye(len(x)) * eps
    J = (f(x-e) - f(x+e)) / (-2*eps)
    x = np.array(x).reshape(len(x), 1)
    fx = f(x)

    while np.linalg.norm(fx) >= eps:
        dx = -np.linalg.inv(J) @ fx
        x = x + dx
        fx = f(x)
        J = J + (fx @ dx.T) / (dx.T @ dx)
        it += 1
    return x.flatten(), fx.flatten(), it

# Новая система уравнений
def f(x):
    return np.array([
        np.cos(x[0]) + x[1] - 0.5,          # cos(x1)+x2-0.5=0
        1.0/(x[0] + 1.5) - x[1] - 1.0       # 1/(x1+1.5)-x2-1=0
    ])

x, y, it = broyden(f, [0.3, 0.3])
print(x, it, sep="\n")