---
title: The convolution sum
heading: How an LTI system turns its impulse response into any output
eyebrow: C9 · Lesson 6 · The convolution sum
xp: 50
---

::: hook
Tap a discrete-time LTI system with a single impulse and record what comes out: that sequence, h[n], is its **impulse response**. Remarkably, it tells you everything. Every input is a stack of scaled, shifted impulses, and an LTI system answers each one with a scaled, shifted copy of h[n], all added together. That sum is **convolution**, the single most important operation in signal processing: it's how filters, echoes, blurs and moving averages all work.
:::

::: play
- The input x[k] is a block of five 1s. The other stems are $h[n - k]$: the impulse response $h[k] = 0.8^k$ flipped around and slid to position n.
- The output y[n] is the sum of x[k] h[n − k] over k: wherever the two overlap, multiply and add. Slide n from −2 upward and watch the overlap grow, then shrink as the flipped response passes the block.
- The dashed curve is the whole output, and the dot is y[n] at the current n. It rises while the block feeds in and decays by 0.8 a step after.
:::
:::

```sim plot
view: graph
x: k = -4..16
y: v = -0.2..3.6
slider: n = -2..14 = 2 step 1
plot: 0.8^(k - (k + 4 - abs(k - 4))/2)*(1 - 0.8^((k + 4 - abs(k - 4))/2 + 1))/0.2*step(k + 0.5) | dashed | samples: 2000 | label: y
plot: step(k + 0.5) - step(k - 4.5) | stems | label: x[k]
plot: 0.8^(n - k)*step(n - k + 0.5) | stems | label: h[n − k]
point: n, 0.8^(n - (n + 4 - abs(n - 4))/2)*(1 - 0.8^((n + 4 - abs(n - 4))/2 + 1))/0.2*step(n + 0.5) | label: y[n]
readout: y[n] = 0.8^(n - (n + 4 - abs(n - 4))/2)*(1 - 0.8^((n + 4 - abs(n - 4))/2 + 1))/0.2*step(n + 0.5) | digits: 4
```

::: predict
## x = [1, 2, 3] (starting at n = 0) is convolved with h = [1, 1]. What is y[1]?

- [ ] 2
- [x] 3
- [ ] 5
- [ ] 6

::: reveal
3. $y[1] = x[0]h[1] + x[1]h[0] = 1 + 2$. The whole output is [1, 3, 5, 3]: each sample is the sum of two neighboring inputs, which is what h = [1, 1] does.
:::
:::

::: nameit
## From impulses to convolution

Any sequence is a sum of shifted impulses, $x[n] = \sum_k x[k]\,\delta[n - k]$. An LTI system answers $\delta[n - k]$ with $h[n - k]$ (time invariance) and scales and adds the answers (linearity), so

$$y[n] = \sum_{k=-\infty}^{\infty} x[k]\,h[n - k] = (x * h)[n]$$

**Recipe for one output sample:** flip h to get h[−k], slide it to h[n − k], multiply by x[k] point by point, and add.

## Properties

- **Commutative:** $x * h = h * x$, so either one can be flipped.
- **Associative:** $(x * h_1) * h_2 = x * (h_1 * h_2)$: two systems in cascade act like one with impulse response $h_1 * h_2$.
- **Distributive:** $x * (h_1 + h_2) = x * h_1 + x * h_2$: systems in parallel add.
- **Impulses:** $x * \delta = x$, and $x * \delta[n - n_0] = x[n - n_0]$, a delay.
- **Sums multiply:** $\sum y = (\sum x)(\sum h)$.
- **Lengths add:** sequences of L and M samples give $L + M - 1$.

Convolving finite sequences is the same arithmetic as multiplying polynomials: $(1 + 2z + 3z^2)(1 + z) = 1 + 3z + 5z^2 + 3z^3$ gives [1, 3, 5, 3].

The **step response** is the running sum of the impulse response, $s[n] = \sum_{k \le n} h[k]$.
:::

::: example
## Convolve [1, 2, 3] with [1, 1].

::: solution
1. **Slide and multiply.**
   $$\begin{aligned} y[0] &= 1\cdot 1 \\ &= 1 \\ y[1] &= 1\cdot 1 + 2\cdot 1 \\ &= 3 \\ y[2] &= 2 + 3 \\ &= 5 \\ y[3] &= 3 \end{aligned}$$
2. **Check the length.** y = [1, 3, 5, 3] has 3 + 2 − 1 = 4 samples.
3. **Check the sum.** Its sum, 12, is 6 × 2, the product of the input sums.

**Answer:** y = [1, 3, 5, 3].
:::
:::

::: example
## A block of five 1s goes into the system $h[n] = 0.8^n u[n]$. Find y[2] and y[7].

::: solution
1. **y[2].** At n = 2 the flipped response covers k = 0 to 2:
   $$\begin{aligned} y[2] &= 0.8^2 + 0.8 + 1 \\ &= 2.44 \end{aligned}$$
2. **y[7].** At n = 7 it covers the whole block:
   $$\begin{aligned} y[7] &= 0.8^3 + 0.8^4 \\ &\quad + \cdots + 0.8^7 \\ &= \frac{0.8^3(1 - 0.8^5)}{1 - 0.8} \\ &= 1.721 \end{aligned}$$

**Answer:** y[2] = 2.44 and y[7] = 1.721.
:::
:::

::: example
## Convolve [1, −1] with [1, 2, 3, 4].

::: solution
1. **Slide and multiply.**
   $$\begin{aligned} y[0] &= 1 \\ y[1] &= 2 - 1 \\ &= 1 \\ y[2] &= 3 - 2 \\ &= 1 \\ y[3] &= 4 - 3 \\ &= 1 \\ y[4] &= -4 \end{aligned}$$
2. **Read the result.** y = [1, 1, 1, 1, −4] is a first difference: it turns the ramp into a constant and then falls back at the end.
3. **Check.** Its length is 2 + 4 − 1 = 5, and its sum, 0, is the product of the sums, 0 × 10.

**Answer:** y = [1, 1, 1, 1, −4].
:::
:::

::: check
given: L = 5 | 32 | 100; M = 3 | 16 | 64
answer: L + M - 1
tolerance: 0

## A {L}-sample sequence is convolved with a {M}-sample impulse response. How many samples long is the output?

::: right
Right. L + M − 1 = {answer}.
:::

::: misses
- [L + M] The first output uses the first sample of each; count the overlaps, not the sum.
- [L*M] Lengths add, they don't multiply.
- [any] Not yet. L + M − 1.
:::
:::

::: check
kind: parts
given: a = 1 | 2; b = 3 | -1; c = 4 | 2; p = 2 | 1; q = 5 | -3

## x = [{a}, {b}, {c}] and h = [{p}, {q}], both starting at n = 0.

::: part
answer: a*p
tolerance: 0

### What is y[0]?

::: misses
- [any] Only x[0]h[0] overlaps.
:::
:::

::: part
answer: a*q + b*p
tolerance: 0

### What is y[1]?

::: misses
- [a*p + b*q] Pair x[k] with h[1 − k]: x[0] with h[1], x[1] with h[0].
- [any] Not yet. x[0]h[1] + x[1]h[0].
:::
:::

::: part
answer: c*q
tolerance: 0

### What is y[3]?

::: misses
- [any] Only x[2]h[1] overlaps.
:::
:::
:::

::: check
given: a = 0.5 | 0.8 | 0.9; n = 1 | 2 | 3
answer: (1 - a^(n + 1))/(1 - a)
tolerance: 0.5%

## A block of five 1s (n = 0 to 4) goes into $h[n] = (\given{a})^n u[n]$. What is y[{n}]?

::: right
Right. $1 + a + \cdots + a^n$ = {answer}.
:::

::: misses
- [a^n] Add up every overlapping term, not just one.
- [(1 - a^n)/(1 - a)] Count k = 0 to n: that's n + 1 terms.
- [any] Not yet. Sum $a^{n-k}$ for k = 0 to n.
:::
:::

::: check
given: n0 = 3 | 7 | 12; m = 2 | 5
answer: m + n0
tolerance: 0

## x[n] has its peak at n = {m}. Where is the peak of $x[n] * \delta[n - \given{n0}]$?

::: right
Right. Convolving with a shifted impulse delays the signal by {n0}.
:::

::: misses
- [m - n0] $\delta[n - n_0]$ is a delay, not an advance.
- [any] Not yet. $x * \delta[n - n_0] = x[n - n_0]$.
:::
:::

::: check
given: a = 0.5 | 0.75 | 0.9; n = 2 | 4 | 6
answer: (1 - a^(n + 1))/(1 - a)
tolerance: 0.5%

## What is the step response s[{n}] of the system $h[n] = (\given{a})^n u[n]$?

::: right
Right. The running sum $1 + a + \cdots + a^n$ = {answer}, heading for $1/(1 - a)$.
:::

::: misses
- [1/(1 - a)] That's the final value. At n = {n} the sum has only n + 1 terms.
- [any] Not yet. Sum h from 0 to n.
:::
:::

::: check
kind: parts
given: M = 4 | 5 | 8; C = 2 | 10

## An M-point moving average, $h[n] = 1/\given{M}$ for n = 0 to {M} − 1, is fed a step of height {C}.

::: part
answer: 2*C/M
tolerance: 0.5%

### What is the output at n = 1?

::: misses
- [C/M] At n = 1 two samples of the step are inside the window.
- [any] Not yet. (n + 1)C/M.
:::
:::

::: part
answer: C
tolerance: 0.5%

### What is the output once n ≥ {M} − 1?

::: misses
- [any] The window is full of {C}s.
:::
:::
:::

::: check
given: Sx = 3 | 10 | -2; Sh = 0.5 | 4
answer: Sx*Sh
tolerance: 0.5%

## A sequence whose samples add up to {Sx} is convolved with an impulse response whose samples add up to {Sh}. What do the output's samples add up to?

::: right
Right. Sums multiply: {answer}.
:::

::: misses
- [Sx + Sh] The sums multiply, as polynomials evaluated at 1 do.
- [any] Not yet. $(\sum x)(\sum h)$.
:::
:::

::: check
kind: parts
given: L1 = 3 | 5 | 8; L2 = 4 | 6; s1 = 2 | 5; s2 = -1 | 3

## A sequence of {L1} samples summing to {s1} is convolved with one of {L2} samples summing to {s2}.

::: part
answer: L1 + L2 - 1
tolerance: 0

### How long is the result?

::: misses
- [L1 + L2] The overlap starts with one sample in common.
- [any] $L_1 + L_2 - 1$.
:::
:::

::: part
answer: s1*s2
tolerance: 0

### What do its samples sum to?

::: misses
- [any] The sums multiply.
:::
:::
:::

::: check
kind: parts
given: a = 0.5 | 0.8 | -0.5; n = 2 | 4 | 9

## A step goes into $h[n] = a^n u[n]$ with a = {a}.

::: part
answer: (1 - a^(n + 1))/(1 - a)
tolerance: 0.5%

### What is y[{n}]?

::: misses
- [any] The sum of h from 0 to {n}.
:::
:::

::: part
answer: 1/(1 - a)
tolerance: 0.5%

### Where does it settle?

::: misses
- [any] The sum of all of h.
:::
:::
:::

::: explain
## Why is the output of an LTI system the convolution of its input with its impulse response?

::: model
Any input sequence can be written as a sum of impulses: one at each time k, scaled by x[k]. Time invariance says the impulse at time k produces the impulse response shifted to start at k, h[n − k]. Linearity says scaling that impulse by x[k] scales its response by x[k], and that the response to the whole sum is the sum of the individual responses. Adding up $x[k]h[n - k]$ over every k is exactly the convolution sum, so knowing h, the response to one impulse, determines the response to everything.
:::
:::

::: practice

::: check
given: L = 8 | 50; M = 4 | 21
answer: L + M - 1
tolerance: 0

## How long is the convolution of {L} and {M} samples?

::: misses
- [any] L + M − 1.
:::
:::

::: check
given: a = 1 | 3; b = 2 | -1; p = 1 | 4; q = 2 | 1
answer: a*q + b*p
tolerance: 0

## x = [{a}, {b}] and h = [{p}, {q}]. What is y[1]?

::: misses
- [any] x[0]h[1] + x[1]h[0].
:::
:::

::: check
given: a = 0.6 | 0.95; n = 2 | 9
answer: (1 - a^(n + 1))/(1 - a)
tolerance: 0.5%

## Step response of $h[n] = (\given{a})^n u[n]$ at n = {n}?

::: misses
- [any] The sum of h from 0 to n.
:::
:::
:::
