1

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

Kay
  • 1,035
  • 7
  • 19

2 Answers2

4
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}]
Sumit
  • 15,912
  • 2
  • 31
  • 73
3

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

ubpdqn
  • 60,617
  • 3
  • 59
  • 148