Multiple Equations with solveset

1 391 katselukertaa
Siirry ensimmäiseen lukemattomaan viestiin

Bobby Rullo

lukematon,
11.10.2017 klo 2.35.2411.10.2017
vastaanottaja 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

lukematon,
11.10.2017 klo 15.37.2511.10.2017
vastaanottaja 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

lukematon,
12.10.2017 klo 23.55.2912.10.2017
vastaanottaja sympy
Hello Bobby,

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

Cheers,
Shekhar
Vastaa kaikille
Vastaa kirjoittajalle
Välitä
0 uutta viestiä