Python: how to solve a system of equations

2.3k Views Asked by At

I'm not very experienced with using python and I am trying to solve a system of equations. Here's an example of how it would look:

x1 + 2x2 + 3x3 + ... + x52 = some number A

7x1 + 8x2 + x3 + ... + 4x52 = some number B

9x1 + 3x2 + x3 + ... + x52 = some number C

So it would only have a few rows with a lot of columns.

I know there are many solutions but not all will work.

1

There are 1 best solutions below

1
On

From your description, it sounds as though your problem is under-determined, so you can't hope to solve the set of equations uniquely but seek a "best" solution in some sense. The usual first approach to this kind of problem is the linear least-squares solution, which NumPy provides a function for: numpy.linalg.lstsq.