Le dimanche 24 avril 2011 à 16:15 +0545, Chris Smith a écrit :
> >> 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.
>
I would say that that information needs to be provided.
> >
> >> 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
No, that's a different problem than what solve() is supposed to do. If
you want that functionality, ask for it explicitly, don't try to graft
it implicitly onto an other function.
> 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
>
How do you know it's two? And how do you know which ones? The only way
to "resist the temptation to guess" is to use all four.
> 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.
>
In any case, the dictionary solution cannot work with infinite solution
sets, so it's not a good choice.
--
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.