You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been experimenting with combining Symbolics.jl with other mathematical libraries. I've noticed that in some cases, the substitute can fail dramatically, without any error or indication of a missing method definition.
using CliffordNumbers, Symbolics
@variables X_sym[1:4]
# Extend a function from CliffordNumbers so the variable can be printed. (Unrelated to issue, but helps see the outputs.)import CliffordNumbers.print_clifford_coefficient
print_clifford_coefficient(io::IO, c::Num, ffn::Bool) =print(io, " + "^ffn, '(', c, ')')
# Form a CliffordNumber whose coefficients are symbolic variables.
X =KVector{1, STA, Real}(X_sym...)
typeof(X) = 1-element KVector{0, LGAWest(3), Num} which is idiomatic and expected. Compare, for example, to c = X_sym[1] + X_sym[2] * im, for which typeof(c) = Complex{Num}.
There are several open issues at time of writing about the type Complex{Num}. A similar issue is likely happening here. The actual behavior seen is
Y =substitute(X, X_sym => [1,2,3,4])
# Produces (X_sym[1])γ₀ + (X_sym[2])γ₁ + (X_sym[3])γ₂ + (X_sym[4])γ₃ which is completely unchanged.# To demonstrate:
Y == X # true
The behavior that should happen, as compared with the analogous Complex{Num} case:
I'm really quite puzzled about what's going on here. The way substitute is behaving like an identity operator is really weird. As a final puzzle piece, I'll note differentiation also silently produces unexpected results. Differential(X_sym[1])(X) |> expand_derivatives should produce γ₀ (type KVector{1, LGAWest(3), Real}), but instead produces 0. Again, compare to Differential(X_sym[1])(c) |> expand_derivatives which correctly produces 1.
Thanks in advance!
The text was updated successfully, but these errors were encountered:
Hi,
I've been experimenting with combining
Symbolics.jl
with other mathematical libraries. I've noticed that in some cases, thesubstitute
can fail dramatically, without any error or indication of a missing method definition.typeof(X) = 1-element KVector{0, LGAWest(3), Num}
which is idiomatic and expected. Compare, for example, toc = X_sym[1] + X_sym[2] * im
, for whichtypeof(c) = Complex{Num}
.There are several open issues at time of writing about the type
Complex{Num}
. A similar issue is likely happening here. The actual behavior seen isThe behavior that should happen, as compared with the analogous
Complex{Num}
case:I'm really quite puzzled about what's going on here. The way
substitute
is behaving like an identity operator is really weird. As a final puzzle piece, I'll note differentiation also silently produces unexpected results.Differential(X_sym[1])(X) |> expand_derivatives
should produceγ₀
(typeKVector{1, LGAWest(3), Real}
), but instead produces0
. Again, compare toDifferential(X_sym[1])(c) |> expand_derivatives
which correctly produces1
.Thanks in advance!
The text was updated successfully, but these errors were encountered: