Let us define a simple complex function Exp[-j*x], j is a square root of -1.
Fase of this function is computed by Arg -function.
If x is a real number the fase is equal -x and it's derivative is -1.
If x is a complex number the fase is equal Re[-x].
But if we would write:
f[x_] = Arg[E^(-j*x\)]; N[D[f[x], x]]\ /. \ x -> 5+j*3
we would get a complex number not equal -1.
In case of a real x, this problem may be solved by ComplexExpand-function:
f[x_] = ComplexExpand[Arg[E^(-j*x\)]]; N[D[f[x], x]]\ /. \ x -> 5
we would get -1.
In case of a complex x, Matematica gives a wrong solution.
Would you correct me if I make a mistake.
Wishes
Alex Klishko
The short answer is that the derivative of Arg is undefined: Arg is
not an analytical function. Just consider what happens when you move
along different directions, for example, from 1 to 1+eps and from 1 to
1+I*eps, with real eps.
There's the question of whether the value of, say, N[Arg'[1+I]] has
any meaning (Mathematica 5.0 gives -0.5). It turns out that it does:
it gives the directional derivative along the real axis. Here's the
explicit expression for this directional derivative:
In[1]:=
ComplexExpand[(Arg[z + h] - Arg[z])/h, z,
TargetFunctions -> Abs] //
Limit[#, h -> 0] & // FullSimplify
Out[1]=
-Im[z]/Abs[z]^2
For z=1+I we get -1/2 as expected. Note that by default ComplexExpand
assumes that all variables are real.
I believe that earlier versions of Mathematica gave similar results
for numerical values of Im', Re', Abs', but those just remain
unevaluated now; N[Arg'] seems to be a relict. This leads to some
contradictions: for example,
In[2]:=
Limit[(Arg[1 + I + I*h] - Arg[1 + I])/(I*h), h -> 0]
Out[2]=
Arg'[1 + I]
while in fact here we're taking the directional derivative along a
different direction, which means that -1/2 is an incorrect value for
this limit.
Maxim Rytin
m...@inbox.ru
>> On 2 Jun 2004, at 17:21, Andrzej Kozlowski wrote:
>>
>> I am not sure what you mean by "fase"? Is that just Arg[E^(-I*x)]? Are
>> you saying that this is -Re[x] for all complex x? Well, that certianly
>> is not true, even for real ones!
>
> You are right, Arg[E^(-I*x)] is equal to -x +2*Pi*n, where n is an
> integer number so, that -Pi<%<Pi.
I suppose you mean -Re[x]+2*Pi*n. But of course for complex x Re[x]
is not differentiable (as a function of the complex variable x !) so
Mathematica is quite right not to return -1.
Of course
D[ComplexExpand[Arg[E^((-I)*x)], {x}],Re[x]]//Simplify
-1
but that is a completely differnt thing!
Andrzej Kozlowski
>
> But I need an Arg's derivative.
> As 2*Pi*n is the constant so the derivative doesn't depend on it.
> So the derivative must be -1.
>
> By the way,
> f[x_] = ComplexExpand[Arg[E^(-I*x)]]; N[D[f[x], x]] /. x -> x0
>
> gives -1, for any x0 (if you substitute instead x0 any real number)
>
> I suppose you mean -Re[x]+2*Pi*n. But of course for complex x Re[x]
Yes, of course.
> is not differentiable (as a function of the complex variable x !) so
> Mathematica is quite right not to return -1.
Yes, but Mathematica is not right to return another definite number.
Best wishes
Alex Klishko
> The short answer is that the derivative of Arg is undefined: Arg is
> not an analytical function. Just consider what happens when you move
> along different directions, for example, from 1 to 1+eps and from 1 to
> 1+I*eps, with real eps.
I think you mean that derivative is Limit[(f[z+dz]-f[z])/dz,dz->0]
and for f=Arg it's depends on Re[dz] and Im[dz].
The fisrt case (from 1 to 1+eps) corresponds to Im[dz]=0, the second
case(from 1 to 1+I*eps) Re[dz]=0.
I think the problem in another field, namely, in that fact that Arg is
discontinuous function.
A complex number z=Re+I*Im, we may represend also as z=Abs*E^(I*Arg).
Where Abs=Squre root[Re^2+Im^2], Arg=ArcTan[Im/Re].
Hense as my function is f=E^(I*z)=E^(-Im)*E^(I*Re)
so Arg[f]=Re[z] by definition.
Therefore Arg'[E^(I*z)]=Re'[z].
So in that case the derivative is define only for real z, but
Mathematica does not show any error message for not real z and gives
definite number.
I think it's a bug.
Examples:
f[x_] := Arg[E^(-I*x)] ; N[D[f[x], x]] /. x -> 5 +3*I
Clear[f]
Out: -0.919536 + 0.272011*I
f[x_] := Arg[E^(-I*x)] ; N[D[f[x], x]] /. x -> 5
Clear[f]
Out: -0.919536 + 0.272011*I
f[x_] := ComplexExpand@Arg[E^(-I* x)] ; N[D[f[x], x]] /. x -> 5
Clear[f]
Out: -1.
By the way
---------------------
dArg=(1/(1+(Im/Re)^2))*d(Im/Re)=(-Im*dRe+Re*dIm)/Abs^2
>
> In[1]:=
> ComplexExpand[(Arg[z + h] - Arg[z])/h, z,
> TargetFunctions -> Abs] //
> Limit[#, h -> 0] & // FullSimplify
>
> Out[1]=
> -Im[z]/Abs[z]^2
In that case Mathematica suppose that dRe=dz, and dIm=0.
-----------------------
Best wishes
Alex Klishko
On 8 Jun 2004, at 13:48, Alex Klishko wrote:
> Andrzej Kozlowski <ak...@mimuw.edu.pl> wrote in message
>
>> I suppose you mean -Re[x]+2*Pi*n. But of course for complex x Re[x]
> Yes, of course.
>
>> is not differentiable (as a function of the complex variable x !) so
>> Mathematica is quite right not to return -1.
>
> Yes, but Mathematica is not right to return another definite number.
>
>
Yes, but only when you use N. In such cases it performs numerical
differentiation. In the case of Arg it looks like a bug, as Maxim has
already pointed out. Note, however that:
N[D[ComplexExpand[Arg[E^((-I)*x)], {x}], x] /. x -> 1]
-1.*Derivative[1][Re][1.]
Andrzej
> The short answer is that the derivative of Arg is undefined: Arg is
> not an analytical function. Just consider what happens when you move
> along different directions, for example, from 1 to 1+eps and from 1 to
> 1+I*eps, with real eps.
Yes, you are right.
I think that when Mathematica take numerical derivative, it's ought to
show error message in case of complex argument (without using
ComplexExpand) .
> In[1]:=
> ComplexExpand[(Arg[z + h] - Arg[z])/h, z,
> TargetFunctions -> Abs] //
> Limit[#, h -> 0] & // FullSimplify
>
> Out[1]=
> -Im[z]/Abs[z]^2
It's right for real argument, when Re'=1 or dRe[z]=dz
It common case it should be (-Im[z]*Re'[z]+Re[z]*Im'[z])/Abs[z]^2
Best wishes
Alex Klishko