import numpy as np
# defining a linear equation system E=F with
# | -2 * x1 - 4 * x2 + 1 * x3 - 9 * x4 + 0 * x5 = +5 |
# | 3 * x1 + 6 * x2 + 0 * x3 + 12 * x4 + 3 * x5 = +15 |
# | 1 * x1 + 2 * x2 + 1 * x3 + 3 * x4 + 1 * x5 = -17 |
# | -5 * x1 - 4 * x2 + 1 * x3 - 9 * x4 + 0 * x5 = +14 |
E=np.array(
[
[-2,-4,1,-9,0],
[3,6,0,12,3],
[1,2,1,3,1],
[-5,-10,3,-23,1]
]
)
F=np.array(
[3,15,-17,14]
)
solutionNonSquare = np.linalg.lstsq(E, F)
print('the solution vector is: {x1, x2, x3, x4, x5}=')
print(solutionNonSquare)