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?
Here is an example of code using Julia Symbolics to create a general functions -
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:14So 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?