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
Arithmetic operations appear to be ambiguous when combining Num:s with ForwardDiff. A minimal example is below (originally reported here):
using Symbolics
using ForwardDiff
@variables a, x
function f(x)
a*x
end
ForwardDiff.derivative(f, x)
which yields the following error:
ERROR: MethodError: *(::Num, ::ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Num}, Num, 1}) is ambiguous.
Candidates:
*(x::Real, y::ForwardDiff.Dual{Ty}) where Ty
@ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:145
*(a::Num, b::Real)
@ Symbolics ~/.julia/packages/SymbolicUtils/r1pzW/src/methods.jl:73
*(a::Num, b::Number)
@ Symbolics ~/.julia/packages/SymbolicUtils/r1pzW/src/methods.jl:75
Possible fix, define
*(::Num, ::ForwardDiff.Dual{Ty}) where Ty
Stacktrace:
[1] f(x::ForwardDiff.Dual{ForwardDiff.Tag{typeof(f), Num}, Num, 1})
@ Main ./REPL[4]:2
[2] derivative(f::typeof(f), x::Num)
@ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/derivative.jl:14
[3] top-level scope
@ REPL[5]:1
I'm trying to come up with a fix for this, but my understanding of Symbolics is still superficial. Would adding the (::Num, ::ForwardDiff.Dual{Ty}) methods to Symbolics similarly as here be a reasonable approach?
The text was updated successfully, but these errors were encountered:
Hi!
Arithmetic operations appear to be ambiguous when combining Num:s with ForwardDiff. A minimal example is below (originally reported here):
which yields the following error:
I'm trying to come up with a fix for this, but my understanding of
Symbolics
is still superficial. Would adding the(::Num, ::ForwardDiff.Dual{Ty})
methods to Symbolics similarly as here be a reasonable approach?The text was updated successfully, but these errors were encountered: