JuliaSymbolics / Symbolics.jl

Symbolic programming for the next generation of numerical software
https://docs.sciml.ai/Symbolics/stable/
Other
1.36k stars 153 forks source link

Symbolics and the Creation of General Function Not Working #1211

Open abrombo opened 3 months ago

abrombo commented 3 months ago

Here is an example of code using Julia Symbolics to create a general functions -

using SymbolicUtils
using Symbolics

x = Symbolics.variable("x")
y = Symbolics.variable("y")
z = Symbolics.variable("z")

@variables F(x),G(x,y)

f = Symbolics.variable("f", T=Symbolics.FnType)(x)
g = Symbolics.variable("g", T=Symbolics.FnType)(x,y)
println(F*G)
println(f*g)

Output -

G(x, y)F(x) ERROR: LoadError: ArgumentError: The function cannot be applied to g(x, y) which is not a Number-like object.Define islike(::Num, ::Type{Number}) = true to enable this. Stacktrace: [1] assert_like(::Function, ::Type, ::Num) @ SymbolicUtils ~/.julia/packages/SymbolicUtils/EGhOJ/src/methods.jl:43 [2] assert_like(f::Function, T::Type, a::Num, b::Num) @ SymbolicUtils ~/.julia/packages/SymbolicUtils/EGhOJ/src/methods.jl:45 [3] *(a::Num, b::Num) @ Symbolics ~/.julia/packages/SymbolicUtils/EGhOJ/src/methods.jl:72 [4] top-level scope @ ~/Julia/Algebra/test1.jl:14 in expression starting at /home/brombo/Julia/Algebra/test1.jl:14

So that FG does not generate an error but fg does. I do not understand the error message. What am I supposed to do to make this work?

ChrisRackauckas commented 3 months ago

@shashi do you know what's going on here?