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:

Why is this happening if the function is continuous?
Thanks for your time.
Answer
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}]

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]

Comments
Post a Comment