+2 votes
in Programming Languages by (74.2k points)
I am using solve() function of linear algebra module of numpy to solve the following system of equations, but I am getting error : "numpy.linalg.LinAlgError: Last 2 dimensions of the array must be square".

3x1 + 7x2 + 2x3 = 17
7x1 + x2 + 5x3 = 25

1 Answer

+1 vote
by (349k points)
selected by
 
Best answer
In your system of equations, you have three variables x1, x2, x3 whereas you have only 2 equations. Therefore, the solve() function is throwing an error.

The number of variables should be equal to the number equations. Then you will not get an error. So, you need to add one more equation.

...