Open bowenszhu opened 1 year ago
This might be https://github.com/JuliaSymbolics/SymbolicUtils.jl/issues/394, which is really (https://github.com/JuliaSymbolics/Metatheory.jl/issues/87)
Addressed by #486
Great. I tested the following on Metatheory branch 2.0.0-DEV commit https://github.com/JuliaSymbolics/Metatheory.jl/commit/6cedf96d673b6702e308094b1e30173153729f14 and SymbolicUtils branch ale/mt2 commit https://github.com/JuliaSymbolics/SymbolicUtils.jl/commit/b103a9d63d8cfd9fd817b77d99fcb92fb2b69943.
using Symbolics, SymbolicUtils.Rewriters
function main()
@variables x, t, f(x, t)
Dx = Differential(x)
Dt = Differential(t)
rule = @rule Dt(Dx(~g)) => Dx(Dt(~g))
rewriter = Chain([rule])
func = Symbolics.value(Dt(Dx(f)))
rewriter(func)
end
r = main()
it correctly returns Differential(x)(Differential(t)(f(x, t)))
.
I will close this issue once PR https://github.com/JuliaSymbolics/SymbolicUtils.jl/pull/486 is merged.
@bowenszhu Note that Metatheory.jl is no longer used in SymbolicUtils.jl :(
This is a simple script which tries to reverse the differential operators.
the result is good:
Differential(x)(Differential(t)(f(x, t)))
However, if we place the entire code in a function,
the result is different and the rewritter fails to match the pattern:
Differential(t)(Differential(x)(f(x, t)))
Then we put the construction of
Dt
andDx
out of the function, it works again.result:
Differential(x)(Differential(t)(f(x, t)))
Version: julia v1.7.3 SymbolicUtils v0.19.11 Symbolics v4.10.3