Skip to content

Convolution, explained

5 min read

Short answer

The convolution (f∗g)(t)=∫f(τ) g(t−τ) dτ(f*g)(t)=\int f(\tau)\,g(t-\tau)\,d\tau (or ∑kfkgn−k\sum_k f_kg_{n-k} for sequences) flips one function, slides it across the other and accumulates the overlap. It models filtering, blurring and the response of a linear system. Under the Fourier transform it becomes ordinary multiplication.

Steps1Flip g to get g(−τ)2Shift it by t to get g(t − τ)3Multiply with f(τ) point by point4Integrate (or add) theproducts: that is (f ∗ g)(t)5Repeat for each tConvolution is commutative, associative and linear.
A moving, flipped window computes a weighted sum at each position.

Why it appears

If a system is linear and time-invariant, its output is the input convolved with its impulse response. Each instant of the input contributes a scaled, delayed copy of the impulse response, and the output is their sum.

Convolution theorem

f∗g^=f^⋅g^\widehat{f*g}=\hat f\cdot\hat g. Instead of an integral for each tt, multiply the spectra and transform back. This is why fast filtering and fast multiplication of big numbers use the FFT.

Worked example

Convolve the sequences [1,2,3][1,2,3] and [0,1,0.5][0,1,0.5].

The result has length 3+3−1=53+3-1=5: c0=1⋅0=0c_0=1\cdot0=0; c1=1⋅1+2⋅0=1c_1=1\cdot1+2\cdot0=1; c2=1⋅0.5+2⋅1+3⋅0=2.5c_2=1\cdot0.5+2\cdot1+3\cdot0=2.5; c3=2⋅0.5+3⋅1=4c_3=2\cdot0.5+3\cdot1=4; c4=3⋅0.5=1.5c_4=3\cdot0.5=1.5. So the result is [0, 1, 2.5, 4, 1.5][0,\,1,\,2.5,\,4,\,1.5].

Try it yourself

What is the length of the convolution of sequences with lengths mm and nn?

Show the answer

The result has length m+n−1m+n-1, because the first and last overlap positions each contribute one term.

Keep going with practice

Vidi's probability lessons use convolution for the distribution of a sum of independent variables.