import numpy as np
import scipy.linalg as sl
a = sl.hilbert(10)
b = np.arange(10)
sol1 = sl.solve(a, b)
sol2 = sl.lstsq(a, b)[0]
sol3 = sl.solve(np.dot(a.T, a), np.dot(a.T, b))
Efficient computation of the least-squares algorithm in NumPy