JuliaSymbolics / Symbolics.jl

Symbolic programming for the next generation of numerical software
https://symbolics.juliasymbolics.org/stable/
Other
1.32k stars 146 forks source link

Rule works with SymbolicUtils.jl but not Symbolics.jl #1175

Closed dpsanders closed 1 week ago

dpsanders commented 1 week ago

The following example from the SymbolicUtils.jl docs works with @syms from SymbolicUtils, but returns empty when using @variables from Symbolics:


julia> using Symbolics

julia> @variables w z α::Real β::Real;

julia> r3 = @rule ~x * +(~~ys) => sum(map(y-> ~x * y, ~~ys));

julia> r3(2 * (w+w+α+β))
dpsanders commented 1 week ago

r3(value(2 * (w+w+α+β))) works

Vaibhavdixit02 commented 1 week ago

With @variables you'd need to unwrap the expression. So this works r3(2 * (w+w+α+β) |> unwrap), which is the same as what you achieve with the value call on it

ChrisRackauckas commented 1 week ago

Was simple enough to handle, might as well make it automatic.