JuliaSymbolics / SymbolicUtils.jl

Symbolic expressions, rewriting and simplification
https://docs.sciml.ai/SymbolicUtils/stable/
Other
527 stars 100 forks source link

y/(x*((y/x)^2)) and y/x/((y/x)^2) are not equal #447

Open acsofie opened 2 years ago

acsofie commented 2 years ago

code:

julia> using SymbolicUtils

julia> @syms x y
(x, y)

julia> a = y / (x*((y / x)^2))
y / (x*((y / x)^2))

julia> b = y/x/((y/x)^2)
x / y

julia> simplify(a)
y / (x*((y / x)^2))

julia> isequal(a,b)
false

environment:

Julia Version 1.8.0-beta3 (2022-03-29)
[d1185830] SymbolicUtils v0.19.7
bowenszhu commented 1 year ago

isequal in SymbolicUtils.jl intends to only compare the exact expressions instead of their equivalent simplified forms. See https://github.com/JuliaSymbolics/SymbolicUtils.jl/blob/v0.19.7/src/types.jl (find isequal) and in master branch https://github.com/JuliaSymbolics/SymbolicUtils.jl/blob/97a8a86227f5eb824c3c28e5f2094d8168b5fa57/src/types.jl#L190-L219

acsofie commented 1 year ago

yes, I know. But

  1. This function is implemented in this way because of assuming all syms has been simplified.
  2. For the semantics of isequal, y / (x*((y / x)^2)) and y/x/((y/x)^2) should be true.
  3. My issue is just describing the phenomenon and I don't think this implement has any problem. In fact, I think the problem is on
    julia> a = y / (x*((y / x)^2))
    y / (x*((y / x)^2))

    and

    julia> simplify(a)
    y / (x*((y / x)^2))