# Mathematica plots a discontinuity in piecewise function that does not exist [duplicate]

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:

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

-

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

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
Plot[IntImpTri[0, 4, r], {r, -1, 5}, Exclusions -> None]