1
$\begingroup$

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}]

enter image description here

$\endgroup$
1
  • 3
    $\begingroup$ p1 = Plot[{f, Evaluate@c[f]}, {x, -2, 2}] $\endgroup$
    – Sumit
    Commented Oct 13, 2016 at 9:07

2 Answers 2

4
$\begingroup$
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}]
$\endgroup$
3
$\begingroup$

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}]

enter image description here

$\endgroup$

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