SymbolicUtils.jl
                                
                                 SymbolicUtils.jl copied to clipboard
                                
                                    SymbolicUtils.jl copied to clipboard
                            
                            
                            
                        Add a single `@rule` to `simplify`
I would it be nice if one could easily add a custom simplification rules on top of the default rules in simplify.
@shashi said on slack, that this is not so easy currently, and asked me to open an issue here.
It seems to be solved with
expr = 1/Symbolics.Term(sqrt, 2))^2 
#
r1 = @rule sqrt(~x)^2 => ~x
r2 = @rule (~x/~y)^2 => (~x)^2 / (~y)^2
#
simplify(expr, RuleSet([r1,r2]))
 
                                    
                                    
                                    
                                
Not sure. Doesn't that only use the two specified rules?
I'd like all predefined rules plus one or two extra.
I see. You are probably right.
One might need to apply one more |> simplify after your extra rule.