I have the following function defined:

IntImpTri[r1_, r2_, r_] := 
    {((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!

  • $\begingroup$ I am using Mathematica under Unix... $\endgroup$ – Andry Apr 30 '13 at 21:40
  • $\begingroup$ 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] $\endgroup$ – chuy Apr 30 '13 at 21:45
  • $\begingroup$ 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. $\endgroup$ – whuber Apr 30 '13 at 22:14
Plot[IntImpTri[0, 4, r], {r, -1, 5}, Exclusions -> None]

enter image description here

The problem is usually caused by discontinuities in the derivatives


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