Skip to content
Math

Convolution Calculator

Enter two sequences of numbers separated by commas, choose linear or circular convolution, and the result updates instantly. Every output term is shown as a separate step so you can follow the dot-product arithmetic. Linear convolution produces N + M - 1 output values; circular convolution wraps around a period of length N.

Your details

Linear convolution is the standard DSP operation. Circular convolution wraps the sequences periodically and is used with the DFT.
Enter values separated by commas or spaces. Up to 20 terms recommended.
Enter values separated by commas or spaces.
Convolution result (f * g)
[4, 13, 28, 27, 18]

The full output sequence as a bracketed list

Output length5
Length of f3
Length of g3
Sum of output terms90
Length of f3
Length of g3
Output length5
01428024
Index n
  • f * g (result)
  • f (input)
  • g (input)

Linear convolution complete: 5 output terms

  • The linear convolution of a 3-term sequence with a 3-term sequence produces 5 output terms.
  • The maximum output value is 28 at index 2.
  • The sum of all output terms equals 90, which equals the product of the sums of f and g for linear convolution.
  • Linear convolution is used in FIR filtering: the result gives every overlap between the two sequences without periodic wrap-around.

Next stepSwitch to circular mode to see how the result differs when the sequences are treated as periodic, or adjust your sequences to explore different filter shapes.

Formula

Linear: (fg)[n]=k=0N1f[k]g[nk]Circular: y[n]=k=0N1f[k]g[(nk)modN]\text{Linear: } (f * g)[n] = \sum_{k=0}^{N-1} f[k]\, g[n-k] \qquad \text{Circular: } y[n] = \sum_{k=0}^{N-1} f[k]\, g[(n-k) \bmod N]

Worked example

f = [1, 2, 3], g = [4, 5, 6]. y[0] = 1*4 = 4. y[1] = 1*5 + 2*4 = 13. y[2] = 1*6 + 2*5 + 3*4 = 28. y[3] = 2*6 + 3*5 = 27. y[4] = 3*6 = 18. Result: [4, 13, 28, 27, 18].

What is discrete convolution?

Convolution is a mathematical operation that blends two sequences (or functions) together by sliding one over the other and summing the element-wise products at each position. For two finite sequences f and g, the linear convolution at index n is the sum of f[k] times g[n-k] over all valid k. The result sequence is always longer than either input: if f has N terms and g has M terms, the output has N + M - 1 terms. Convolution appears throughout digital signal processing, image filtering, probability theory (where it gives the distribution of a sum of random variables), and deep learning (convolutional neural networks use learnable filter kernels convolved with input data).

Linear vs. circular convolution

Linear (aperiodic) convolution is the default operation described above. Every output term is formed by only the actual, non-wrapped values of f and g. Circular (periodic) convolution treats both sequences as if they repeat with the same period N, where N = max(len(f), len(g)) after zero-padding the shorter one. Each output index is computed with the modulo operation: y[n] = sum over k of f[k] times g[(n-k) mod N]. Circular convolution is equivalent to multiplying the Discrete Fourier Transforms (DFTs) of the two sequences and then taking the inverse DFT, which is why it is fundamental in fast convolution algorithms. If you are implementing an FIR filter, use linear convolution. If you are computing a spectrum or using the FFT for speed, use circular convolution (and be aware of circular aliasing if the sequences are not zero-padded enough).

Key properties of convolution

Convolution satisfies three algebraic properties: commutativity (f * g = g * f, the order of the inputs does not change the result), associativity ((f * g) * h = f * (g * h), you can chain multiple convolutions in any grouping), and distributivity over addition (f * (g + h) = f * g + f * h, useful when combining filter banks). The identity element under linear convolution is the unit impulse [1]: convolving any sequence with [1] returns the original sequence unchanged. These properties make convolution useful for building modular systems, such as cascaded digital filters, where each filter stage can be designed and tested independently.

Applications of convolution

Digital signal processing: an FIR (finite impulse response) filter computes the convolution of the input signal with the filter coefficients. A moving-average filter with coefficients [1/3, 1/3, 1/3] smooths a sequence by replacing each sample with the average of its neighbours. Image processing: 2-D convolution applies a kernel (such as a blur, sharpen, or edge-detect matrix) to every pixel in an image. Probability: if X and Y are independent discrete random variables, the probability mass function of X + Y is the convolution of the PMFs of X and Y. Neural networks: convolutional layers apply learned 2-D or 3-D kernels to input feature maps, extracting spatial patterns at multiple scales.

Convolution output length rules

Convolution typeLength of fLength of gOutput length
Linear333 + 3 - 1 = 5
Linear444 + 4 - 1 = 7
Linear535 + 3 - 1 = 7
Linear848 + 4 - 1 = 11
Circular33max(3, 3) = 3
Circular43max(4, 3) = 4
Circular84max(8, 4) = 8

How many terms to expect in the output for common input lengths.

Frequently asked questions

What is the output length of a convolution?

For linear convolution of two sequences of lengths N and M, the output has exactly N + M - 1 terms. For circular convolution, the output length equals max(N, M), because the shorter sequence is zero-padded to match. For example, convolving a 5-term sequence with a 3-term sequence gives 7 terms linearly, and 5 terms circularly.

Is convolution commutative?

Yes. f * g always equals g * f for both linear and circular convolution. Swapping the two input sequences produces the same output sequence. This follows directly from the definition: renaming the summation index shows that the products being summed are identical in both orderings.

What is the difference between linear and circular convolution?

Linear convolution treats the sequences as finite and produces a longer output. Circular convolution treats the sequences as periodic with period N and produces an output of the same length N. Circular convolution wraps values that would fall outside the period back to the beginning using modulo indexing. When sequences are zero-padded to at least N + M - 1 terms before circular convolution, the result matches linear convolution - this is the trick used in overlap-add fast filtering.

What is the unit element (identity) of convolution?

The identity element of linear convolution is the unit impulse sequence [1], also written as delta[n]. Convolving any sequence f with [1] returns f unchanged, because every output term y[n] = f[n] * 1 = f[n]. In continuous convolution the identity is the Dirac delta function.

How is convolution used in filtering?

An FIR digital filter convolves the input signal with a fixed set of coefficients called the impulse response. Each output sample is a weighted sum of the current and past input samples, where the weights are the filter coefficients. A 3-point moving-average filter has coefficients [1/3, 1/3, 1/3]: each output sample is the average of three consecutive inputs, smoothing out high-frequency noise.

How do I enter sequences into this calculator?

Type or paste the values separated by commas, spaces, or semicolons, such as "1, 2, 3" or "4 5 6". The calculator accepts integers and decimals. Do not include brackets or the letter "n"; just the raw numbers. Press Tab or click away and the result updates immediately.

What is the relationship between convolution and the Fourier transform?

The convolution theorem states that the Fourier transform of a convolution equals the pointwise product of the individual Fourier transforms: FT(f * g) = FT(f) x FT(g). This means you can compute a convolution by transforming both sequences to the frequency domain, multiplying, then transforming back. For long sequences this is dramatically faster using the FFT algorithm, giving O(N log N) complexity instead of O(N squared) for direct convolution.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…