1
$\begingroup$

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?

$\endgroup$
6
  • 2
    $\begingroup$ 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. $\endgroup$
    – Michael E2
    Dec 7, 2021 at 16:08
  • $\begingroup$ Related: (3810), (8188), (59503) $\endgroup$
    – Michael E2
    Dec 7, 2021 at 16:13
  • 2
    $\begingroup$ 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. $\endgroup$
    – Michael E2
    Dec 7, 2021 at 16:17
  • $\begingroup$ @MichaelE2 I think this actually helps! Thanks! How can I mark your reply as the answer? $\endgroup$ Dec 7, 2021 at 16:40
  • $\begingroup$ 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.) $\endgroup$
    – Michael E2
    Dec 7, 2021 at 16:48

1 Answer 1

3
$\begingroup$

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

$\endgroup$

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.