Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute a partial derivative with respect to a complex variable or its conjugate
| ResourceFunction["ComplexD"][f,z] gives the partial derivative  | |
| ResourceFunction["ComplexD"][f,Conjugate[z]] gives the partial derivative with respect to the complex conjugate of z. | |
| ResourceFunction["ComplexD"][f,{z,n}] gives the multiple derivative. | 
Complex derivative of a function:
| In[1]:= | ![ResourceFunction["ComplexD"][Sin[z Conjugate[z]], Conjugate[z]]](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/79068aed4d2de457.png) | 
| Out[1]= |  | 
ComplexD works with Abs:
| In[2]:= | ![ResourceFunction["ComplexD"][Abs[z]^2, z]](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/6080c180f82bd313.png) | 
| Out[2]= |  | 
Compare ComplexD with its definition for a function:
| In[3]:= | ![f = Conjugate @ Sin[z Conjugate[z]^2];](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/4bba59b0da41eb5e.png) | 
Find the complex derivative using the definition in terms of derivatives with respect to the real and imaginary parts:
| In[4]:= | ![With[{xy = ComplexExpand[f, z] /. {Re[z] -> x, Im[z] -> y}},
 1/2 (D[xy, x] - I D[xy, y]) // Simplify
 ]](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/0468ca481167d6cf.png) | 
| Out[4]= |  | 
Use ComplexExpand on the output of ComplexD:
| In[5]:= | ![Simplify[
 ComplexExpand[ResourceFunction["ComplexD"][f, z], z] /. {Re[z] -> x, Im[z] -> y}
 ]](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/4b4d454a2ab5a4fe.png) | 
| Out[5]= |  | 
More complicated expressions can be differentiated by first complex expanding the expression into one that consists of Conjugate only:
| In[6]:= | ![ResourceFunction["ComplexD"][
  ComplexExpand[Re[z] Im[z] Sign[z], z, TargetFunctions -> Conjugate],
  z
  ] // Simplify](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/2d3daf90b4f82644.png) | 
| Out[6]= |  | 
Use ComplexD to find the real derivative (i.e. the derivative with respect to the real part only):
| In[7]:= | ![RealD[f_, z_] := ResourceFunction["ComplexD"][f, z] + ResourceFunction["ComplexD"][f, Conjugate[z]]](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/55c78358a61a4b33.png) | 
For example, here is the "real" derivative of Abs:
| In[8]:= | ![RealD[Abs[z], z] // FullSimplify](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/4868359754145049.png) | 
| Out[8]= |  | 
Compare to the usual definition of the real derivative (h is treated as real here):
| In[9]:= | ![Limit[(Abs[z + h] - Abs[z])/h, h -> 0] // FullSimplify](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/5dda2fc90ea86677.png) | 
| Out[9]= |  | 
The complex variable z and its conjugate are independent:
| In[10]:= | ![ResourceFunction["ComplexD"][z, Conjugate[z]]](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/5e31868fd76977e7.png) | 
| Out[10]= |  | 
| In[11]:= | ![ResourceFunction["ComplexD"][Conjugate[z], z]](https://www.wolframcloud.com/obj/resourcesystem/images/3f6/3f6fe816-4716-477a-b200-aeb79ba4c7a6/127e288074c29de6.png) | 
| Out[11]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License