Plotting function involving derivative of Abs(x)

Hello everybody,

I was experimenting with some functions useful in physics and learning to plot some. At one point, I decided to toy with f=Abs. Plotting gave the expected. I took the derivative of this function and then tried to plot it. No luck there… There is only the coordinate system while I had expected to see the usual “step” function. For negative numbers for x, the derivative should be -1 always, and plus one for positive x. Plot[Evaluate[D[f, x_]], {x, -2, 2}] does not work. The command Plot[Evaluate[x/Abs], {x, -2, 2}] does give the expected plot.

I may be doing something very silly but or I came immediately across something pretty damn strange.

Thanks,

Patrick

I once asked Technical Support why Abs’ is not defined. They told me that Abs doesn’t satisfy the Cauchy-Riemann equations so the derivative can’t be defined in the complex plane.

Yes, that’s correct.
Mathematica is aware of what happens when you only consider real values, so if you do have equations with this, you can still work with them using FullSimplify pretty easily:

FullSimplify[Abs'[x], Assumptions -> {Element[x, Reals]}]

And if you want to, it’s possible to add these definitions to Mathematica.

Thank you. I wrongly assumed that telling x to be between -2 and 2 would make it realize it is real (admittedly, I also did not think of what happens in the complex plane). I had some practice already and being a chemist, I use a lot of maths but Mathematica makes you quite aware of the ‘fine print’ of our methods!
Thanks,
Patrick