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 plotted the overlapping area of the UnitBox and the triangle function as:

Plot[Evaluate[
  Integrate[
       Piecewise[{{1, -0.5 <= x < 0.5}, {0, Not[-0.5 <= x < 0.5]}}] 
       Piecewise[{{x + 1 - a, -1 + a <= x <= 0 + a}, {-x + 1 + a, 0 + a <= x <= 1 + a}}],
   {x, -Infinity, +Infinity}]], 
{a, -2, 2}, PlotRange -> All]

However, the result has gaps as you can see in the plot:

enter image description here

Why is this happening if the function is continuous?

Thanks for your time.

share|improve this question

marked as duplicate by Mr.Wizard Feb 21 '13 at 10:47

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.

4  
You can use Exclusions-None. –  b.gatessucks Feb 20 '13 at 12:01
    
Possible duplicate: mathematica.stackexchange.com/q/4797/12 –  Szabolcs Feb 20 '13 at 17:49
1  
    
Thanks for the replies. However I knew that Exclusions->None solved the problem. I wanted to know the reason for those "exclusions" and Belisarius gave it to me. –  José Antonio Díaz Navas Feb 26 '13 at 18:50

1 Answer 1

up vote 7 down vote accepted

Plot[] is excluding the discontinuities in the second derivative:

f[x_, a_] := Integrate[
                Piecewise[{{1, -0.5 <= x < 0.5}, {0, Not[-0.5 <= x < 0.5]}}] 
                Piecewise[{{x + 1 - a, -1 + a <= x <= 0 + a}, {-x + 1 + a, 0 + a <= x <= 1 + a}}],
             {x, -Infinity, +Infinity}]

Plot[Evaluate[D[f[x, a], a]], {a, -2, 2}]

Mathematica graphics

As @b,gatessucks mentioned in a comment, using Exclusions->None solves the issue:

Plot[Evaluate[f[x, a]], {a, -2, 2}, PlotRange -> All, Exclusions -> None]

Mathematica graphics

share|improve this answer
    
Thanks a lot!! This is the answer I was looking for. I knew that I could "fill the gaps" with "Exclusions" Option. However, I wanted to know the reason. –  José Antonio Díaz Navas Feb 26 '13 at 18:49

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