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


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

# Новая система уравнений:
# 1) 2^(x1) - x2 - 1.5 = 0
# 2) ln(x1+1.5) + x2 - 0.2 = 0
def f(x):
    return np.array([
        2**x[0] - x[1] - 1.5,
        np.log(x[0] + 1.5) + x[1] - 0.2
    ])

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