Updates:
Summary: solve and solve_poly_system can give ambiguous results
Comment #2 on issue 2405 by [email protected]: solve and solve_poly_system
can give ambiguous results
http://code.google.com/p/sympy/issues/detail?id=2405
There is a reason that the solver's current implementation must return
dictionaries and cannot return sets of values: it is possible to pass it 2
equations and 4 variables and it will return solutions for -- and here is
the key -- 2 of the 4 variables. If you don't get a dict back you don't
know what two it solve for unless you deduce this by inspecting the
free_symbols of the solution to see which 2 variables are missing.
Alternatively, two items can be returned: the variables and a set of values
for which solutions were found. My preference is that it always return the
same thing or things.
solve_poly_system is used when a system of equations is not linear in all
variables being solve for. The results are returned in whatever order the
symbols were supplied. But in the case of n-equations and n-unknowns solve
can unambiguously determine the variables...but the user won't know what
order was chosen so they won't know what order the results are in unless
those variables (as in the case of the linear system for which a subset of
variables is being solved or) are returned.
So, since variables must be returned in some way for the linear-subset case
(and this is used a lot by sympy code, e.g. gosper) we need to agree -- and
again, I would vote for consistency -- on a way that results will be
returned. I think the easiest would be to get a tuple: (symbols, set([v1,
v2])) where vi are the values of the symbols. The one drawback of that is
that multiple values should be stored in Tuple (so it will handle
substitution) but then for the single variable case that's a lot of visual
baggage to have: e.g. set([Tuple(3), Tuple(4)]) instead of [3, 4] for the
results of `solve((x-3)*(x-4))`.
I've changed the title to reflect the fact that solve is also a source of
the ambiguity when symbols are deduced. poly_system alone is only ambiguous
if you don't give it Poly instances (for which the generators were given in
the same order for each Poly). (That *is* done in solve, but it's the
guessing of symbols that causes the problem.)
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" 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-issues?hl=en.