Convolution Calculator

Convolution Calculator

Growing AI Skill PRO

Enter Calculation

Formula

(Seq1∗Seq2)[i]=∑j=max⁡(0,i−m+1)min⁡(i,n−1)Seq1[j]·Seq2[i−j]({{\text{Seq}_1}} * {{\text{Seq}_2}})[i] = \sum_{j=\max(0,\,i-m+1)}^{\min(i,\,n-1)} {{\text{Seq}_1}}[j]\cdot {{\text{Seq}_2}}[i-j]
Usage stats

Advertisement

Results

Convolution Result:
4, 13, 28, 27, 18
First Sequence 1,2,3
Second Sequence 4,5,6

Report an error on this page

What the Convolution Calculator Does

This Convolution Calculator computes the discrete convolution of two finite sequences of numbers. Convolution is a core operation in signal processing, image filtering, probability, and polynomial multiplication. Instead of working through the sums by hand, you enter two sequences and the tool instantly returns the combined output sequence.

How to Use It

There are just two input fields:

  • First Sequence — your input signal or first set of numbers, entered as comma-separated values (for example 1, 2, 3).
  • Second Sequence — your second signal, kernel, or filter, also comma-separated (for example 0, 1, 0.5).

Decimals and negative numbers are accepted. The calculator splits each entry on commas, trims spaces, and converts each item to a number before computing the result.

The Formula Explained

Discrete convolution is defined as:

$$(\text{Seq}_1 * \text{Seq}_2)[i] = \sum_{j=\max(0,\,i-m+1)}^{\min(i,\,n-1)} \text{Seq}_1[j]\cdot \text{Seq}_2[i-j]$$

For two finite sequences of length n and m, the result has exactly n + m − 1 values. Each output value \(y[i]\) is the sum of all products \(x[j] \cdot h[i - j]\) where the indices stay within both sequences. In plain terms, the tool slides one sequence across the other, multiplies overlapping terms, and adds them up at each shift.

Advertisement
Diagram of discrete convolution as a flip-and-slide overlap of two sequences producing an output sequence
Convolution flips one sequence and slides it across the other, summing the overlapping products at each shift.

Worked Example

Let First Sequence = 1, 2, 3 and Second Sequence = 0, 1, 0.5. Here n = 3 and m = 3, so the result has 3 + 3 − 1 = 5 values:

  • \(y[0] = 1\cdot 0 = 0\)
  • \(y[1] = 1\cdot 1 + 2\cdot 0 = 1\)
  • \(y[2] = 1\cdot 0.5 + 2\cdot 1 + 3\cdot 0 = 2.5\)
  • \(y[3] = 2\cdot 0.5 + 3\cdot 1 = 4\)
  • \(y[4] = 3\cdot 0.5 = 1.5\)

So the output is 0, 1, 2.5, 4, 1.5.

Three stem plots showing input sequence, second sequence, and the longer resulting convolution output
The output is longer than either input, with length n + m − 1.

How to Compute a Convolution by Hand

Discrete linear convolution combines two finite sequences, \(x\) of length \(n\) and \(h\) of length \(m\), into a single output \(y = x * h\). The defining sum is

$$y[i] = \sum_{j} x[j]\,h[i-j], \qquad i = 0,1,\dots,n+m-2$$

where any term whose index falls outside a sequence is treated as zero. The procedure below is the standard "flip and slide" method and is what this calculator performs (full linear convolution, no truncation).

  1. Note the lengths. Let \(n\) be the number of terms in the first sequence and \(m\) the number in the second. The output always has exactly \(n+m-1\) terms. Check this number first — it is the simplest guard against a dropped term.
  2. Index both sequences from 0. Write \(x[0],x[1],\dots,x[n-1]\) and \(h[0],h[1],\dots,h[m-1]\). Zero-based indexing makes the shift arithmetic \(i-j\) work without offsets.
  3. Reverse (flip) the second sequence. Write \(h\) backwards: \(h[m-1],\dots,h[1],h[0]\). The flip is what turns the sum \(\sum_j x[j]h[i-j]\) into a simple aligned column of products.
  4. Slide the flipped sequence across the first. Start at shift \(i=0\), where only the last element of the flipped kernel — that is, \(h[0]\) — sits under \(x[0]\). Move the flipped kernel one position to the right for each successive \(i\).
  5. Multiply aligned pairs and sum. At each shift, multiply every vertically aligned pair and add the products. That single number is \(y[i]\).
  6. Treat out-of-range indices as zero. Where the flipped kernel hangs off either end, the missing values are zeros (zero-padding), so those products contribute nothing. Equivalently, restrict the sum to \(\max(0,\,i-m+1) \le j \le \min(i,\,n-1)\).
  7. Record \(y[i]\) for \(i = 0,1,\dots,n+m-2\). Stop when the flipped kernel has passed completely off the right end; the last non-zero shift is \(i=n+m-2\).

Sliding alignment layout

With \(n=3\) and \(m=2\) — sequences \(x=[x_0,x_1,x_2]\) and \(h=[h_0,h_1]\) — the flipped kernel \([h_1,h_0]\) slides as follows. The output has \(3+2-1=4\) terms.

Shift \(i\) Aligned under \(x_0\) Aligned under \(x_1\) Aligned under \(x_2\) Products entering \(y[i]\)
0 \(h_0\) — — \(y[0]=x_0h_0\)
1 \(h_1\) \(h_0\) — \(y[1]=x_0h_1+x_1h_0\)
2 — \(h_1\) \(h_0\) \(y[2]=x_1h_1+x_2h_0\)
3 — — \(h_1\) \(y[3]=x_2h_1\)

Notice the pattern: in every product the two indices add up to \(i\). That is the whole rule — \(y[i]\) is the sum of all \(x[j]h[k]\) with \(j+k=i\).

The polynomial-multiplication view

Because indices add, convolution is identical to multiplying polynomials and collecting coefficients. Associate each sequence with a polynomial in a dummy variable \(z\):

$$X(z)=x_0+x_1z+x_2z^2, \qquad H(z)=h_0+h_1z$$

Then

$$X(z)H(z)=x_0h_0+(x_0h_1+x_1h_0)z+(x_1h_1+x_2h_0)z^2+x_2h_1z^3$$

whose coefficients are exactly \(y[0],y[1],y[2],y[3]\). A degree-\((n-1)\) polynomial times a degree-\((m-1)\) polynomial has degree \(n+m-2\), i.e. \(n+m-1\) coefficients — the same length rule. This is a convenient way to check a hand computation: multiply out the polynomials by ordinary algebra and compare coefficient lists.

Advertisement

Key Terms and Notation

Term Meaning
Convolution \(x * h\) The operation \(y[i]=\sum_j x[j]\,h[i-j]\) that combines two sequences by summing all products whose indices add to \(i\). Written with an asterisk, \(y = x * h\).
Sequence / signal \(x[n]\) An ordered list of numbers indexed by an integer \(n\) — samples of a measurement, a data series, or a set of coefficients. Here indexing starts at \(n=0\).
Kernel / filter / impulse response \(h[n]\) Three names for the same second sequence. "Kernel" or "filter" emphasises the weights applied to neighbouring samples; "impulse response" is the system view — \(h\) is literally the output a linear time-invariant system produces when fed a single unit impulse.
Index \(n\) (or \(i\)) and shift variable \(j\) \(i\) labels the output position being computed; \(j\) is the internal summation variable that runs over the overlapping positions. Inside the sum, \(x\) is read at \(j\) and \(h\) at \(i-j\).
Support and output length The support is the range of indices where a sequence is non-zero. If \(x\) has \(n\) terms and \(h\) has \(m\), the output occupies indices \(0\) through \(n+m-2\) — exactly \(n+m-1\) values.
Zero-padding Treating every index outside a sequence's defined range as zero. This is what lets the sum be written over all \(j\) without special cases; it also explains the reduced-magnitude values at the two ends of the output.
Linear vs circular convolution Linear convolution zero-pads the ends and produces \(n+m-1\) values. Circular convolution wraps the ends around, producing only \(\max(n,m)\) values, and arises naturally from DFT/FFT multiplication. This calculator computes linear convolution in "full" mode — nothing is truncated to the shorter "same" or "valid" output that some software libraries return by default.
Commutative \(x * h = h * x\). Swapping the two input sequences gives the identical output, so it never matters which one you call the signal and which the kernel.
Associative \((x * h_1) * h_2 = x * (h_1 * h_2)\). Two filters applied in series can be replaced by a single filter equal to their convolution.
Distributive \(x * (h_1 + h_2) = x * h_1 + x * h_2\). Filters in parallel add.
LTI system A linear, time-invariant system: scaling and adding inputs scales and adds outputs, and delaying the input merely delays the output. Every such system is completely described by its impulse response, and its output is the convolution of input with \(h\).
Moving-average / smoothing filter A kernel of \(k\) equal weights \(1/k\), e.g. \(h = [0.5, 0.5]\) or \(h = [1/3, 1/3, 1/3]\). Convolving with it averages each sample with its neighbours, suppressing rapid fluctuations; the first and last few output values are edge transients contaminated by zero-padding.
Discrete vs continuous convolution The discrete form sums; the continuous form integrates: \((x * h)(t) = \int_{-\infty}^{\infty} x(\tau)\,h(t-\tau)\,d\tau\). This tool handles the discrete (sampled) case.
Polynomial coefficient multiplication If \(X(z)=\sum_j x[j]z^j\) and \(H(z)=\sum_k h[k]z^k\), then the coefficients of \(X(z)H(z)\) are exactly \(x * h\). Long multiplication of integers is the same idea with carrying.
Sum of independent random variables If \(X\) and \(Y\) are independent and integer-valued, the probability mass function of \(Z = X+Y\) is the convolution of their PMFs: \(P(Z=k)=\sum_j P(X=j)\,P(Y=k-j)\). Convolving \([1/6,\dots,1/6]\) with itself, for instance, gives the distribution of the total of two fair six-sided dice.

Frequently Asked Questions

How long is the output sequence? Always the length of the first sequence plus the length of the second sequence minus one (n + m − 1).

Does the order of the two sequences matter? No. Convolution is commutative, so swapping the two inputs gives the same result sequence.

Can I use it for polynomial multiplication? Yes. If you treat each sequence as the coefficients of a polynomial, the convolution output is the coefficients of their product — a handy shortcut for algebra as well as signals.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators