On Fri, Nov 11, 2011 at 11:59 AM, gsagrawal <[email protected]> wrote:
> my requirement is like
> "x+y+x " and 2*x+y are different
> but "x+y+x" and "x+x+y" are same ...
> if i use evaluate ===False it make both cases inequal.
What I mean is, Why are you using unevaluated expressions? One reason
I could think is that you are generating expressions for students to
check for equality (e.g. simplify `x + x + y`) and you want to have
them obtain `2*x + y`.
This, btw, Ronan, is one reason I don't consider evaluate=False a
hack. This flag gives you total control, sans ordering, of what
appears in the final expression,
>>> Add(2,x+y,x,3,evaluate=False)
x + x + y + 2 + 3
On the other hand you could just create the strings you want and
sympify the result to get it back into a sympy expression but you
would still have to fiddle with the generation if there were leading
negatives on some of the terms:
>>> ' + '.join(str(s) for s in [2,x+y,x,3])
'2 + x + y + x + 3'
>>> S(_)
2*x + y + 5
>>> ' + '.join(str(s) for s in [2,x+y,x,-3])
'2 + x + y + x + -3'
But gsagrawal, what is *your* reason for using unevaluated expressions?
--
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.