SymbolicUtils.jl
SymbolicUtils.jl copied to clipboard
function to define a rule
It would be nice to have a function to define a rule. The problem with macros is that sometimes it becomes difficult to interpolate all the variables correctly.
I also report a problem:
@variables x[1:10]
r1 = [@acrule(*($i, $j, $k) => 0) for (i, j, k) in collect(combinations(x, 3))] # example: x[1]*x[2]*x[3] => 0
println(r1[1]) # ACRule($i * $j * $k => 0), instead of ACRule(x[1] * x[2] * x[3] => 0)
Despite this, the generated rules work correctly when simplifying.
you don't need $ there.
Sometimes if I don't put $, the rules don't work in simplification.
Example:
@variables x[1:10]
r2 = [@acrule(*(x[2], x[5]) => 0)]
r3 = [@acrule(*($(x[2]), $(x[5])) => 0)]
f = x[2]*x[5]
simplify(f, RuleSet(r2)) # x[2]*x[5]
simplify(f, RuleSet(r3)) # 0