On Apr 20, 2011, at 1:24 PM, Ronan Lamy wrote:

> Le mercredi 20 avril 2011 à 13:16 -0600, Aaron S. Meurer a écrit :
>> 
>> On Apr 20, 2011, at 1:04 PM, Mateusz Paprocki wrote:
>> 
>>> Hi,
>>> 
>>> On 20 April 2011 11:55, Aaron S. Meurer <[email protected]> wrote:
>>>        The Solution class is indeed a good idea.
>>> 
>>>        I think it would be best to have a unified data structure
>>>        independent of the number of solutions.  The reason is that
>>>        it is not clear from the outset how many solutions an
>>>        equation or system of equations will have.  That is why I
>>>        think it would be better to have a list always or a
>>>        dictionary always (or a list of dictionaries always). The
>>>        list of dictionaries idea is one of the better ones, in my
>>>        opinion.
>>> 
>>> 
>>> This is what Mathematica does (for example) (it gives a list of
>>> rules, which is a list of dicts in Python's terminology). There is
>>> one more issue that has to be taken into account: currently it's not
>>> easy to substitute results from solve() back to the original
>>> equation/set of equations (in a systematic way).
>> 
>> 
>> If you have a list of dictionaries, you can just do
>> 
>> 
>> sol = solve(expr, vars)
>> expr.subs(sol[0])
>> expr.subs(sol[1])
>> …
>> 
>> 
>> or just
>> 
>> 
>> [expr.subs(i) for i in sol]
>> 
>> 
>> because subs works with a dictionary.  Actually, looking at it this
>> way, this data structure is far superior to any of the others.
>> 
> That won't work if there's an infinite number of solutions.

But the only way to represent an infinite number of solutions is to use a 
parameter, which should cancel if you substitute it into the expression.

Granted, we should also return a list of the parameters somehow, but I think 
this is something that would be best done with the Solution class.

Aaron Meurer

> 
>> 
>> And this is another advantage that a Solution class could offer.  We
>> could just make expr.subs(Solution) work as you would expect it to.
>> 
> Actually, I don't know what expr.subs(Solution) is supposed to do and I
> would expect it to raise an exception.
> 
> 
> 
> -- 
> 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