Re: [sympy] Difference between replace and subs?

2012-12-05 Thread Shriramana Sharma
Hi and thanks both for your replies. xreplace doesn't look like something I'd be interested in using, but as a very superficial approximation, it looks like replace changes the expression lexicographically but subs changes the expression mathematically. I know I know that's *very* superficial but I

Re: [sympy] Difference between replace and subs?

2012-12-03 Thread Chris Smith
> > (BTW as an aside, in some places in the documentation like p 502 (508 > of PDF) what is apparently a terminal transcript such as ">>> from > sympy.matrices import" etc are not properly formatted -- just thought > I'd mention.) > > >>> eq=x+y+2 >>> eq.replace(x+1, z) x + y + 2 >>> eq.subs(x+1, z

Re: [sympy] Difference between replace and subs?

2012-12-03 Thread Aaron Meurer
subs finds all instances of an expression and tries to replace them. It takes into account mathematical knowledge (e.g., (4*x).subs(2*x, y) will work, even though strictly speaking, 2*x is not part of the expression tree of 4*x). replace uses several methods to let you do more advanced substitutio

[sympy] Difference between replace and subs?

2012-12-03 Thread Shriramana Sharma
Hello again. Here's another question: The documentation says that replace replaces "matching subexpressions of self with value" and subs does "substitution of subexpressions as defined by the objects themselves". Unfortunately I am not totally able to comprehend the difference between the two. Ca