Symbolics.jl `simplify` behaves in a strange random fashion

So I was trying to simplify some expression and it didn’t work for me and I couldn’t understand why. Boiling it down to its simplest form, if I use different letters of the alphabet sometimes it works and sometimes it doesn’t;. I give 5 examples to show it’s not even the order of the alphabet. I also go in an out of the Julia REPL each time to be sure previous attempts don’t influence the next. What am I doing wrong here?

%  julia
…
using Symbolics
julia> @variables a  x y x̄ ȳ
5-element Vector{Num}:
 a
 x
 y
 x̄
 ȳ
 
 julia> simplify(a*y + a*ȳ)
a*(y + ȳ)

% julia
…
julia> using Symbolics

julia> @variables b  x y x̄ ȳ
5-element Vector{Num}:
 b
 x
y
 x̄
 ȳ

julia> simplify(b*y + b*ȳ)
b*y + b*ȳ
 
%  julia
…
julia> using Symbolics

julia> @variables c  x y x̄ ȳ
5-element Vector{Num}:
 c
 x
 y
 x̄
 ȳ

julia> simplify(c*y + c*ȳ)
c*(y + ȳ)

% julia                                                          
…  
julia> using Symbolics

julia> @variables d  x y x̄ ȳ
5-element Vector{Num}:
 d
 x
 y
 x̄
 ȳ

julia> simplify(d*y + d*ȳ)
d*y + d*ȳ

% julia
…
julia> using Symbolics

julia> @variables e  x y x̄ ȳ
5-element Vector{Num}:
 e
 x
 y
 x̄
 ȳ

julia> simplify(e*y + e*ȳ)
e*y + e*ȳ

Are you using a fresh session of Julia for each of these example sections? (I’m wondering if there’s some weirdness going on around re-definition of a @variable.)

I can kinda* replicate this in the same session, even if I omit the redefinitions of y and ȳ. How are you not running into ay not defined etc. errors though? *I have to reasonably use a*y.

Yes as you can see in the log I go in and out of Julia each time. I had same thought as you which is why I did it this way.

That’s just the formatting of the quote. I actually used *

Oh I see that leading stripe now. Maybe use ``` quote blocks for code formatting?

Yes I fixed it! Apologies for the confusion

I can replicate the issue. Please, create a bug report!

1 Like