I want to solve a linear equation with three or more variables. Is there a good library in python to do it?
Using @Jeremy's example:
from sympy import *
x0, x1 = symbols(['x0', 'x1'])
sol = solve([3 * x0 + x1 - 9, x0 + 2 * x1 - 8], [x0, x1])
print(sol)
output:
{x0: 2, x1: 3}
Using @004 example with slightly different notation:
from sympy import *
x, y = symbols(['x', 'y'])
system = [
Eq(3*x + 4*y, 7),
Eq(5*x + 6*y, 8)
]
soln = solve(system, [x, y])
print(soln)
{x: -5, y: 11/2}
Note: Sometimes one may see the following notation for symbols: x, y = symbols('x, y'), which seems to be less pythonic.