DiffRules.jl icon indicating copy to clipboard operation
DiffRules.jl copied to clipboard

Added support for complex differentiable functions

Open fp4code opened this issue 6 years ago • 1 comments

When a complex function of a complex variable is differentiable, @define_diffrule can be replaced with @define_complex_diffrule. Then both diffrule and complex_diffrule will exist.

fp4code avatar Jul 10 '19 15:07 fp4code

I think this should be merged. Then ForwardDiff can use it to fix this very bad issue:

using ForwardDiff
f(x) = exp(2.0+im*x)
@show ForwardDiff.derivative(f, 0.0)
@show (f(1e-8) - f(0))/1e-8

This bug is because this just runs exp(::Complex) with a Complex{Dual}, and that method has a if imag(x) == 0 .... The PR seems reasonable to me but probably has to be updated. @fp4code are you still interested in this and can you do it?

antoine-levitt avatar Nov 27 '24 09:11 antoine-levitt