# Automatic complex valued differentiation for adjoint method

**URL:** <https://discourse.julialang.org/t/automatic-complex-valued-differentiation-for-adjoint-method/106408>\
**Category:** Modelling & Simulations\
**Tags:** autodiff\
**Created:** [November 18, 2023, 3:11pm UTC](https://discourse.julialang.org/t/automatic-complex-valued-differentiation-for-adjoint-method/106408 "2023-11-18T15:11:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marco\_menarini](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marco_menarini/32/46117_2.png) [@marco\_menarini](https://discourse.julialang.org/u/marco_menarini)\
**Post date:** [November 18, 2023, 3:11pm UTC](https://discourse.julialang.org/t/automatic-complex-valued-differentiation-for-adjoint-method/106408/1 "2023-11-18T15:11:14Z")

</div>

Is there a package that supports automatic differentiation for complex-valued functions (non-holomorphic)? So far I used a workaround of defining my own [Wirtinger derivative](https://www.bing.com/search?q=wirtinger+derivative+zygote&qs=n&form=QBRE&sp=-1&ghc=1&lq=0&pq=wirtinger+derivative+zygote&sc=8-27&sk=&cvid=7DDA2349CABB4B91804874697A9381D7&ghsh=0&ghacc=0&ghpl=) in Zygote and I use the result as the input for the adjoint problem. However, I can only compute one and the result does not backpropagate.

The goal would be to automate the computation of the adjoint method for optimization like they did with [Angler](https://github.com/fancompute/angler/blob/master/Notebooks/Splitter.ipynb). It would be particularly useful to automatically compute the adjoint of a convolution (using FFT or NFFT), or to optimize contemporarely the real and imaginary part of a photonic structure.

Relevant sources:  
[1]( [[2302.08286] Theory and Implementation of Complex-Valued Neural Networks (arxiv.org)](https://arxiv.org/abs/2302.08286))
