Am 02.06.2012 21:47, schrieb [email protected]:
Most (all?) of the solvers implemented in sympy return a list of
solutions if there is more than one, and the solution itself (not in a
list) if it is the only in existence. (And usually an empty list
(sometimes None) if there are no solutions).
I dislike this strongly. I would like to know if there are similar
sentiments in the community.
I share this dislike. However, solutions do not come easy.
Take square roots for example.
Usually, you expect zero, one, or two solutions.
However, somebody working with geometries expects exactly one answer out
of the square root in the calculation; for him, a square root has
exactly one answer.
Somebody working with complex numbers, on the other hand, always expects
a list of two answers. Except when the two roots coincide, when he
sometimes wants a one-value list and sometimes a two-value pair.
Mathematicians seem to deal with this by ignoring the difference between
lists/tuples/sets and single values. This goes as far as neglecting to
define the sine of a set of reals, taking for granted that sin(1, 2, 3)
is defined as (sin 1, sin 2, sin 3).
It IS possible to take this kind of wilful imprecision to code. We'd
need to make all SymPy-related single-argument functions to accept
arbitrary containers as argument, and construct a similarly-structured
data structure with the ground values replaced by the results of the
single-argument variant.
--
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.