Inconsistency in derivative computation in Symbolics.jl

These two ways of computing the derivative in Symbolics return the same result, as expected:

using Symbolics
@variables k1,k2

julia> Symbolics.derivative(^,(k1,k2),Val(1))
k2*(k1^(k2 - 1))
julia> Symbolics.derivative(k1^k2,k1)
k2*(k1^(k2 - 1))

But these two don’t:

julia> Symbolics.derivative(k1^k2,k2)

julia> Symbolics.derivative(^,(k1,k2),Val(2))
ERROR: TypeError: non-boolean (Num) used in boolean context
 [1] derivative(#unused#::typeof(^), args::Tuple{Num, Num}, #unused#::Val{2})
   @ Symbolics C:\Users\seatt\.julia\packages\Symbolics\FGTCH\src\diff.jl:344
 [2] top-level scope
   @ REPL[46]:1

Is this a bug?

installed packages
Status `C:\Users\seatt\source\Differentiation\Project.toml`
  [5ae59095] Colors v0.12.10
  [b552c78f] DiffRules v1.12.2
  [a2cc645c] GraphPlot v0.5.2
  [bd48cda9] GraphRecipes v0.5.12
  [f526b714] GraphViz v0.2.0
  [86223c79] Graphs v1.7.4
  [b964fa9f] LaTeXStrings v1.3.0
  [e9d8d322] Metatheory v1.3.5
  [91a5bcdd] Plots v1.38.0
  [6c8a4c8a] RelevanceStacktrace v0.1.8
  [c5292f4c] ResumableFunctions v0.6.1
  [295af30f] Revise v3.4.0
  [90137ffa] StaticArrays v1.5.11
  [d1185830] SymbolicUtils v0.19.11
  [0c5d862f] Symbolics v4.13.0
⌅ [8ea1fca8] TermInterface v0.2.3
  [f8b46487] TestItemRunner v0.2.1
  [1c621080] TestItems v0.1.0
  [b4f28e30] TikzGraphs v1.4.0
  [8dfed614] Test
version info
julia> versioninfo()
Julia Version 1.8.3
Commit 0434deb161 (2022-11-14 20:14 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 32 × AMD Ryzen 9 7950X 16-Core Processor
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, znver3)
  Threads: 32 on 32 virtual cores
  JULIA_EDITOR = code.cmd
1 Like

Yeah it looks like there’s a missing overload there. Please open an issue.