MasonProtter / Symbolics.jl

A symbolic math library written in Julia modelled off scmutils
MIT License
107 stars 15 forks source link

Symbolic equality operator #5

Open MasonProtter opened 5 years ago

MasonProtter commented 5 years ago

Right now, == is used to tell if two symbolic expressions are the same. Ie.

using Symbolics
@sym x y

julia> x*y == y*x
false

julia> cos(x)^2 + sin(x)^2 == 1
false

and in some senses, I kind of like it being that way because that's more the sense that == is used elsewhere with Julia. I definitely think its a good idea for == to always return a boolean. That approach seems to preclude using == the way its used for instance in Mathematica where

In[1]:= x == 1

Out[1]= x == 1

In[2]:= Cos[x]^2 + Sin[x]^2 == 1 // FullSimplify

Out[2]= True

I think it may be preferable to use an operator like (\cong) to denote the mathematical relation. With this syntax, we'd have

julia> x ≅ 1
x ≅ 1

julia> cos(x)^2 + sin(x)^2 ≅ 1
true

Any thoughts or feelings @PerezHz?

PerezHz commented 5 years ago

Perhaps we should just follow behavior of == as it is used in scmutils, where if I remember correctly the equivalent of x*y == y*x gives false?