This is expected behavior. An important thing to remember about all SymPy expressions (with the exception of matrices) is that they are immutable, so no function will change them in place. If you want to save the output to subs, assign it to a new variable.
See the tutorial for more information on this and other common gotchas with SymPy. http://docs.sympy.org/latest/tutorial/index.html Aaron Meurer On Oct 25, 2013, at 11:51 AM, Pietro Zambelli <[email protected]> wrote: Hi all, I'm new to sympy and I found a strange behaviour that I'm not able to understand, probably I'm doing something wrong... :-) {{{ In [1]: from sympy import symbols In [2]: xa, ya, xb, yb = symbols('xa ya yb yb') In [3]: yk = ya + yb In [4]: yk.subs([(xa, 0), (ya, 4), (xb, 2), (yb, 4)]) Out[4]: 6 In [5]: yk.subs([(xa, 0), (ya, 4), (xb, 0), (yb, 4)]) Out[4]: 4 In [6]: yk.subs([(ya, 4), (yb, 4)]) Out[5]: 8 In [7]: import sympy In [8]: sympy.__version__ Out[7]: '0.7.3' }}} Why the result is changing from line 4 to line 6? The variable xa and xb are not used in the equation at line 3, but they changed the result... I'm confused.. Any hints? Pietro -- 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 post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out. -- 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 post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
