Omni Calculator logo

Convolution Calculator

Created by Julia Żuławińska and Anna Szczepanek, PhD
Reviewed by Rijk de Wet
Last updated: Jan 18, 2024


With Omni's convolution calculator, you can quickly compute the result of convolving two sequences of data. Not yet familiar with this math operation? Scroll down to learn with us! We'll answer the following questions:

  • What is convolution?
  • How to calculate convolution?
  • What is the role of convolution in probability theory?

We'll also go together through an example of computing the convolution of two data sets.

🙋 Convolution is a specific method of multiplying two sequences of numbers. If you're looking for the more standard method, visit Omni's dot product calculator.

What is convolution in math?

Convolution is a mathematical operation on two sequences (or, more generally, on two functions) that produces a third sequence (or function). Traditionally, we denote the convolution by the star , and so convolving sequences a and b is denoted as a∗b. The result of this operation is called the convolution as well.

The applications of convolution range from pure math (e.g., probability theory and differential equations) through statistics to down-to-earth applications like acoustics, geophysics, signal processing, and computer vision.

💡 In signal processing, if you know the impulse response of a linear time-invariant system (e.g., an amplifier), then using convolution, you can predict the system's output for any input.

Let's discuss how we define convolution.

Formula for convolution of sequences

Consider the two sequences a={an}n=0\vec{a} = \{a_n\}_{n =0}^\infty and b={bn}n=0\vec{b} = \{b_n\}_{n=0}^\infty. The use of \infty here simply means that their lengths can be arbitrarily long. Note that we start counting the sequences' terms at 00, like programmers do. We define the convolution of a\vec{a} and b\vec{b} as the sequence c={cn}n=0\vec{c} = \{c_n\}_{n =0}^\infty, where

cn=k=0nakbnkc_n = \sum_{k=0}^{n} a_k b_{n-k}

The convolution formula above may look intimidating at first, but it is actually really simple! Explicitly, for the first few terms, we have:

c0=a0b0c1=a0b1+a1b0c2=a0b2+a1b1+a2b0c3=a0b3+a1b2+a2b1+a3b0c_0 = a_0b_0\\ c_1 = a_0b_1+a_1b_0\\ c_2 = a_0b_2+a_1b_1+a_2b_0\\ c_3 = a_0b_3+a_1b_2+a_2b_1+a_3b_0

See the pattern? To get cnc_n (the nn-th term of the convolution), we compute the products of terms whose indices sum to nn. Consider c2c_2 — for this term, we need the products of terms whose indices sum to 22. These are a0b2a_0b_2, a1b1a_1b_1, and a2b0a_2b_0, because 0+2=1+1=2+0=20+2 = 1+1 = 2+0 = 2! Clever, isn't it?

🔎 If you're already familiar with series, the formula above looks familiar — it is the Cauchy product of series. See the sum of series calculator to learn about this area of math.

As we now know what convolution is and what formula has to be used, let's see how to calculate the convolution of two data sets with the help of our tool.

How to use the convolution calculator?

Using this convolution calculator is really simple:

  1. Input the data up to fifteen terms per sequence — additional fields will appear as you go.
  2. The calculator will summarize your input at the bottom of the calculator. Make sure there's no typos.
  3. The result of the convolution will appear at the same place.

Example

Let's go together through an example. We will compute the convolution of [1, 2, 3] with [4, 5, 6]. Let's first compute by hand, using the convolution formula we've discussed in the previous section:

  • c0 = 1 × 4 = 4
  • c1 = 1 × 5 + 2 × 4 = 13
  • c2 = 1 × 6 + 2 × 5 + 3 × 4 = 28
  • c3 = 2 × 6 + 3 × 5 = 27
  • c4 = 3 × 6 = 18

Entering these values into Omni's convolution calc, we see that our calculations are correct. Great!

Convolution of functions

The convolution of two sequences that we discussed above is, in fact, a special case of a more general math operation: convolving two functions.

Namely, for two real functions ff and gg, their convolution fgf * g is another function, whose value at xx is defined as

(fg)(x):=f(t)g(xt)dt\small (f*g)(x):=\int _{-\infty }^{\infty }f(t)g(x-t)\,dt

From the point of view of signal processing, ff describes the signal and gg is a filter applied to this signal. The role of the filter may be, e.g., to sharpen or blur the signal, depending on our needs.

How to visualize convolution?

The integral formula for convolving two functions promotes the geometric interpretation of the convolution, which is a bit less conspicuous when one looks at the discrete version alone.

First, note that by using t-t under the function gg, we reflect it across the vertical axis. Then, by introducing the time-offset xx, we slide gg horizontally.

Now, for a fixed value of xx, we integrate the product of f(t)f(t) and g(xt)g(x-t), that is, we compute the area under the function f(t)f(t) but weighted by the function g(xt)g(x-t), i.e., by g(t)g(-t) shifted by xx. And as the value of xx changes (let's say it increases), i.e., as g(t)g(-t) slides horizontally (from left to right), different parts of the signal f(t)f(t) get emphasized by the weighting.

In the picture below, you can see how this procedure works in the particular case of both ff and gg as the characteristic functions of the interval [12,12][-\frac 12, \frac 12], or more visually intuitive, as single periods of square waves. Let us point out that here, the weighting is trivial (constant), so the value of convolution for the argument xx is exactly equal to the yellow area at time xx. Look carefully how the value of the convolution (black line) increases from zero (before the two functions touch) to the maximal value (when they coincide) and then decreases again, hitting zero exactly at the moment of gg bidding its final farewell to ff.

Visualization of convolution of two functions.
Convolution of box signal with itself by Brian Amberg. Derivative work: Tinos, CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0, via Wikimedia Commons

FAQ

Is convolution commutative?

Yes, convolution is commutative, meaning that the order does not matter and that f∗g=g∗f. Moreover, it is associative as well as distributive, i.e. f∗(g∗h)=(f∗g)∗h and f∗(g+h)=(f∗g)+(f∗h).

What is the unit element of convolution?

The unit element of convolution is the sequence with one at the initial position and zeroes elsewhere: {1, 0, 0, 0,...}. We call it a unit sample sequence, discrete-time impulse, or a (discrete) Dirac delta impulse.

How do I calculate convolution?

To compute the convolution of two sequences (vectors):

  1. First multiply the first term of each sequence with one another. This is the first term of the convolution.
  2. To get the n-th term of the result:
    • Compute the products a0bn, a1bn-1, etc., up to anb0. Note that the indices change simultaneously: the first one increases, while the second one decreases.
    • Add together all the terms computed above.
  3. Repeat Step 2 for as many terms as you need.
  4. Alternatively, use an online convolution calculator.

What is the application of convolution in probability?

The well-known theorem in probability says that if we have two independent random variables with probability density functions (PDFs), then the PDF of their sum arises as the convolution of the PDFs of these variables.

Julia Żuławińska and Anna Szczepanek, PhD
Input up to 15 terms in each sequence:
First data sequence
#1
#2
#3
Second data sequence
#1
#2
#3
Check out 10 similar sequences calculators 🔗
Arithmetic sequenceCollatz conjectureFibonacci… 7 more
People also viewed…

Discount

The discount calculator uses a product's original price and discount percentage to find the final price and the amount you save.

Perfect square trinomial

Perfect square trinomial calculator checks if your trinomial is a perfect square of a linear binomial and, if so, finds the binomial.

Test grade

With this test grade calculator, you'll quickly determine the test percentage score and grade.

Three-dimensional distance

Use the three-dimensional distance calculator to find the distance between two points in space.
Copyright by Omni Calculator sp. z o.o.
Privacy, Cookies & Terms of Service