Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can someone be so nice to provide some help for this particular situation? I try to plot a graph of a derivative which contains modulus. Without it the graph is drawn correctly:

correct graph

But when I wrap the expression in the Abs Mathematica outputs an empty graph:

empty graph

I looked for several answers related to empty graphs, but nothing seems to fit to my case. Thanks in advance.

share|improve this question
Workaround: With[{a = Piecewise[{{#, # >= 0}, {-#, # < 0}}, 0] &}, Plot[Evaluate[D[a[5 - 2 x], x]], {x, -1*^3, 1*^3}, Axes -> None, PlotRange -> {-1*^3, 1*^3}]] – J. M. May 8 '13 at 15:25
@J. M, thank you, it works – user907860 May 8 '13 at 15:27
up vote 10 down vote accepted

Might it be the way Mathematica deals with the derivative of Abs[]? For example,

D[Abs[5 - 2 x], x]


-2*Derivative[1][Abs][5 - 2*x]


Plot[Evaluate[D[Sqrt[(5 - 2 x)^2], x]], {x, -10, 10}]
share|improve this answer
I was about to say that, so I added the relevant example to your answer. +1 – rcollyer May 8 '13 at 15:36

I'm also wondering why Mathematica doesn't treat the derivative of Abs as normal way. But here is a solution.

Plot[Evaluate@ComplexExpand[D[Abs[5 - 2 x], x]], {x, -10, 10}]
share|improve this answer
"I'm also wondering..." - that Mathematica considers variables to take complex values by default is a hint... – J. M. May 9 '13 at 3:44
Perhaps not everyone knows that as a function of a complex variable, Abs[z] is not differentiable at any z. – Michael E2 May 9 '13 at 3:49
@J.M. Yes. Sometimes if plotting a complex function carelessly , Mathematica will return a empty graphic. I think in this occasion, it will be helpful if Mathematica give some warnings. – luyuwuli May 9 '13 at 4:11
@MichaelE2 Mathematica often tells me to rethink about the complex variables:) – luyuwuli May 9 '13 at 4:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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