Dear all, why do I have to invoke symplify
twice?
using Symbolics # v6.29.2, julia 1.11.4
@variables x
v = 2cos(x) - sin(2x)/sin(x)
va = simplify(v) # not simplified
vb = simplify(va) # 0
Dear all, why do I have to invoke symplify
twice?
using Symbolics # v6.29.2, julia 1.11.4
@variables x
v = 2cos(x) - sin(2x)/sin(x)
va = simplify(v) # not simplified
vb = simplify(va) # 0
This is similar to Mathematica’s Simplify vs FullSimplify. A rule-based simplifier just runs through its set of rules. If you want to run it to convergence we could put a fixed point iteration on it with a separate full_simplify
function, though it’s not guaranteed to converge.
Here is a simple fixed point combinator
fix(f, eq) = x -> let y = f(x)
while !eq(x, y)
x, y = y, f(y)
end
y
end
and it’s application:
julia> v |> fix(simplify, isequal)
0