TExcelTAD
Home › Differential Equations › Convolution

Convolution

The Laplace transform of a product is not the product of the transforms. But the product of two transforms is the transform of something useful: the convolution

(f∗g)(t)=∫0tf(τ) g(t−τ) dτ.(f * g)(t) = \int_0^t f(\tau)\,g(t - \tau)\,d\tau.

The convolution theorem

L{f∗g}=F(s) G(s).\mathcal{L}\{f * g\} = F(s)\,G(s).

So whenever Y(s)Y(s) is a product F(s)G(s)F(s)G(s) of two known transforms, y=f∗gy = f * g. Convolution is commutative (f∗g=g∗ff * g = g * f), associative and linear in each argument.

Example. L−1{1s2(s+1)}\mathcal{L}^{-1}\left\{\frac{1}{s^2(s + 1)}\right\} with F=1s2↔tF = \frac{1}{s^2} \leftrightarrow t and G=1s+1↔e−tG = \frac{1}{s + 1} \leftrightarrow e^{-t}:

(t∗e−t)=∫0tτ e−(t−τ) dτ=t−1+e−t.(t * e^{-t}) = \int_0^t \tau\,e^{-(t - \tau)}\,d\tau = t - 1 + e^{-t}.
python · try it yourself
import sympy as sp

t, tau, s = sp.symbols("t tau s", positive=True)
conv = sp.integrate(tau * sp.exp(-(t - tau)), (tau, 0, t))
print("t * e^-t =", sp.simplify(conv))
print("inverse transform:", sp.inverse_laplace_transform(1 / (s**2 * (s + 1)), s, t))
t * e^-t = t - 1 + exp(-t)
inverse transform: t - 1 + exp(-t)

Response to any input

For ay′′+by′+cy=f(t)ay'' + by' + cy = f(t) with zero initial conditions, transforming gives

Y(s)=1as2+bs+c F(s)=H(s) F(s).Y(s) = \frac{1}{as^2 + bs + c}\,F(s) = H(s)\,F(s).

H(s)H(s) is the transfer function. Its inverse h(t)h(t) is the impulse response (see The Dirac Delta), and by the convolution theorem

y(t)=∫0th(τ) f(t−τ) dτ.y(t) = \int_0^t h(\tau)\,f(t - \tau)\,d\tau.

The output is a weighted average of past inputs, with weights given by hh. This is the same formula as the Green's function, now derived in one line.

Numerically: discrete convolution

Sampled on a grid with spacing Δt\Delta t, the integral becomes a sum, which np.convolve computes. For y′′+y=fy'' + y = f we have h(t)=sin⁡th(t) = \sin t:

python · try it yourself
import numpy as np
from scipy.integrate import solve_ivp

dt = 0.001
t = np.arange(0, 10, dt)
f = np.where(t < 3, t, 0.0)                     # a ramp that stops at t = 3
h = np.sin(t)
y_conv = np.convolve(h, f)[: len(t)] * dt        # Riemann sum of the convolution integral

ff = lambda tt: tt if tt < 3 else 0.0
sol = solve_ivp(lambda tt, Y: [Y[1], ff(tt) - Y[0]], (0, 10), [0, 0], t_eval=[2.0, 5.0, 9.0], max_step=0.01, rtol=1e-10)
for tv, yv in zip(sol.t, sol.y[0]):
    print(f"t = {tv}: convolution {y_conv[int(round(tv / dt))]: .4f}, ODE solver {yv: .4f}")
t = 2.0: convolution  1.0907, ODE solver  1.0907
t = 5.0: convolution  0.6184, ODE solver  0.6197
t = 9.0: convolution  2.1894, ODE solver  2.1890

The small differences come from the Riemann-sum approximation; they shrink with Δt\Delta t.

Volterra integral equations

Convolution also solves integral equations like

y(t)=t+∫0tsin⁡(t−τ) y(τ) dτ.y(t) = t + \int_0^t \sin(t - \tau)\,y(\tau)\,d\tau.

Transforming: Y=1s2+1s2+1YY = \frac{1}{s^2} + \frac{1}{s^2 + 1}Y, so Y=1s2⋅s2+1s2=1s2+1s4Y = \frac{1}{s^2}\cdot\frac{s^2 + 1}{s^2} = \frac{1}{s^2} + \frac{1}{s^4} and y=t+t36y = t + \frac{t^3}{6}.

In software

  • Convolution is everywhere in signal processing: audio effects (reverb with a measured impulse response), image blurs and sharpening, and the convolutional layers of neural networks (which actually compute cross-correlations, the same idea without flipping).
  • Large convolutions are computed with the FFT: the convolution theorem for Fourier transforms is the same trick as here (Fourier Analysis & Signals).

Exercises

Exercise 1: A convolution by hand

Compute 1∗11 * 1 and 1∗t1 * t.

Answer

1∗1=t1 * 1 = t and 1∗t=t221 * t = \frac{t^2}{2}.

Solution

∫0t1 dτ=t\int_0^t 1\,d\tau = t and ∫0t(t−τ) dτ=t22\int_0^t (t - \tau)\,d\tau = \frac{t^2}{2}. Check with transforms: 1s⋅1s=1s2\frac{1}{s}\cdot\frac{1}{s} = \frac{1}{s^2} and 1s⋅1s2=1s3\frac{1}{s}\cdot\frac{1}{s^2} = \frac{1}{s^3}.

Exercise 2: Inverse by convolution

Find L−1{1(s2+1)2}\mathcal{L}^{-1}\left\{\frac{1}{(s^2 + 1)^2}\right\} as sin⁡t∗sin⁡t\sin t * \sin t.

Answer

12(sin⁡t−tcos⁡t)\frac{1}{2}(\sin t - t\cos t).

Solution

∫0tsin⁡τsin⁡(t−τ) dτ=12∫0t(cos⁡(2τ−t)−cos⁡t) dτ=12sin⁡t−12tcos⁡t\int_0^t \sin\tau\sin(t - \tau)\,d\tau = \frac{1}{2}\int_0^t \big(\cos(2\tau - t) - \cos t\big)\,d\tau = \frac{1}{2}\sin t - \frac{1}{2}t\cos t.

Exercise 3: Integral equation (code)

Solve y(t)=1+∫0ty(τ) dτy(t) = 1 + \int_0^t y(\tau)\,d\tau with the Laplace transform and check with SymPy.

Answer

y=ety = e^t.

Solution

The integral is 1∗y1 * y, so Y=1s+1sYY = \frac{1}{s} + \frac{1}{s}Y and Y=1s−1Y = \frac{1}{s - 1}.

python · try it yourself
import sympy as sp
s, t = sp.symbols("s t", positive=True); Y = sp.symbols("Y")
Ys = sp.solve(sp.Eq(Y, 1 / s + Y / s), Y)[0]
print(Ys, "->", sp.inverse_laplace_transform(Ys, s, t))
1/(s - 1) -> exp(t)

Test yourself

The convolution theorem states $\mathcal{L}\{f * g\} = $…

  1. F+GF + G
  2. F(s)G(s)F(s)G(s)
  3. F(G(s))F(G(s))
  4. F′GF'G

For zero initial conditions, the output of a linear system is…

  1. the input times the transfer function in the time domain
  2. the convolution of the impulse response with the input
  3. always zero
  4. the derivative of the input

(f∗g)(t)(f * g)(t) for f=g=1f = g = 1 is…

  1. 1
  2. tt
  3. t2t^2
  4. 0