I'm a little unclear on what you're asking, so let me just tell you some things and hopefully it will contain the answer you are looking for.
a == b does structural comparison only. So x + 1 == x + 1 will give True, but (x +1)*x == x**2 + x will give False.
To test for mathematical equality, simplify(a - b) is your best bet. If you know something about the structure of a and b, you can use something more directed (and efficient) than simplify(), but in the general case we try to make simplify() all encompassing, so that it performs all possible simplifications known to SymPy.
Our assumption system is not smart enough at the moment to perform assumptions based comparison, unfortunately, but that's something to think about. Usually simplify(a - b) tells you if a = b if it reduces to zero, but nothing if it doesn't. But you could potentially do the reverse with something like Symbol("x", positive=True) != Symbol("y", negative=True). I'm not sure what a good interface to that would be, for whenever it is implemented.
Aaron Meurer
I'm wondering how to make the following work:
In: x, y = symbols('x y')
In: Eq(x, y)
Out: Eq(x, y)
In: Eq(x, x)
Out: True
It seems that it just require something like an
if a == b: True else Eq(a,b)
test, perhaps right in the __new__ generator of Relational. I don't know what the policy is on calling simplify() to test for zero / nonzero difference between the two sides, but if a zero is found, then any of the relations give an immediate result. There are also some number theoretic results involving valid variable ranges that could immediately simplify symbolic comparisons.
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sympy/-/Kq24S46MI-gJ.
To post to this group, send email to
sy...@googlegroups.com.
To unsubscribe from this group, send email to
sympy+un...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.