Convolution Calculator: Discrete and Circular Convolution Step by Step
By FindMySum · Last reviewed
A convolution calculator combines two sequences into one by sliding one across the other and adding up products. Discrete convolution is the basic operation of signal processing, and it also describes polynomial multiplication, moving averages and sums of random variables. This page computes the full, same and valid convolutions (with NumPy's conventions), circular convolution of any period, and deconvolution, and lists every flip-and-slide sum so you can follow the working. Enter each sequence as numbers separated by commas; fractions and decimals are handled exactly.
The definition
For two finite sequences f (length M) and g (length N), both starting at index 0:
(f ∗ g)[n] = Σₖ f[k] · g[n − k], for n = 0, 1, …, M + N − 2.
Each output value multiplies f by a reversed, shifted copy of g and adds the products where both are defined.
Worked example: the default
f = [1, 2, 3] and g = [0, 1, 0.5]. Flip g to get [0.5, 1, 0] and slide it along f:
| n | Products | Value |
|---|---|---|
| 0 | f[0]·g[0] = 1·0 | 0 |
| 1 | f[0]·g[1] + f[1]·g[0] = 1·1 + 2·0 | 1 |
| 2 | f[0]·g[2] + f[1]·g[1] + f[2]·g[0] = 0.5 + 2 + 0 | 2.5 |
| 3 | f[1]·g[2] + f[2]·g[1] = 1 + 3 | 4 |
| 4 | f[2]·g[2] = 1.5 | 1.5 |
So f ∗ g = [0, 1, 2.5, 4, 1.5]. A quick check: the sum of the result (9) equals the sum of f (6) times the sum of g (1.5).
Convolution as polynomial multiplication
Write each sequence as the coefficients of a polynomial, lowest power first: f(x) = 1 + 2x + 3x² and g(x) = x + 0.5x². Their product is
(1 + 2x + 3x²)(x + 0.5x²) = x + 2.5x² + 4x³ + 1.5x⁴,
and its coefficients, [0, 1, 2.5, 4, 1.5], are the convolution. This is why the FOIL method, long multiplication and convolution are the same calculation.
Full, same and valid
Different tools return different parts of the full result:
- Full (the default): all M + N − 1 values.
- Same: max(M, N) values from the centre of the full result. NumPy starts at index ⌊(min(M, N) − 1)/2⌋; for the default that is index 1, giving [1, 2.5, 4].
- Valid: only values where the shorter sequence lies completely inside the longer one, max(M, N) − min(M, N) + 1 values; here just [2.5].
"Same" keeps a filtered signal aligned with the original, and "valid" avoids edge effects from the implicit zero padding.
Circular convolution
With a period L, indices wrap around: y[n] = Σₖ f[k]·g[(n − k) mod L]. Equivalently, compute the full convolution and fold it: add every value at index n + L, n + 2L, … back onto index n. For the default with L = 3, the full result [0, 1, 2.5, 4, 1.5] folds to [0 + 4, 1 + 1.5, 2.5] = [4, 2.5, 2.5].
Circular convolution is what you get by multiplying discrete Fourier transforms. If L is at least M + N − 1 (here 5), nothing wraps, and circular and linear convolution agree, which is how fast FFT convolution works.
Deconvolution
If y = f ∗ g and you know g, you can recover f by dividing polynomials. Enter y as the first sequence and choose "Deconvolve". Dividing [0, 1, 2.5, 4, 1.5] by [0, 1, 0.5] gives [1, 2, 3] with remainder 0. A non-zero remainder means y is not an exact convolution of anything with g. With noisy measurements exact division is unstable, which is why practical deconvolution (in image deblurring, for example) uses regularised methods.
Useful kernels
- [1]: the identity; f ∗ [1] = f.
- [1, −1]: the first difference, f[n] − f[n − 1]. Convolving [1, 2, 3, 4, 5] with it gives [1, 1, 1, 1, 1, −5].
- [1/3, 1/3, 1/3]: a three-point moving average.
- [1, 2, 1]/4: a gentle smoothing (binomial) filter.
Properties worth knowing
- Commutative: f ∗ g = g ∗ f.
- Associative: (f ∗ g) ∗ h = f ∗ (g ∗ h), so a chain of filters is one combined filter.
- Distributive over addition: f ∗ (g + h) = f ∗ g + f ∗ h.
- Sum rule: the sum of f ∗ g is the sum of f times the sum of g.
More questions
Where is convolution used?
Everywhere signals are filtered or blurred. Audio effects such as reverb convolve sound with a room's impulse response; image blur and edge detection convolve pixels with a small kernel; moving averages in finance and statistics are convolutions; and probability uses convolution to find the distribution of a sum of independent random variables, such as the total of two dice.
How does convolution relate to the Fourier transform?
The convolution theorem says that convolution in time is multiplication in frequency: the DFT of f ⊛ g (circular) is the product of the DFTs of f and g. That is why long convolutions are computed with the FFT, padding both sequences to at least M + N − 1 values so the circular result equals the linear one.
What is the difference between convolution and correlation?
Correlation slides g across f without flipping it: (f ⋆ g)[n] = Σ f[k]·g[k + n]. It measures similarity at each shift and is used to find a known pattern in a signal. Convolution flips g first. For a symmetric kernel the two give the same result.
What do 'same' and 'valid' mean in NumPy and MATLAB?
They choose which part of the full result to keep. NumPy's convolve and MATLAB's conv both default to the full result; 'same' keeps a centred slice as long as the longer input, and 'valid' keeps only the outputs computed without zero padding. The calculator follows NumPy's centring rule.
Can convolution be done with fractions?
Yes. The calculator uses exact rational arithmetic, so a kernel such as [1/3, 1/3, 1/3] gives exact thirds rather than 0.333333. That matters when checking deconvolution, where a rounding error would otherwise leave a tiny false remainder.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.