Open bowenszhu opened 1 year ago
What is the current way to just convert a number (and indeed, the number 0) into a symbolic that can be stored in a vector with other symbolic expressions? I tried (Symbolics.Term(Symbolics.identity, [Real(Float64(result))]) )
but this gives an error when I try to store it in an array, the error is
ERROR: LoadError: MethodError: Cannot `convert` an object of type
SymbolicUtils.BasicSymbolic{Float64} to an object of type
SymbolicUtils.BasicSymbolic{Real}
Following the discussion in
As of Symbolics v5.1.0 and SymbolicUtils v1.0.3, it is complicated to create a symbolic number that doesn't include a variable.
For example, to create a symbolic $\sqrt 3$, one needs to call
Here, users have to be aware of the
Term
data structure, in which the fieldarguments
is aVector
instead of just a scalar number.Term
Term
And a
BasicSymbolic
shall bewrap
ped in aNum
in order to properly use promotion rules. https://github.com/JuliaSymbolics/Symbolics.jl/blob/426eb803efdb3bedf508b1d2dc547c2445f44252/src/wrapper-types.jl#L48-L52 https://github.com/JuliaSymbolics/Symbolics.jl/blob/426eb803efdb3bedf508b1d2dc547c2445f44252/src/num.jl#L1-L3 https://github.com/JuliaSymbolics/Symbolics.jl/blob/426eb803efdb3bedf508b1d2dc547c2445f44252/src/num.jl#L98-L99We should hide these internal details to make it simpler for end users.
In SymPy and SymEngine, we can do it as follows, which are very straightforward.