ForwardDiff.jl
ForwardDiff.jl copied to clipboard
support for complex valued function
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.
Ref #157
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.
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
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
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)?