Status: Started
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 3145 by smi...@gmail.com: simultaneous substitution
http://code.google.com/p/sympy/issues/detail?id=3145
An option that we might consider for substitution is a "simultaneous"
option where any arg that is targeted for substitution waits until all
substitutions are finished before evaluating. Without that, evaluation may
depend on the order of substitution:
>>> (sqrt(a/b)).subs([(a,0),(b,0)])
0
>>> (sqrt(a/b)).subs(reversed([(a,0),(b,0)]))
nan
Perhaps that is the meaning that can be given to substitutions involving a
dictionary. It is not interpreted this was in the current implementation,
however:
>>> sqrt(b/a).subs({a:0,b:0})
0
>>> sqrt(a/b).subs({a:0,b:0})
nan
xreplace does appear to use these semantics, however, so subs could be made
to do simultaneous substitution by substituting `old` with a dummy and then
xreplacing the dummies with the final `new` values:
>>> sqrt(a/b).xreplace({a:0,b:0})
nan
>>> sqrt(b/a).xreplace({a:0,b:0})
nan
In the above example, dummies are not necessary because no subs-smarts are
needed to avoid making replacements in portions of the expression that
should not be replaced.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.