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.

Finally, I want to point out that currently Relational serves a dual role,
one of asking about the property and one of assuming it. See
http://code.google.com/p/sympy/issues/detail?id=1887.

Aaron Meurer

On Aug 27, 2012, at 6:03 PM, "David M. Rogers" <[email protected]>
wrote:

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 [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.

-- 
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.

Reply via email to