Skip to content

Commit 4f6ea1b

Browse files
committed
fix term ordering issue with Sym < Term
1 parent ee10b08 commit 4f6ea1b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/simplify.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ function <ₑ(a::Sym, b::Term)
6262
# both subterms are terms, so it's definitely firster
6363
return true
6464
elseif n1
65-
return a <ₑ args[1]
65+
return isequal(a, args[1]) || a <ₑ args[1]
6666
elseif n2
67-
return a <ₑ args[2]
67+
return isequal(a, args[2]) || a <ₑ args[2]
6868
else
6969
# both arguments are not numbers
7070
# This case when a <ₑ Term(^, [1,-1])

test/order.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,13 @@ end
6363
@test a(t) <b(t)
6464
@test !(b(t) <a(t))
6565
end
66+
67+
@testset "Sym vs Term" begin
68+
@syms x
69+
70+
@test x <ₑ (3 + x) && !((3 + x) <ₑ x)
71+
@test x^2 <ₑ y && !(y <ₑ x^2)
72+
73+
# a nice consequence
74+
@test simplify(x/(x+3) + 3/(x+3)) == 1
75+
end

0 commit comments

Comments
 (0)