I'm trying to solve following system of equations=
-14a + b + e = 0
2a - 14b + d = 0
b -14c +2d = 0
-15d + e = 0
+ 2c -14e = 0
a + b + c + d + e = 1
I appended required zeroes to matrices formed from above equations . I used numpy.linalg.solve function. I always get this error:: numpy.linalg.linalg.LinAlgError: Singular matrix. I know that I have created a singular matrix by making one row elements zero.
My matrices & code ::
a= np.array([
[-14, 1, 0, 0, 1, 0],
[2, -14, 0, 1, 0, 0],
[0, 1, -14, 2, 0, 0],
[0, 0, 0, -15, 1, 0],
[0, 0, 2, 0, -14, 0],
[1, 1, 1, 1, 1, 0]
])
b=np.array( [0, 0, 0, 0, 0, 1] )
x = np.linalg.solve(a, b)
Is there another way to solve this ?
Using np.linalg.lstsq returns ::
(array([ 0.00674535, 0.00713199, 0.00709352, 0.00582019, 0.006766 , 0.
]), array([], dtype=float64), 5, array([ 15.88397122, 15.68586038, 14.59368088, 13.14182044,
12.12312981, 0. ]))
How am I supposed to get my solutions from above array ??.. None of the no. in above array is the solution..