>> You may have not requested an explicit set of symbols and are
>> willing to take whatever you get...in that case you need to know
>> what you got.
>>
>> h[2] >>> solve([x+y-3,x**2+y-5])
>> [(-1, 4), (2, 1)]
>>
> But that's just an unsafe convenience that should really only be used
> in interactive sessions, in which case you do know what the variables
> are.
Is it x,y or y,x pairs that you got? Somehow that information needs to be
returned.
>
>> And if there are many symbols and you just want *some* solution, then
>> it's nice to let solve handle figuring out which set of symbols it
>> can solve for.
>>
> I'm not sure what it is you're suggesting, but it sounds like the "do
> what I mean" philosophy of coding, which produces "nice" results in
> simple cases and debugging nightmares in complex ones.
> It should be very easy to figure out what the variables are, basically
> just S(equations).free_symbols.
That's not the problem. The problem is knowing which subset lead to an explicit
solution. In Chemical Engineering you sometimes solve systems of equations for
which there are more parameters than equations. And all you need to
characterize the system is some solution to them so you can map out how they
behave as the variables change. But you don't care what is treated like a
variable and what is a parameter -- you just want something to work with. So
this cooked-up example
h[1] >>> solve([x + a**2 + y/b, 1/x - y + a])
indicates you want two of the four variables solved for in terms of the others.
So you would be happy to have the solver do the looking for you and get
something like:
[(b, (a*y - y**2)/(1 + y*a**2 - a**3)), (x, (-y - b*a**2)/b)]
or, after backsubstitution
{x: (-y - a**2*(a*y - y**2)/(1 + y*a**2 - a**3))*(1 + y*a**2 - a**3)/(a*y -
y**2),
b: (a*y - y**2)/(1 + y*a**2 - a**3)}
You're right about the dictionary being easy to use. I would prefer that the
format always be the same (as opposed to the current situation: list of expr,
dictionary, list of symbols followed by solution tuples.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.