JuliaSymbolics / SymbolicUtils.jl

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

Simplify does not pull out common factors from polynomials #455

Closed ndinsmore closed 2 years ago

ndinsmore commented 2 years ago

Simplify seems to be struggling with basic polynomial common factor extraction. It in fact seems to favor the expanded form of a factorpolynomial ie `2(a+b)"simplifies" to2a+2b`.

julia> using Symbolics

julia> @syms a b c
(a, b, c)

julia> simplify(2*(a+b) )
2a + 2b

julia> simplify(2*(1+a+a^2+a^3+a^4+a^5))
2 + 2a + 2(a^2) + 2(a^3) + 2(a^4) + 2(a^5)

julia> simplify( a / (b + c) + a / (b + c)^2 )
(a + a*b + a*c) / ((b + c)^2) 

I understand that sometimes the expanded form is needed for other simplifications to be investigated, but you would expect that once no further simplifications are found in that search tree it reverts to non-expanded form.

ndinsmore commented 2 years ago

I meant to put this in symbolics.jl