ForwardDiff needs a lot more than just opening up type signatures to work with complex numbers, so I wouldnât expect this to just work any time soon. You can split to real and imaginary parts and diff that. We are making essentially a ForwardDiff 2.0 (with Jarrettâs blessing ) to address this, along with the lack of multivariate rules (use BLAS!) and post-hoc rule definition (via ChainRules).
Itâs a new repo. I hope we can open it up by next week with some preliminary results. Itâs quite cool: itâs struct of arrays and matrix backed with Cassette generating the connection to ChainRules.jl
Also, you will be able to do this type of automatic differentiation with Grassmann.jl after I finish implementing the Leibniz.jl package for working with the symmetric differentials. Complex number algebra is simply a subalgera of the geometric algebra in Grassmann and by extending it with the symmetric Leibniz algebra the automatic differentiation is automatically built-in, as described in my paper.
julia> using Grassmann, basis"2"
(â¨++âŠ, v, vâ, vâ, vââ)
julia> f2(t) = real(sqrt(cos(t)+vectorspace(t)(I)*sin(t)))
f2 (generic function with 1 method)
julia> f2((pi/2)v)
0.7070714177261098vâ
All of the methods needed for your AD example are already implemented in Grassmann variables so now I only need to finish implementing the extended support for the Leibniz indices and then you will be able to also tack on the derivatives also to get the forward mode AD.
You will be able to work with it using this extended tangent basis⌠which is still a work in progress. In the near future I will resume work on this aspect when I get around to it.