julia> ForwardDiff.derivative(identity, 1+im)
ERROR: DimensionMismatch: derivative(f, x) expects that x is a real number (does not support Wirtinger derivatives). Separate real and imaginary parts of the input.
Stacktrace:
[1] derivative(f::Function, x::Complex{Int64})
@ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/derivative.jl:73
[2] top-level scope
@ REPL[35]:1
I think the following should work:
Note that https://github.com/JuliaDiff/ForwardDiff.jl/issues?q=is%3Aissue+is%3Aclosed+complex supports
Complex{<:Dual}
so the implementation would be really straightforward.I was surprised not to see a discussion on this. Would a PR adding automatic support for complex differentiation be merged?