write matrix solve 5x4 algorithm in python

main.py
import numpy as np

# Coefficients matrix
A = np.array([[2, 1, -1, 2],
              [4, 5, -3, 6],
              [3, 3, 1, 2],
              [6, 7, -5, 2],
              [7, 9, -6, 7]])

# Constants vector
B = np.array([2, 3, -1, 4, 5])

# Solve the equation Ax = B
X = np.linalg.solve(A, B)

print(X)
303 chars
17 lines

related categories

gistlibby LogSnag