I’m adding to the list of posts about simplifying a Symbolics.jl
expression, but I wanted to check if I did something wrong or if it is an internal limitation. I want to check if two (lengthy) expressions are identical, and am trying to simplify their difference. However, simplify(expr)
doesn’t simplify things such as this:
(I ran simplify
twice, and a third pass didn’t change anything).
Edit: I found a simplified example.
Maybe the fact that the computed expression’s (b1
) terms are not reordered is the problem ?
Edit 2: a MWE
julia> using Symbolics
[ Info: Precompiling Symbolics [0c5d862f-8b57-4792-8d23-62f2024744c7]
julia> @variables a b c d e f
6-element Vector{Num}:
a
b
c
d
e
f
julia> (a^2 + b^2) * cos(c + d) * e + e * cos(c + d) * (-a^2 - b^2)
(a^2 + b^2)*e*cos(c + d) + (-(a^2) - (b^2))*e*cos(c + d)
julia> (a^2 + b^2) * cos(c + d) * e + e * cos(c + d) * (-a^2 - b^2) |> simplify
0
julia> (a^2 + b^2) * cos(c + d) * e * f + e * cos(c + d) * (-a^2 - b^2) * f |> simplify
(a^2 + b^2)*e*f*cos(c + d) + (-(a^2) - (b^2))*e*f*cos(c + d)
I suspect the problem here is the terms in the computed expression (b1
) are not reordered.