Symbolics.jl: `simplify` is inconsistent when changing the number of terms

I am using simplify for the below terms:

for which I get the following result:

As you can see that depending on the number of terms in the expressions, it gives inconsistent results. For some terms it’s able to completely get the common factors whereas for others it cannot. What is the possible reason for this? Is there a way to get the common factors completely?

Edit: I did something like below which works but seems a bit hacky, simplify should be able to do this by itself or is it not true?

There are currently 92 open issues regarding simplify: GitHub · Where software is built (and also a lot of closed issues).

Feel free to add a new issue if your example has not been reported yet.

I think there are two higher level issues:

  • how simplify is supposed to work is hard to clearly define, because many choices are subjective
  • the current implementation needs some more years to mature

Yeah that’s a property of rule-based methods. We need to keep improving it but also probably need to look into e-graph simplifiers as well. Open an issue so we have more data for the future.