I am trying to find the gradient of the phase of complex exponential functions.
For example:
Grad[Arg[Exp[-I (x + z)]], {x, z}]
Should be {1,1} for all x,z (Reals). However, instead I get:
{-I E^(-I (x + z))
Derivative[1][Arg][E^(-I (x + z))], -I E^(-I (x + z))
Derivative[1][Arg][E^(-I (x + z))]}
I think it has to do with the fact that Arg[Exp[-I (x + z)]] doesn’t return (x+z). I assumed that was because it doesn’t know that x,z are Reals.
I also tried Refine[Arg[Exp[-I (x + z)]], x \[Element] Reals && z \[Element] Reals] but that doesn’t return (x+z) either.
Thanks!
mroge02
(Michael Rogers)
2
ComplexEpand is useful for expanding non-differentiable complex functions into differentiable real functions:
Grad[ComplexExpand@Arg[Exp[-I (x + z)]], {x, z}]
(*
{-(Cos[x + z]^2/(Cos[x + z]^2 + Sin[x + z]^2)) - Sin[x + z]^2/(Cos[x + z]^2 + Sin[x + z]^2),
-(Cos[x + z]^2/(Cos[x + z]^2 + Sin[x + z]^2)) - Sin[x + z]^2/(Cos[x + z]^2 + Sin[x + z]^2)}
*)
dmoore101
(David Moore)
3
Here’s another way to get the correct result, using the mathematical property that Log[z]==Log[Abs[z]]+I Arg[z]
In[]:= Im[Grad[Log[Exp[-I (x + z)]], {x, z}]]
Out[]= {-1, -1}
The problem is that Grad is trying to take the complex derivative of Arg, which is not a complex differentiable function.
Beware that your function Arg[Exp[-I (x + z)]] has discontinuities, as you can see from a plot:
Plot3D[Arg[Exp[-I (x + y)]], {x, -2 Pi, Pi}, {y, -2 Pi, 2 Pi}]
Curiously, the following gives True:
FunctionDiscontinuities[Arg[Exp[-I (x + y)]], {x, y}]
Even more puzzling is the output of this:
PiecewiseExpand[Arg[Exp[-I (x + y)]],
0 < x < 2 Pi && 0 < y < 2 Pi,
Reals]