Skip to content

Conversation

fp4code
Copy link

@fp4code fp4code commented Jul 10, 2019

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.

@antoine-levitt
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants