1

So I am getting some results after a computation like:

(-0.741446 - 5.47358 I) Abs'[-0.702207 + 0.0951203 I]

The problem is the derivative in Abs. Could someone explain why I am getting this and how I can get rid of it? Why doesn't mathematica give me a number back instead and it gives derivative of Absolute value?

Michael E2
  • 235,386
  • 17
  • 334
  • 747
  • 2
    The complex absolute value is not differentiable. I don't know how to get rid of it in this case. It's not clear what value it should be. This works when you want the real absolute value: Abs'[2] /. Abs -> RealAbs. But that is not the case here. – Michael E2 Dec 07 '21 at 16:08
  • 2
    Suppose the result came from D[Abs[Sin[t + I t]], t] /. t -> RandomReal[]. Then the fix is D[ComplexExpand@Abs[Sin[t + I t]], t] /. t -> RandomReal[]. In other words, the solution to your problem cannot be inferred just from the result. You have to fix how the result was generated. – Michael E2 Dec 07 '21 at 16:17
  • @MichaelE2 I think this actually helps! Thanks! How can I mark your reply as the answer? – Nikolaos Petropoulos Dec 07 '21 at 16:40
  • You can't accept comments. I put them in an answer below, but the site's community would probably appreciate a more complete question. (You could just use the example from my comment, if it's reasonably representative of the problem.) – Michael E2 Dec 07 '21 at 16:48
  • sorry I didn't add the code because it is really complex function of functions of functions..... and they have huge expressions which I am not explicitly printing not even in my code. What you added below though is really enlightening. – Nikolaos Petropoulos Dec 07 '21 at 17:11

1 Answers1

3

Apparently, my comments provided a solution. It might be better to have a more complete question, but here are my comments, slightly alter to show reproducible output:

The complex absolute value is not differentiable. I don't know how to get rid of it in this case. It's not clear what value it should be. This works when you want the real absolute value: Abs'[2] /. Abs -> RealAbs. But that is not the case here. – Michael E2 33 mins ago

Suppose the result came from

D[Abs[Sin[t + I t]], t] /. t -> 1/3.
(*  (1.10904 + 0.886847 I) [Abs'[0.345541 + 0.320851 I]  *)

Then the fix is

D[ComplexExpand@Abs[Sin[t + I t]], t] /. t -> RandomReal[]
(8  1.41615  *)

In other words, the solution to your problem cannot be inferred just from the result. You have to fix how the result was generated. – Michael E2 24 mins ago

Michael E2
  • 235,386
  • 17
  • 334
  • 747