Solving Linear Equations
np.linalg.solve finds x in Ax = b. It is faster and more accurate than computing the inverse.
Example
import numpy as np
A = np.array([[3, 1], [1, 2]])
b = np.array([9, 8])
x = np.linalg.solve(A, b)
print(x)
print(np.allclose(A @ x, b))Result
[2. 3.] True
Exercise
Solve for x.
np.linalg.(A, b)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.