Skip to content
Justice Tech School

Solving Linear Equations

linalg.solve finds x in A x = b without computing the inverse.

Example
A = np.array([[2.0, 1.0], [1.0, 3.0]])
b = np.array([5.0, 10.0])
x = np.linalg.solve(A, b)
print(x, np.allclose(A @ x, b))

Result

[1. 3.] True

Exercise

Solve A x = b.

np.linalg.(A, b)

Quiz Test

Why solve over inv?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.