# How to plot a function? [closed]

Let's assume a box-function and a convolution:

f = UnitBox[x];
c[t_] := Convolve[t, t, x, y] /. y -> x;
c[f]


My problem arises when plotting the functions. Why does the code p2 work and the code p1 not? Where is the difference?

p1 = Plot[{f, c[f]}, {x, -2, 2}]
p2 = Plot[{f, UnitTriangle[x]}, {x, -2, 2}]


• p1 = Plot[{f, Evaluate@c[f]}, {x, -2, 2}] Commented Oct 13, 2016 at 9:07

f = UnitBox[x];
c[t_] := Convolve[t, t, x, y] /. y -> x;
p1 = Plot[{f, Evaluate@c[f]}, {x, -2, 2}]
p2 = Plot[{f, UnitTriangle[x]}, {x, -2, 2}]


Just for fun (as Sumit has answered question). Also search site for questions and posts such as this.

f = UnitBox[x];
c[t_] := Convolve[t, t, x, y] /. y -> x;
c[f];
cn[t_] := Integrate[f UnitBox[t - x], {x, -Infinity, Infinity}];

Animate[Plot[{f, c[f], UnitBox[x - p]}, {x, -2, 2},
Filling -> {3 -> {Axis, LightRed}, 1 -> {3}},
Evaluated -> True,
Epilog -> {Red, PointSize[0.02], Point[{p, cn[p]}]},
Exclusions -> None], {p, -2, 2}]