Thank you! This almost worked for me as is. My desired dependent variables are [w, y]. If I just pass those, then I don't get the solution for z=1. So I did two solves:
1. Solve with my desired dependent variables (e.g. [w, y]) 2. Identify the set of variables that are not in the solution (as keys or in the values) and add those to my list of desired dependent varaibles ([x]) 3. Solve the same set of equations again with the new minimal set of variables ([w, x, y]) Thanks for the pointer! - Brandon On Friday, April 9, 2021 at 4:03:48 PM UTC-4 smi...@gmail.com wrote: > just list the variables for which you want to solve -- in this case, leave > off the "x" and you will get > > ``` > >>> soln > [{w: 0.5 - 0.5*x, y: 0.5 - 0.5*x, z: 1.00000000000000}] > > ``` > > see also https://github.com/sympy/sympy/issues/2720 > > /c > > On Friday, April 9, 2021 at 1:32:51 PM UTC-5 brandon...@gmail.com wrote: > >> Given the snippet below: >> >> from sympy import symbols, solve >> w, x, y, z = symbols("w x y z") >> equations = [ >> w + x + y - 1, >> z - 1, >> w/(w+y) - 0.5, >> w/(w+y) + y/(w+y) - 1 >> ] >> soln = solve(equations, (w, x, y, z), dict=True)[0] # accept first >> solution >> print(soln) >> >> the soln is: >> >> { >> w: y, >> x: 1.0 - 2.0*y, >> z: 1.000 >> } >> >> Is there a way I can use solve or some other function in SymPy to >> change/influence the set of independent variables? In this case, I would >> like to prefer x to be independent (used in the expressions of the soln >> values) instead of y. >> >> This is a simplified of my actual code. In practice, I don't know which >> symbols will can be independent before I call solve, but trivial for me to >> order the symbols in order of my preference for them to be independent, if >> possible. >> >> Cheers, >> Brandon Bocklund >> > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/4bc8c31b-8e24-4f12-a117-ed8e6901e865n%40googlegroups.com.