# Convolution Calculator

Created by Julia Żuławińska and Anna Szczepanek, PhD
Reviewed by Rijk de Wet
Last updated: Jun 21, 2023

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 $\vec{a} = \{a_n\}_{n =0}^\infty$ and $\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 $0$, like programmers do. We define the convolution of $\vec{a}$ and $\vec{b}$ as the sequence $\vec{c} = \{c_n\}_{n =0}^\infty$, where

$c_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:

$c_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 $c_n$ (the $n$-th term of the convolution), we compute the products of terms whose indices sum to $n$. Consider $c_2$ — for this term, we need the products of terms whose indices sum to $2$. These are $a_0b_2$, $a_1b_1$, and $a_2b_0$, because $0+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 $f$ and $g$, their convolution $f * g$ is another function, whose value at $x$ is defined as

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

From the point of view of signal processing, $f$ describes the signal and $g$ 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$ under the function $g$, we reflect it across the vertical axis. Then, by introducing the time-offset $x$, we slide $g$ horizontally.

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

In the picture below, you can see how this procedure works in the particular case of both $f$ and $g$ as the characteristic functions of the interval $[-\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 $x$ is exactly equal to the yellow area at time $x$. 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 $g$ bidding its final farewell to $f$.

## 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
People also viewed…

### Helium balloons

Wondering how many helium balloons it would take to lift you up in the air? Try this helium balloons calculator! 🎈

### Ideal egg boiling

Quantum physicist's take on boiling the perfect egg. Includes times for quarter and half-boiled eggs.

### Interval notation

Our interval notation calculator will help you convert from inequality notation to interval notation and the other way around.

### Order of magnitude

The order of magnitude calculator will show you the number in scientific notation (also called standard form), and based on that, return its order of magnitude.