scipy.linalg.solve(A, b) solves Ax = b. Prefer it over multiplying by an inverse.
Goal
Solve a 2×2 system and print det and inv.
from scipy.linalg import solve
A = np.array([[3.0, 1.0], [1.0, 2.0]])
b = np.array([9.0, 8.0])
x = solve(A, b)
print(x)
print('check', A @ x)from scipy.linalg import det, inv
A = np.array([[3.0, 1.0], [1.0, 2.0]])
print('det', det(A))
print(inv(A).round(3))from scipy.linalg import eig
A = np.array([[2.0, 0.0], [0.0, 3.0]])
vals, vecs = eig(A)
print(vals.real.round(3))
print(vecs.real.round(3))from scipy.linalg import norm
v = np.array([3.0, 4.0])
print(norm(v), np.sqrt(np.sum(v ** 2)))