Convolution Calculator

Enter two sequences of numbers to find their discrete convolution a ∗ b, with the working for every term.

Updated

Enter to calculate Esc to clear

Convolution Calculator

Our Convolution Calculator finds the discrete convolution a ∗ b of two sequences of numbers. Type the terms of each sequence, separated by spaces or commas, and the result appears straight away with every term worked out exactly, so 0.1 × 0.2 gives 0.02 and not a long rounding error. It also shows the work for each term, the same result written as a polynomial, and a quick check that the answer is right.

Quick answer

The convolution of two sequences a and b is a new sequence c whose kth term adds up a[i] × b[k − i] for every pair of positions that add to k. For example, [1, 2, 3] ∗ [0, 1, 0.5] = [0, 1, 2.5, 4, 1.5]. Enter any two sequences above and the calculator shows the result instantly.

  • Formula: c[k] = Σ a[i] × b[k − i]
  • Length: m terms ∗ n terms gives m + n − 1 terms
  • Same as: multiplying polynomials, where the sequences are the coefficients
  • Check: sum of a ∗ b = (sum of a) × (sum of b)

What Is Convolution?

Convolution combines two sequences into a third. Every term of the first sequence is multiplied by every term of the second, and each product lands in the position given by adding their two positions. Products that land in the same position are added together.

It is one of the most used operations in applied maths. A filter on an audio signal, a blur on a photo, the total of two dice and the product of two polynomials are all convolutions. This calculator works out discrete convolution, the kind for lists of numbers; the continuous version replaces the sum with an integral, (f ∗ g)(t) = ∫ f(τ) g(t − τ) dτ.

The Convolution Formula

For a = [a₀, a₁, …, am−1] and b = [b₀, b₁, …, bn−1], the convolution c = a ∗ b is:

c[k] = Σ a[i] × b[k − i]

k = 0, 1, …, m + n − 2

The sum only uses positions where both terms exist, that is 0 ≤ i < m and 0 ≤ k − i < n. The first term is c[0] = a₀ × b₀ and the last is c[m + n − 2] = am−1 × bn−1, so the result always has m + n − 1 terms.

The Flip and Slide Method

To work out a convolution by hand, reverse b, slide it along a one step at a time, and at each step multiply the terms that line up and add them. For a = [1, 2, 3] and b = [0, 1, 0.5], the step for c[2] looks like this:

a 1 2 3
b flipped 0.5 1 0
products 0.5 + 2 + 0 = 2.5

Doing this for every position gives the whole result:

TermProducts that line upValue
c[0]1×00
c[1]1×1 + 2×01
c[2]1×0.5 + 2×1 + 3×02.5
c[3]2×0.5 + 3×14
c[4]3×0.51.5

So [1, 2, 3] ∗ [0, 1, 0.5] = [0, 1, 2.5, 4, 1.5], five terms from two three-term sequences.

Convolution as Polynomial Multiplication

Read each sequence as the coefficients of a polynomial, lowest power first. Multiplying the polynomials gives exactly the convolution:

(1 + 2x)(3 + x) = 3 + 7x + 2x²

[1, 2] ∗ [3, 1] = [3, 7, 2]

This is also how long multiplication works. The digits of 123 and 45 convolve to [1, 2, 3] ∗ [4, 5] = [4, 13, 22, 15], and carrying the tens gives 4,000 + 1,300 + 220 + 15 = 5,535 = 123 × 45.

Properties of Convolution

  • Commutative: a ∗ b = b ∗ a, so the order of the two sequences does not matter.
  • Associative: (a ∗ b) ∗ c = a ∗ (b ∗ c).
  • Distributive: a ∗ (b + c) = a ∗ b + a ∗ c.
  • Identity: a ∗ [1] = a. The sequence [1] is the unit impulse.
  • Shift: a ∗ [0, 1] moves a one place to the right: [5, 7, 9] ∗ [0, 1] = [0, 5, 7, 9].
  • Sum rule: the terms of a ∗ b add up to (sum of a) × (sum of b). The calculator uses this as a check.
  • Length: m terms ∗ n terms always gives m + n − 1 terms.

Worked Examples

Two dice. Each face of a die has 1 way to come up, so the sequence is [1, 1, 1, 1, 1, 1]. Convolving it with itself counts the ways to roll each total from 2 to 12:

[1,1,1,1,1,1] ∗ [1,1,1,1,1,1]
= [1,2,3,4,5,6,5,4,3,2,1]

There are 6 ways out of 36 to roll a 7, the most likely total.

A moving average. Convolving [2, 4, 6, 8] with [0.5, 0.5] averages each pair of neighbours: [1, 3, 5, 7, 4]. The middle three terms are the averages; the first and last are the edges, where only one term overlaps.

Negative numbers. [3, −1, 2] ∗ [1, 0, −2] = [3, −1, −4, 2, −4]. The sum check works too: 4 × (−1) = −4, and 3 − 1 − 4 + 2 − 4 = −4.

Binomial coefficients. [1, 1] ∗ [1, 1] = [1, 2, 1] and [1, 2, 1] ∗ [1, 1] = [1, 3, 3, 1], the rows of Pascal's triangle.

Convolution vs Correlation

Cross-correlation slides b along a in the same way but does not flip it first. It measures how alike two signals are at each shift, while convolution applies one sequence to the other as a filter. For a symmetric b, such as [1, 2, 1], the two give the same result. Many "convolution" layers in neural networks actually compute correlation, which makes no difference there because the weights are learned.

Convolution in Python, MATLAB and R

Tool[1, 2, 3] ∗ [0, 1, 0.5]
Python (NumPy)numpy.convolve([1, 2, 3], [0, 1, 0.5])
Python (SciPy)scipy.signal.convolve(a, b)
MATLAB / Octaveconv([1 2 3], [0 1 0.5])
Rconvolve(a, rev(b), type = "open")

These all return the full result of m + n − 1 terms, the same as this calculator. NumPy also has mode="same" (as long as the longer input) and mode="valid" (only the positions where the sequences overlap completely). Note that R's convolve() needs b reversed to give the usual convolution.

Common Mistakes

  • Forgetting to flip. Sliding b without reversing it gives the correlation, not the convolution.
  • Wrong length. The result has m + n − 1 terms, not m + n and not the length of the longer sequence.
  • Multiplying term by term. [1, 2] × [3, 4] term by term is [3, 8]; the convolution is [3, 10, 8].
  • Dropping zeros. A 0 inside a sequence is a real term; [1, 0, 2] and [1, 2] give different results.
  • Starting at the wrong index. The first term is c[0] = a₀ × b₀.

Key Terms

Sequence
An ordered list of numbers, such as [1, 2, 3].
Discrete
Made of separate values, not a continuous curve.
Kernel
The short sequence used as a filter, such as [0.5, 0.5].
Impulse
The sequence [1]; convolving with it changes nothing.
Correlation
Like convolution, but without flipping b.

How to Use the Convolution Calculator

  1. Enter sequence a. Type the terms of the first sequence, separated by spaces or commas, for example 1 2 3. Decimals, negative numbers and brackets such as [1, 2, 3] are fine. Press Enter to move to the second field.
  2. Enter sequence b. Type the second sequence the same way, for example 0 1 0.5. Each sequence can have up to 1,000 terms.
  3. Read and copy the result. The convolution a ∗ b appears as you type, worked out exactly. The table shows its length, a sum check, the result as a polynomial and, for up to 15 terms, the products behind every term. Press Copy to copy the result, or Clear or Esc to start again.

Example: enter 1 2 3 and 0 1 0.5 and the result is 0, 1, 2.5, 4, 1.5. The table shows 3 + 3 − 1 = 5 terms, the sum check 6 × 1.5 = 9 and the polynomial x + 2.5x² + 4x³ + 1.5x⁴.

Who Can Use This Calculator?

Students and TeachersSignals and systems, sequences and polynomials
EngineersFilter outputs and impulse responses
ProgrammersChecking numpy.convolve or conv results
Probability LearnersDistributions of sums such as two dice

Frequently Asked Questions (FAQs)

What is convolution?

Convolution combines two sequences a and b into a new sequence c. Each term c[k] adds up the products a[i] × b[k − i] for every pair of positions that add to k. For example [1, 2, 3] ∗ [0, 1, 0.5] = [0, 1, 2.5, 4, 1.5].

How do you calculate the convolution of two sequences?

Reverse the second sequence, slide it along the first one step at a time, and at each step multiply the terms that line up and add the products. Each step gives one term of the result, starting with c[0] = a₀ × b₀.

How long is the result of a convolution?

If a has m terms and b has n terms, a ∗ b has m + n − 1 terms. Two 3-term sequences give 5 terms, and a 4-term sequence with a 2-term sequence gives 5 terms.

Is convolution the same as polynomial multiplication?

Yes. If the sequences are the coefficients of two polynomials, lowest power first, their convolution is the coefficients of the product. (1 + 2x)(3 + x) = 3 + 7x + 2x², and [1, 2] ∗ [3, 1] = [3, 7, 2].

Does the order of the two sequences matter?

No. Convolution is commutative, so a ∗ b = b ∗ a and you can enter the sequences in either field.

What is the difference between convolution and correlation?

Both slide one sequence along the other and add up products. Convolution flips the second sequence first; cross-correlation does not. For a symmetric sequence such as [1, 2, 1] they give the same result.

Why does the calculator give a different length than numpy.convolve with mode="same"?

This calculator gives the full convolution, the same as numpy.convolve with its default mode="full" and MATLAB conv. mode="same" keeps only the middle part, as long as the longer input, and mode="valid" keeps only the positions where the sequences overlap completely.

How is convolution used in probability?

The distribution of the sum of two independent random variables is the convolution of their distributions. For two dice, [1, 1, 1, 1, 1, 1] ∗ [1, 1, 1, 1, 1, 1] = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1] counts the ways to roll each total from 2 to 12.

Can I enter decimals and negative numbers?

Yes. Both sequences accept whole numbers, decimals, negative numbers and scientific notation such as 2e3. The calculator works with the digits exactly, so 0.1 × 0.2 gives 0.02 without floating-point rounding errors.

Is the Convolution Calculator free?

Yes. It is completely free, needs no sign-up, and can be used as many times as you like.

Try our Convolution Calculator to convolve any two sequences exactly, with the working for every term.