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

support for complex valued function

Open atbug opened this issue 7 years ago • 5 comments

IIUC, ForwardDiff.jl does not support complex valued function such as x->exp(im*x). Is there any plan to support this? I believe this is possible since AutoGrad.jl seems to support this.

atbug avatar Oct 09 '18 05:10 atbug

Ref #157

fredrikekre avatar Oct 09 '18 06:10 fredrikekre

I believe #157 is talking about complex arguments, not complex valued functions. Complex values functions should be much simpler since I am talking real arguments.

atbug avatar Oct 09 '18 06:10 atbug

Support for complex-valued functions with real arguments was added in https://github.com/JuliaDiff/ForwardDiff.jl/pull/583:

julia> using ForwardDiff

julia> ForwardDiff.derivative(x->exp(im*x), 1.0)
-0.8414709848078965 + 0.5403023058681398im

devmotion avatar May 16 '22 09:05 devmotion

Support for complex-valued functions with real arguments was added in #583:

julia> using ForwardDiff

julia> ForwardDiff.derivative(x->exp(im*x), 1.0)
-0.8414709848078965 + 0.5403023058681398im

ForwardDiff.gradient etc don't work for complex valued functions of multiple real arguments

petar-andrejic avatar Nov 25 '22 07:11 petar-andrejic

e.g.

julia> ForwardDiff.gradient(x->exp(im * x[1]+x[2]), [3.0,2.0])
ERROR: DimensionMismatch: gradient(f, x) expects that f(x) is a real number. Perhaps you meant jacobian(f, x)?

petar-andrejic avatar Nov 25 '22 07:11 petar-andrejic