Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for complex differentiable functions #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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