structural versus symbolic equality symbols (== versus Eq)

28 views
Skip to first unread message

Robert Pollak

unread,
Aug 30, 2017, 5:23:12 AM8/30/17
to sympy
Hello everyone,

some of us here at EurosciPy2017 are wondering why '==' is for structural and 'Eq' for symbolic equality.
The documentation just says in the 'gotchas' tutorial:
"It turns out that when using SymPy as a library, having == test for exact symbolic [should obviously mean 'structural'] equality is far more useful than having it represent symbolic equality, or having it test for mathematical equality."

Does anyone know why this "turns out" so?
 
As the tutorial also says, "However, as a new user, you will probably care more about the latter two." So I am still a new user in this respect.

Best regards,
Robert

Robert Pollak

unread,
Aug 30, 2017, 6:27:16 AM8/30/17
to sympy
Sorry for the self reply.
I found that Aaron has answered this, although I think it depends very much on the user's work area whether "structural equality testing is used way more often than creation of Eq instances".

Aaron Meurer

unread,
Aug 30, 2017, 4:55:49 PM8/30/17
to sy...@googlegroups.com
The primary use is in our tests. Virtually all the SymPy tests take the form

assert something == expected

And we want the "something" to be exactly the same as the expected.
But if you search the nontest code you can see it is used quite a bit
there as well.

On the other hand, outside of documentation, Eq is not used very much.
This is primarily because most operations work on expressions, not
equalities (for instance, a derivative of integral is taken on an
expression, not an equality), and those functions that do operate on
equalities, such as solve(), assume that an expression is equal to 0,
so even code that calls solve() usually does solve(a - b) instead of
solve(Eq(a, b)).

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/e23a8d01-a0e8-4d9c-8025-ab9f2db97d37%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages