I'm personally a fan of returning some kind of dictionary (whether
that should be a Python dict or a SymPy Dict I don't know).

Aaron Meurer

On Tue, Sep 20, 2011 at 9:16 AM, smichr <[email protected]> wrote:
> There are algorithms that depend on being able to send more symbols
> than equations and obtain a dictionary containing the symbols solved
> for and their values, so *not* returning the symbol information in
> some way is not an option. This being the case we have to figure out
> the cleanest way to send back symbol/value information every time.
>
> Can we move forward with one of these options?
>
> OPTION A
>
> Return a FiniteSet of Dict results and (if explicit symbols were given
> or the system is univariate) allow the list=True option to have values
> or tuples of values returned? (If explicit symbols are not given and
> the solution is multivariate, then raise an error if the list option
> is selected.)
>
>  solve(x-1)
> {{x:1}}
>  solve(x-1, list=True)
> [-1]
>  solve(x-y)
> {{x: y}}
>  solve(x-y, list=True)
> Error
>  solve((x+y-5,x-y,1))
> {{x:2, y:3}}
>  solve((x+y-5,x-y,1), list=1)
> Error
>  solve((x+y-5,x-y,1), x,y, list=1)
> [(2, 3)]
>
> Given the standard solution (FiniteSet of Dicts)
> eq.subs(list(sol)[j]) will subs the jth solution into eq
> eq.subs(sol.args[j]) will subs the jth solution into eq
>
> OPTION B
>
> Return a tuple: the symbols solved for and the set of solns for single
> equation system, and multi-equation systems could return as (symbol
> list, set of soln tuples) so there would only be two return types.
>
>  solve(x-1)
> (x, {1})
>  solve(x**2-1)
> (x, {-1, 1})
>  solve(x**2-y)
> (y, {x**2})
>  solve(x**2-y, x)
> (x, {-sqrt(y), sqrt(y)})
>  solve((x+y-5,x-y,1), x,y)
> ((x, y), {(2, 3)})
>
> eq.subs(zip(sol[0], list(sol[1])[j])) will subs the jth solution into
> eq
> eq.subs(zip(sol[0], sol[1].args[j])) will subs the jth solution into
> eq
>
> Unless FiniteSet is made indexable, it is a pain to work with as a
> container for solutions since to access a given solution, you have to
> convert the FiniteSet to a list or else use args. Is there any reason
> to not allow FiniteSet to be indexable?
>
> /c
>
> --
> 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.
>
>

-- 
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.

Reply via email to