Skip to content

Symbolics and the Creation of General Function Not Working  #1211

Open
@abrombo

Description

@abrombo

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions