# Calculation of a Jacobian of a set of complex functions in Julia

I want to calculate the numerical Jacobian of complex functions using the Julia ForwardDiff package.

``````using ForwardDiff

f(θ,i,u) = [1im *i * exp(-1im * θ), 1im * u * exp(-1im * θ)] # Complex Current and Voltage

z = [1,1,1]
ForwardDiff.jacobian(x -> f(x[1],x[2],x[3]), z)
``````

But when I run this simple example I get the following result:

``````2×3 Array{Complex{Dual{ForwardDiff.Tag{var"#138#139",Int64},Float64,3}},2}:
Dual{ForwardDiff.Tag{var"#138#139",Int64}}(0.0,0.0,0.0,0.0) + Dual{ForwardDiff.Tag{var"#138#139",Int64}}(0.0,0.0,0.0,0.0)im
...
``````

I am not really sure what happend there. When I use a real function for the Jacobian I get the expected output.

``````f(θ,i,u) = [i * exp(-θ), u * exp(-θ)]

z = [10,1,1]
ForwardDiff.jacobian(x -> f(x[1],x[2],x[3]), z)

2×3 Array{Float64,2}:
-4.53999e-5  4.53999e-5  0.0
-4.53999e-5  0.0         4.53999e-5
``````

Then after reading: Automatic differentiation of complex valued functions, I am surprised that the complex function worked at all…