Message Boards Message Boards

4 Replies
0 Total Likes
View groups...
Share this post:

Why I am getting Abs' when I am doing derivative over a complex function?

Posted 10 years ago

Hi all,

I am pretty new in Mathematica, so that might be a simple question!

I am defining a function in complex space, then I am trying to use its module and argument (Abs and arg). At the end of the day, I'd like to take derivative of that. The output seems pretty weird for me. I am getting Abs' and do not know how to deal with that. Here is the sample of my work:

T1[A_, B_, f] = (A + I*B)*f;
Rho1 = Log[Abs[T1[A, B, f]]] - Log[Abs[11 + I*22]]
D[Rho1, A]
(f Abs'[(A + I B) f])/Abs[(A + I B) f]

And even when I evaluate that after ComplexExpand at a simple point it gives me wrong answer:

ComplexExpand(f Abs'[(A + I B) f])/
 Abs[(A + I B) f] /. {A -> 2 , B -> 1 , f -> 100}

But it should be 2/5!

I am wondering if any one has some idea in relate of that. I have attached the file as well.

Thanks, Sardar

POSTED BY: Ali Mousavian
4 Replies

If it is a real-valued function f[z] of a complex-valued variable x=x+I*y, then you really have to consider separately D[f,x] and D[f,y]. You are, in effect, not distinguishing (I was tempted to say "differentiating") between these, and that is messing things up. It will also be necessary to write the function in such a way that dependencies on {x,y} are explicit.

POSTED BY: Daniel Lichtblau
Posted 10 years ago

Thanks for your response David,

That idea is working pretty well for that case but if I make my function more complicated, again it turns out "Arg' " . I do not understand that pretty well, I have a function which is always real, but its derivatives might be complex? Could you take a quick look at the attachment? I have a rather complicated function which is always real valued (I have plotted the function and its imaginary part for comparison) then I am taking Complex Expand and then the derivative of that. If I evaluate the function after derivative, the result is complex. Is it true answer or I am doing something wrong.

Thanks, Sardar

POSTED BY: Ali Mousavian

As I mention above, the absolute value function is not complex differentiable. This is because it does not satisy the Cauchy Riemann Equations:

In[1]:= u = ComplexExpand[Re[Abs[x + I y]]]

Out[1]= Sqrt[x^2 + y^2]

In[2]:= v = Im[Abs[x + I y]]

Out[2]= 0

In[3]:= D[u, x]

Out[3]= x/Sqrt[x^2 + y^2]

<a href="–Riemann_equations">–Riemann_equations

Thus in your attached notebook (to avoid differentiating the Abs function via the chain rule) you need to do ComplexExpand before doing any differentiations.


ComplexExpand[F[A, B, f]];
D[F[A, B, 1] , A] /. {A -> 1 , B -> 1}

should be replaced by

D[ComplexExpand [F[A, B, 1]] , A] /. {A -> 1 , B -> 1}

An additional bit of advice: you should define your functions using a delayed evaluation (:=) rather than an immediate evaluation (=).

(Also in your attached notebook Re1 and Im1 are not defined.)

You get a Abs'[...] in your result because of the chain rule, but Abs['[...] cannot be interpreted in an unambiguous manner. Therefore you need to avoid it.

POSTED BY: David Reiss

The reason why you are encountering this issue, I think, is that the derivative of the absolute value generally does not exist in the complex plane, though it does exist on the real line--or any other fixed curve in the complex plane since that determines explicitly the directions of the differentiation. See

and see the discussion in the paragraphs surrounding equation 4. The return of Abs'[...] unevaluated is a sign of this. When you make use of ComplexExpand, it assumes all parameters are real, and so it Evaluates Abs'[z] assuming that z is real, which it isn't in your case.

Thus the correct way to go about your computation is to evaluate


before performing any differentiation. This then leads to your value of 2/5 as expected.

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract