JuliaSymbolics / SymbolicUtils.jl

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

`@arithmetic_rule` #506

Open shashi opened 1 year ago

shashi commented 1 year ago

Have a macro

@arithmetic_rule $(D(r)) * ~x => ...

such that it matches,

D(r) * a * b with ~x as a*b (D(r) * b) / a with ~x as b/a

Also similarly enable: D(x) * ~y + ~x

This should simplify writing redundant rules in MethodOfLines.jl

shashi commented 11 months ago

One idea is to just add multipleof predicate, and make it more powerful by allowing slots in predicate.

@rule ~x::multipleof(~y) + ~z::multipleof(~y) => ~y * (~x / ~y + ~z/~y)