0
$\begingroup$

I tried to differentiate D[Abs[z],z] and instead of Sign[z], I got the following:

Derivative[1][Abs][z]

Did I do something wrong or Mathematica just does not know how to differentiate?

$\endgroup$
  • 3
    $\begingroup$ At the very top of the Mathematica,Stackexchange.com web page there is "Search on Mathematica..." If you type differentiate abs or derivative abs into that and tap Enter and read some of the posts on this subject then that may explain some of this to you. $\endgroup$ – Bill Dec 26 '18 at 22:51
  • $\begingroup$ If someone can suggest a better duplicate, I can add a link. $\endgroup$ – Michael E2 Dec 27 '18 at 2:16
  • $\begingroup$ As of version 11, there's a function RealAbs whose domain is restricted to reals. It is therefore differentiable, unlike Abs. $\endgroup$ – John Doty Dec 27 '18 at 14:18
  • $\begingroup$ There's also ComplexExpand: Derivative[1][Abs][z] // ComplexExpand $\endgroup$ – Michael E2 Dec 27 '18 at 20:58
  • $\begingroup$ Now, I try FullSimplify[Sign'[x], x [Element] Reals]. It should give DiracDelta and it doesn't. Any advice? $\endgroup$ – user1765636 Dec 29 '18 at 22:03
2
$\begingroup$

For z real

Abs[z] == Sqrt[z^2] // Simplify[#, Element[z, Reals]] &

(* True *)

D[Abs[z] /. Abs[x_] :> Sqrt[x^2], z] // Simplify[#, Element[z, Reals]] &

(* z/Abs[z] *)

This is only equal to Sign[z] if z is real and z != 0

% == Sign[z] // Simplify[#, Element[z, Reals]] &

(* z != 0 *)

%% == Sign[z] // Simplify[#, Element[z, Reals] && z != 0] &

(* True *)

EDIT: That is,

D[Abs[z] /. Abs[x_] :> Sqrt[x^2], z] // 
 FullSimplify[#, Element[z, Reals] && z != 0] &

(* Sign[z] *)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.