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.

This question already has an answer here:

I have the following function defined:

IntImpTri[r1_, r2_, r_] := 
  Piecewise[{
    {((4/((r2 - r1)^2)) ((r^2 - r1^2)/2 - r1 (r - r1))), 
     r >= r1 && r < ((r1 + r2)/2)}, 
    {(1/2 - (2/((r2 - r1)^2)) (r^2 - ((r1 + r2)/2)^2) + 
      (4/((r2 - r1)^2)) r2 (r - ((r1 + r2)/2))), 
     r >= ((r1 + r2)/2) && r < r2}, 
    {1, r >= r2}}, 0];

I am using Mathematica 9 and I do not understand why, when I try to plot this function, which is the integral function of a triangle pulse, the figure shows an interruption in the line.

If I try the following command: Plot[IntImpTri[0, 4, r], {r, -1, 5}], I get the following output:

enter image description here

There is a discontinuity around x=2 but the piecewise covers everything!

share|improve this question

marked as duplicate by whuber, Sjoerd C. de Vries, m_goldberg, Artes, J. M. Apr 30 '13 at 23:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
I am using Mathematica under Unix... –  Andry Apr 30 '13 at 21:40
    
I am not sure exactly why it is missing this point (must be something with how Plot is decided to recurse), but try increasing the PlotPoints to specify how many initial sample points to use: Plot[IntImpTri[0, 4, r], {r, -1, 5}, PlotPoints -> 300] –  chuy Apr 30 '13 at 21:45
    
possible duplicate of Plot showing discontinuity where it shouldn't. Also a duplicate of mathematica.stackexchange.com/questions/19877/…. For more information, do a search. –  whuber Apr 30 '13 at 22:14

1 Answer 1

up vote 3 down vote accepted
Plot[IntImpTri[0, 4, r], {r, -1, 5}, Exclusions -> None]

enter image description here

The problem is usually caused by discontinuities in the derivatives

share|improve this answer

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