12
$\begingroup$

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?

$\endgroup$
8
  • $\begingroup$ This can shed some light: Trace[ Arg'[1. + I], TraceInternal -> True ] $\endgroup$
    – Kuba
    Commented Apr 25, 2019 at 8:04
  • $\begingroup$ 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. $\endgroup$
    – Nasser
    Commented Apr 25, 2019 at 8:08
  • $\begingroup$ @Kuba Oh blinding light… $\endgroup$
    – xzczd
    Commented Apr 25, 2019 at 8:09
  • $\begingroup$ @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. $\endgroup$
    – Kuba
    Commented Apr 25, 2019 at 8:11
  • 1
    $\begingroup$ Related: mathematica.stackexchange.com/questions/29329/… $\endgroup$
    – Michael E2
    Commented May 1, 2019 at 15:27

2 Answers 2

9
$\begingroup$

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.

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

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} *)
$\endgroup$
4
  • $\begingroup$ Er… how is derivative of $\ln(z^*)$ defined here? $\endgroup$
    – xzczd
    Commented Apr 25, 2019 at 8:45
  • $\begingroup$ 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? $\endgroup$
    – Nasser
    Commented Apr 25, 2019 at 8:47
  • $\begingroup$ @xzczd $z$ and $z^*$ are independent variables in complex analysis, so $\partial z^*/\partial z=0$ etc. $\endgroup$
    – Roman
    Commented Apr 25, 2019 at 8:48
  • 1
    $\begingroup$ @Nasser they do give the same result when you apply N: Arg'[1 + I] // N also gives -0.5. $\endgroup$
    – Roman
    Commented Apr 25, 2019 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.