The output from solve for algebraic equations is not usable without testing
output because of the variable types of output.
CASE 1: If no variables are given we get the following from the input:
* univariate equation -> list of values
>>> solve(x**2 - 4)
[-2, 2]
* multivariate equation -> list of one or more dictionaries
>>> solve(x**2 - y)
[{y: x**2}]
CASE 2: If variable(s) are given we get
* list of solutions
>>> solve(x**2-y,x)
[-sqrt(y), sqrt(y)]
* tuples of solutions
>>> solve(x**2-y,x,y)
[(-sqrt(y),y), (sqrt(y),y)] --> [{x: -sqrt(y)}, {x: sqrt(y)}]
>>> solve([x**2-y],x)
[(-sqrt(y),), (sqrt(y),)] --> [{x: -sqrt(y)}, {x: sqrt(y)}]
* dictionary for single solution
>>> solve([x-y],x)
{x: y} --> [{x: y}]
Although the dict=True or set=True will give a standard output, can we at
least unify the case for when more than one variable or more than one
expression is given so we always get a list of one or more dictionaries?
This would make the output from solve always be a list. It would be a list
of values for a univariate expression given without the variable specified
or for a expression given with a single variable of interest, the first
examples for each of the CASEs above. (And, again, those could be given as
list(s) of dictionaries with the `dict=True` flag.)
/c
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/9548bd61-464e-4da9-870a-03cf5b1726b9n%40googlegroups.com.