Convolution

Author

Eric W. Weisstein
August 18, 2008

This notebook downloaded from http://mathworld.wolfram.com/notebooks/IntegralTransforms/Convolution.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Convolution.html.

©2008 Wolfram Research, Inc. except for portions noted otherwise

Code

MyConvolve[f_,g_,t_]:=Integrate[Function[t,f][τ]Function[t,g][t-τ],{τ,-∞,∞},GenerateConditions->False]
RectanglePi[x_]:=UnitStep[x+1/2]-UnitStep[x-1/2]
RectanglePi[x_,{a_,b_}]:=UnitStep[x-a]-UnitStep[x-b]

Identities

Convolve[f(x),g(x),x,t]==Convolve[g(x),f(x),x,t]

Convolve[f[x],g[x],x,t]-Convolve[g[x],f[x],x,t]

FullSimplify[%]

Animations

<<Utilities`GIF`

Rectangle

Convolve[.75RectanglePi[t],RectanglePi[t,{-1/4,1/4}]/2,t]

movie=With[
{h=Convolve[RectanglePi[t],.5RectanglePi[t,{-1/4,1/4}],t]},
Table[Show[
{
Plot[.5RectanglePi[t]RectanglePi[t-τ,{-1/4,1/4}],{t,-5,5},PlotPoints->100,ClippingStyle->False,Filling->Axis],
Plot[
{
RectanglePi[t],
.5RectanglePi[t-τ,{-1/4,1/4}],
h
},
{t,-2,2},
PlotStyle->{Red,Blue,Green},
ClippingStyle->False,
Exclusions->False
],
Graphics[{Green,Line[{{τ,-1},{τ,1}}],
{Red,Text[f,{0,.85},Background->White]},
{Blue,Text[g,{τ,.6},Background->White]}
}]
},
AxesLabel->{t,Star[f,g]},
Method->{"AxesInFront"->False},
PlotRange->{{-2,2},{-.1,1}}],
{τ,-2,2,.05}
]];

ListAnimate[movie]

GraphicsGrid[Partition[Take[movie,{1,-1,10}],3],Spacings->{-40,10},ImageSize->400]

Animated GIF

Export[$GIFDirectory<>"convrect.gif",movie,"Interlaced"->True,"TransparentColor"->GrayLevel[1],AnimationRepetitions->∞,"DisplayDurations"->0.1]//Timing

Gaussian

movie=With[
{h=Convolve[Exp[-5t^2],Exp[-10t^2]/2,t]},
Table[Show[
{
Plot[Exp[-5t^2]Exp[-10(t-τ)^2]/2,{t,-5,5},PlotPoints->100,Filling->Axis,ClippingStyle->False],
Plot[
{
Exp[-5t^2],
Exp[-10(t-τ)^2]/2,
h
},
{t,-2,2},
ClippingStyle->False,
PlotStyle->{Red,Blue,Green}
],
Graphics[{Green,Line[{{τ,-1},{τ,1}}],
{Red,Text[f,{0,1.1},Background->White]},
{Blue,Text[g,{τ,.6},Background->White]}
}]
},
AxesLabel->{t,Star[f,g]},
Method->{"AxesInFront"->False},
PlotRange->{{-2,2},{-.1,1.1}}],{τ,-2,2,.05}
]];

ListAnimate[movie]

GraphicsGrid[Partition[Take[movie,{1,-1,10}],3],Spacings->{-40,10},ImageSize->400]

Animated GIF

Export[$GIFDirectory<>"convgaus.gif",movie,"Interlaced"->True,"TransparentColor"->GrayLevel[1],AnimationRepetitions->∞,"DisplayDurations"->0.1]//Timing

Analytic Cases

Rectangle

V6

Convolve[a RectanglePi[t,{t1,t2}],b RectanglePi[t,{u1,u2}],t]

Convolve[a RectanglePi[t,{t1,t2}],b RectanglePi[t,{u1,u2}],t]%

V7

Plot[UnitBox[(x-2)/1],{x,-2,5}]

RectanglePi[t_,{t1_,t2_}]:=UnitBox[(t-Mean[{t1,t2}])/(t2-t1)]

Plot[RectanglePi[t,{3/2,5/2}],{t,-2,5}]

TimeConstrained[Convolve[a RectanglePi[t,{t1,t2}],b RectanglePi[t,{u1,u2}],t,x],60]//Timing

TimeConstrained[Convolve[a RectanglePi[t,{t1,t2}],b RectanglePi[t,{u1,u2}],t,x,Assumptions->(a|b|t1|t2|u1|u2)∈Reals],60]//Timing

V7

Gaussian

V6

Convolve[a Exp[-(t-(Subscript[μ, 1]))^2/(2(Subscript[σ, 1])^2)]/(Subscript[σ, 1])/Sqrt[2π],b Exp[-(t-(Subscript[μ, 2]))^2/(2(Subscript[σ, 2])^2)]/(Subscript[σ, 2])/Sqrt[2π],t]

FullSimplify[%,(Subscript[σ, 1])>0&&(Subscript[σ, 2])>0]

FullSimplify[ (Sqrt[((1/(Subscript[σ, 1]^2))+(1/(Subscript[σ, 2]^2)))(Subscript[σ, 1])^2(Subscript[σ, 2])^2])]

((e^(-((((t-((Subscript[μ, 1])+(Subscript[μ, 2]))))^2)/(2 ((Subscript[σ, 1]^2)+(Subscript[σ, 2]^2))))))/(Sqrt[2 π ((Subscript[σ, 1]^2)+(Subscript[σ, 2]^2))]))

V7

Convolve[a Exp[-(t-(Subscript[μ, 1]))^2/(2(Subscript[σ, 1])^2)]/(Subscript[σ, 1])/Sqrt[2π],b Exp[-(t-(Subscript[μ, 2]))^2/(2(Subscript[σ, 2])^2)]/(Subscript[σ, 2])/Sqrt[2π],t,x]