Understanding the convolution calculator — concept and principle
This calculator computes the discrete convolution of two finite sequences, such as a signal and a filter kernel. It gives the full output sequence, its length, the largest value and where it occurs, and the first few terms worked out. Use it for signal-processing homework, smoothing data, or multiplying polynomials through their coefficients.
How it is calculated
y[n] = Σₖ x[k] · h[n − k], summed over every k where both terms exist
Output length = N + M − 1, for n = 0 … N + M − 2
- N is the length of x and M the length of h; both start at index 0.
- Check: sum(y) = sum(x) × sum(h).
- Convolution is commutative: swapping x and h gives the same y.
The principle
Think of h as the response of a system to a single unit pulse. A signal is a sum of scaled, shifted pulses, and for a linear, time-invariant system the output is the same sum of scaled, shifted responses. Writing that sum out gives the convolution formula. In practice you reverse the kernel, slide it along the signal and, at each position, multiply overlapping values and add them. The same arithmetic multiplies polynomials: the coefficients of (1 + 2t + 3t² + 4t³)(0.5 + t + 0.5t²) are exactly this convolution.
Worked example
Default inputs: x = 1, 2, 3, 4 and h = 0.5, 1, 0.5.
- Lengths 4, 3, so the output has 4 + 3 − 1 = 6 values.
- y[0] = 1·0.5 = 0.5; y[1] = 1·1 + 2·0.5 = 2; y[2] = 1·0.5 + 2·1 + 3·0.5 = 4.
- y[3] = 2·0.5 + 3·1 + 4·0.5 = 6; y[4] = 3·0.5 + 4·1 = 5.5; y[5] = 4·0.5 = 2.
- Result y = 0.5, 2, 4, 6, 5.5, 2; largest value 6 at position 3.
- Check: sum(y) = 20 and sum(x) × sum(h) = 10 × 2 = 20.
How to read the result
A kernel like 0.5, 1, 0.5 is a smoothing filter: each output blends a value with its neighbours. Because its weights add to 2, it also doubles the overall level; dividing the kernel by its sum keeps the level the same. The extra values at the start and end are where the kernel only partly overlaps the signal; filters often trim or pad these edges.
Common mistakes
- Forgetting to reverse the kernel, which gives correlation instead of convolution.
- Expecting the output to have the same length as the input.
- Starting the indices at 1 instead of 0.
- Ignoring the edge values when comparing with a filtered signal of the same length.
Frequently asked questions
What is discrete convolution?
A sum of products y[n] = Σ x[k] h[n − k], sliding a reversed kernel across a signal.
How long is the result of a convolution?
N + M − 1 values for sequences of lengths N and M.
How is convolution related to polynomial multiplication?
The coefficients of a product of two polynomials are the convolution of their coefficient lists.
Sources: S. W. Smith, The Scientist and Engineer's Guide to Digital Signal Processing, Ch. 6 "Convolution"