Skip to content

Convolution Calculator

Convolve two sequences step by step: full, same and valid discrete convolution (NumPy conventions), circular convolution, deconvolution and the polynomial view.

Calculator Details

f ∗ g:[0, 1, 2.5, 4, 1.5]See results ↓

Numbers separated by commas or spaces, from n = 0; fractions like 1/3 allowed

Numbers separated by commas or spaces, from n = 0

Full, same or valid length (NumPy conventions), circular, or deconvolution (y ÷ g)

Your Results

f ∗ g: [0, 1, 2.5, 4, 1.5]

f ∗ g

[0, 1, 2.5, 4, 1.5]

5 values, full output

Sum of the result

9

Equals sum(f) × sum(g) for full and circular output

Lengths

3 and 3

f and g

The full convolution of [1, 2, 3] and [0, 1, 0.5] is [0, 1, 2.5, 4, 1.5] (5 values).

Compare scenarios

Save these inputs as a scenario, change them, and compare the results side by side.

Loading, available in a moment

Sequences by index n

Sequences by index n

Detailed Breakdown

Flip and slide: each output value
nΣ f[k]·g[n − k]Value
0f[0]·g[0] = 1·00
1f[0]·g[1] = 1·1 + f[1]·g[0] = 2·01
2f[0]·g[2] = 1·0.5 + f[1]·g[1] = 2·1 + f[2]·g[0] = 3·02.5
3f[1]·g[2] = 2·0.5 + f[2]·g[1] = 3·14
4f[2]·g[2] = 3·0.51.5

How This Calculator Works

How it's calculated

(f ∗ g)[n] = Σₖ f[k]·g[n − k]

circular: y[n] = Σₖ f[k]·g[(n − k) mod L]

Your sequences: f = [1, 2, 3] and g = [0, 1, 0.5]. Flip g, slide it along f, and add the products where they overlap: n = 0: f[0]·g[0] = 1·0 = 0; n = 1: f[0]·g[1] = 1·1 + f[1]·g[0] = 2·0 = 1; n = 2: f[0]·g[2] = 1·0.5 + f[1]·g[1] = 2·1 + f[2]·g[0] = 3·0 = 2.5; …. The result is [0, 1, 2.5, 4, 1.5]. The same numbers are the coefficients of a polynomial product: (3x² + 2x + 1)(0.5x² + x) = 1.5x⁴ + 4x³ + 2.5x² + x.

Frequently Asked Questions

What is discrete convolution?

An operation that combines two sequences into a third: (f ∗ g)[n] = Σ f[k]·g[n − k]. Each output value is a weighted sum of f, with the weights taken from g reversed and shifted by n. It describes how a linear, time-invariant system with impulse response g responds to the input f.

How do you compute a convolution by hand?

Flip g, slide it along f one step at a time, and at each position multiply the overlapping values and add them. For f = [1, 2, 3] and g = [0, 1, 0.5]: n = 0 gives 1·0 = 0; n = 1 gives 1·1 + 2·0 = 1; n = 2 gives 1·0.5 + 2·1 + 3·0 = 2.5; then 4 and 1.5. The result is [0, 1, 2.5, 4, 1.5].

How long is the result?

Full convolution of sequences of lengths M and N has M + N − 1 values. NumPy’s “same” mode keeps the length of the longer input, centred on the full result, and “valid” keeps only the max(M, N) − min(M, N) + 1 values where one sequence overlaps the other completely.

Why is convolution the same as multiplying polynomials?

Collecting the terms of a product (Σ fₖxᵏ)(Σ gⱼxʲ) gives the coefficient of xⁿ as Σ fₖgₙ₋ₖ, which is exactly the convolution sum. So [1, 2, 3] ∗ [0, 1, 0.5] is the coefficient list of (1 + 2x + 3x²)(x + 0.5x²). Long multiplication of whole numbers is convolution of their digits, before carrying.

What is circular convolution?

Convolution where indices wrap around a period L: y[n] = Σ f[k]·g[(n − k) mod L]. It is what multiplying discrete Fourier transforms (FFTs) of length L computes. Circular convolution equals linear convolution when L ≥ M + N − 1; with a shorter period, the tail wraps onto the start (time-domain aliasing).

What is deconvolution?

Undoing a convolution: given y = f ∗ g and g, recover f. For exact finite sequences it is polynomial division of y by g. If the remainder is zero, y really was f ∗ g; a non-zero remainder means no finite f gives y exactly. Real measured signals have noise, so practical deconvolution uses regularised methods instead.

Is convolution commutative?

Yes: f ∗ g = g ∗ f. It is also associative and distributes over addition, and convolving with [1] (the unit impulse) leaves a sequence unchanged. Convolving with [1, −1] gives the first difference, and with [1/3, 1/3, 1/3] a three-point moving average.

Included: discrete linear convolution of two finite sequences of up to 64 values each, with NumPy’s full, same and valid output lengths, circular convolution of any period, deconvolution by exact polynomial division, and every flip-and-slide sum (Oppenheim and Schafer, Discrete-Time Signal Processing, ch. 2). Arithmetic is exact, so fractions and decimals give exact results. Left out: continuous convolution integrals, two-dimensional (image) convolution, sequences that start at a negative index, cross-correlation, and FFT-based fast convolution for long signals.

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:

nProductsValue
0f[0]·g[0] = 1·00
1f[0]·g[1] + f[1]·g[0] = 1·1 + 2·01
2f[0]·g[2] + f[1]·g[1] + f[2]·g[0] = 0.5 + 2 + 02.5
3f[1]·g[2] + f[2]·g[1] = 1 + 34
4f[2]·g[2] = 1.51.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.

Spotted a wrong result or a bug? Report a problem

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy