# Why does Arg'[1. + I] return -0.5?

From the document we know that

Arg[z] gives the gives the argument of the complex number z.

Then how about Arg'[z]? This seems to be meaningless, but Mathematica returns something if z is a non-exact number, for example

Arg'[1. + I]
(* -0.5 *)

So my question is:

1. How is the numeric value of Arg'[z] defined?

2. Why does Arg' behave like this? What's the potential usage of this behavior?

• This can shed some light: Trace[ Arg'[1. + I], TraceInternal -> True ]
– Kuba
Apr 25, 2019 at 8:04
• It is impossible to understand what the output from Trace[ Arg'[1. + I], TraceInternal -> True ] mean. May be numerics gone mad or something :) so just change 1.0 to 1 in the example given and then Arg will no longer do what you show. Apr 25, 2019 at 8:08
• @Kuba Oh blinding light… Apr 25, 2019 at 8:09
• @Nasser and xzczd it looks like it calculates derivative value from set of points f or Arg, but I wasn't paying too much attention.
– Kuba
Apr 25, 2019 at 8:11
• May 1, 2019 at 15:27

The internal Trace[] Kuba advises shows calculations consistent with the numeric approximation of the partial derivative with respect to the real part:

D[ComplexExpand[Arg[x + I y], TargetFunctions -> {Re, Im}], x] /.
x -> 1 /. y -> 1
(*  -(1/2)  *)

This is what Mathematica does with the derivative of a numeric function with approximate input.

Other examples:

ClearAll[f, g];
f[x_?NumericQ] := Re[x]^2;
g[x_?NumericQ] := Im[x]^2;

f'[1. + I]
g'[1. + I]
(*
1.999999999999995
-2.7506672371246275*^-15
*)

It seems like the wrong way to evaluate Derivative.

• Funny, Abs'[2. + I] returns the input. Apr 25, 2019 at 11:19
• @xzczd I guess they protected Abs'[] from being evaluated in this way. Re'[] and Im'[] do not evaluate, also. Maybe they overlooked Arg'[]? Apr 25, 2019 at 14:21

The definition of the argument is $$\arg(z)=\text{Im}(\ln(z))$$. Its partial derivative with respect to $$z$$ would then be

$$\frac{\partial \arg(z)}{\partial z}= \frac{\partial}{\partial z}\frac{\ln(z)-\ln(z^*)}{2i} = -\frac{i}{2z}.$$

What you see looks like twice the real part of this expression:

With[{z = 2. + 5 I},
{Arg'[z], 2Re[-I/(2z)]}]

(* {-0.172414, -0.172414} *)

I don't know in which sense this is the "correct" answer. It could be that what is actually calculated is not the partial derivative with respect to $$z$$, but rather the partial derivative with respect to the real part of $$z$$:

$$\frac{\partial \arg(z)}{\partial\text{Re}(z)} =\frac{\partial \arg(z)}{\partial z}\frac{\partial z}{\partial\text{Re}(z)} +\frac{\partial \arg(z)}{\partial z^*}\frac{\partial z^*}{\partial\text{Re}(z)}\\ =\frac{\partial \arg(z)}{\partial z} +\frac{\partial \arg(z)}{\partial z^*} = -\frac{i}{2z}+\frac{i}{2z^*} = -\frac{\text{Im}(z)}{|z|^2}$$

With[{z = 2. + 5 I},
{Arg'[z], 2Re[-I/(2z)], -Im[z]/Abs[z]^2}]

(* {-0.172414, -0.172414, -0.172414} *)
• Er… how is derivative of $\ln(z^*)$ defined here? Apr 25, 2019 at 8:45
• Any idea why then With[{z = 1.0 + I}, Arg'[z]] not same as With[{z = 1 + I}, Arg'[z]]? Should not these give same result? Apr 25, 2019 at 8:47
• @xzczd $z$ and $z^*$ are independent variables in complex analysis, so $\partial z^*/\partial z=0$ etc. Apr 25, 2019 at 8:48
• @Nasser they do give the same result when you apply N: Arg'[1 + I] // N also gives -0.5. Apr 25, 2019 at 8:50