Multiple Equations with solveset

1,395 views
Skip to first unread message

Bobby Rullo

unread,
Oct 11, 2017, 2:35:24 AM10/11/17
to sympy
Hi there,

Given a number of equations, I can give them to solve to get the solution set, eg: 

solutions = solve([eq1, eq2, eq3])

However, solve seems to be deprecated in favor of solveset, but solveset only takes a single equation:

solutions = solveset([eq1, eq2, eq3])
ValueError: [Eq(x, 1), Eq(y, 2), Eq(z, x + y)] is not a valid SymPy expression

Is there way to combine a number of equations to a single one? I am very new to Sympy so I am sure I am missing something simple!

Thanks,

Bobby

Bobby Rullo

unread,
Oct 11, 2017, 3:37:25 PM10/11/17
to sympy
Here's one thing I tried but did not work. 

a,b,c = symbols('a b c')
expr = Eq(a, 10) & Eq(b, 80) & Eq(a + b + c, 100)
solveset(expr, a)
ValueError: Eq(a, 10) & Eq(b, 80) & Eq(a + b + c, 100) is not a valid SymPy expression

So it turns out that the boolalg expressions are not Exprs. 


Bobby

Shekhar Prasad Rajak

unread,
Oct 12, 2017, 11:55:29 PM10/12/17
to sympy
Hello Bobby,

You can use `linsolve` for linear system of equation and `nonlinsolve` for non linear system of equation.

Cheers,
Shekhar
Reply all
Reply to author
Forward
0 new messages