Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
1  
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 –  user5693 May 8 '13 at 15:27

2 Answers 2

up vote 8 down vote accepted

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

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

returns

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

Try

Plot[Evaluate[D[Sqrt[(5 - 2 x)^2], x]], {x, -10, 10}]
share|improve this answer
2  
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

 
discard

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.