Advertisement
Advertisement
SIGNALS

Convolution Calculator — discrete linear convolution, term by term

Convolve two sequences and get the full output, the same and valid truncations, the sum check, and the lag-by-lag working that shows where every term came from.

Separate values with spaces, commas, semicolons or new lines. Up to 200 terms.
The second sequence. In filtering language this is the impulse response; in image work it is the kernel.
Full is the mathematical convolution. Same and valid are truncations of it used in signal and image processing.
The only difference is whether h is reversed before sliding. For a symmetric kernel the two are identical.
Normalising makes a smoothing kernel preserve the average level of the signal instead of scaling it.
Display only. The arithmetic is always done at full double precision.
Output sequence y
 
Output length
Sum of the full output
Largest term
Index of the largest
Sum check:
Working:
Tip: indices are zero-based, so the first output term is y[0]. In full mode y[0] is always x[0] multiplied by h[0], which is the quickest way to confirm you pasted the sequences the way round you intended.
Advertisement

The convolution calculator above takes two finite sequences and returns their discrete linear convolution: the sequence produced by sliding one past the other, multiplying the overlapping terms and summing them at every offset. It gives the full result, the same and valid truncations, a conservation check on the totals, and a written breakdown of the individual products behind each output term.

Convolution is the single most reused operation in applied mathematics. It is what a linear time-invariant filter does to a signal, what a blur kernel does to an image, how the distribution of a sum of independent random variables is found, and what happens to the coefficients when two polynomials are multiplied. Arb Digital publishes this page as the signals view of that operation — sliding, lags, kernels and edge modes. If your two sequences are polynomial coefficients and you want the answer written back as an algebraic expression, our polynomial arithmetic calculator does that instead, with long division as well.

What This Convolution Calculator Does

It computes the discrete linear convolution directly from the definition, with no transform and no approximation. For every output index it identifies which pairs of terms overlap, multiplies them, and adds the products. There are no zero-padding surprises: outside its own range each sequence is treated as exactly zero, which is what “linear” convolution means and is what separates it from the circular convolution a discrete Fourier transform produces.

Three output modes are offered because three are used in practice. Full keeps every overlap and has length Nx + Nh − 1. Same centres the result and trims it back to the length of x, which is what an image filter does so the picture keeps its dimensions. Valid keeps only the offsets where the kernel lies entirely inside x, giving Nx − Nh + 1 terms and no edge artefacts at all. The tool always computes the full result internally and then trims, so the sum check and the peak always refer to the untruncated sequence.

A cross-correlation option is included because the two operations are constantly confused. Correlation is the identical sliding sum without the kernel flip. If your kernel is symmetric — a Gaussian, a boxcar, a triangle — the two give the same answer, which is exactly why the distinction is so easy to miss until a non-symmetric kernel shifts your output the wrong way. Our correlation coefficient calculator covers the statistical measure, which is a different thing again.

How to Use It

  1. Paste the input sequence x using any mix of spaces, commas, semicolons or line breaks as separators.
  2. Paste the kernel h. It can be longer or shorter than x; convolution is commutative, so the order does not change the full result.
  3. Pick the output mode. Full for the mathematics, same for filtering that preserves length, valid when you want no edge effects.
  4. Choose convolution or correlation, and normalise the kernel if you want a smoother that preserves the signal level.
  5. Read the sum check. The sum of the full output must equal the sum of x multiplied by the sum of h. If it does not, one of your sequences did not parse the way you expected.

The Formula and How It Is Calculated

Discrete linear convolution is defined as

y[n] = ∑k x[k] · h[n − k]

with the sum running over every k for which both terms exist. Wolfram MathWorld's page on convolution gives the continuous integral form and the discrete sum side by side, along with the commutative, associative and distributive properties the operation satisfies.

Work the default values through by hand. Take x = (1, 2, 3, 4) and h = (1, 1, 1). The output has 4 + 3 − 1 = 6 terms. y[0] = 1×1 = 1. y[1] = 1×1 + 2×1 = 3. y[2] = 1×1 + 2×1 + 3×1 = 6. y[3] = 2×1 + 3×1 + 4×1 = 9. y[4] = 3×1 + 4×1 = 7. y[5] = 4×1 = 4. So y = (1, 3, 6, 9, 7, 4).

Check it. The sum of x is 10, the sum of h is 3, and the sum of y is 1 + 3 + 6 + 9 + 7 + 4 = 30, which is 10 × 3 exactly. That identity holds for every convolution and is the cheapest possible test of an implementation. In same mode the tool returns the centred four terms (3, 6, 9, 7); in valid mode it returns the two terms (6, 9) where the three-term kernel sits entirely inside x.

Advertisement

Why the Kernel Gets Flipped

The reversal in h[n − k] is not a convention someone chose for tidiness. It falls out of what a linear time-invariant system actually does. The impulse response h describes how the system reacts to a single unit impulse at time zero. An arbitrary input is a sum of scaled, delayed impulses, so the output is the sum of scaled, delayed copies of h. Line those copies up on a time axis and the flip appears automatically, because the input sample that arrived earliest has had the longest to decay through h.

The practical consequence is that convolving with an asymmetric kernel shifts and reverses features, while correlating with it does not. If you are matching a template against a signal you want correlation. If you are modelling what a physical system does to an input you want convolution. Choosing the wrong one produces a result that is mirrored about its centre — plausible-looking and wrong.

Flipping also explains the commutativity that makes the order of the two boxes above irrelevant. Substituting m = n − k in the sum turns x-convolved-with-h into h-convolved-with-x. The swap button is there so you can confirm that for yourself rather than take it on trust.

The Edge Modes and Where They Bite

Every output term near the start or end of the full result is computed from fewer than the full number of products, because part of the kernel is hanging off the end of the data. That is the source of every edge artefact in filtering. In the worked example y[0] = 1 and y[5] = 4 are both far below the interior values, not because the signal dipped but because only one product contributed.

Valid mode solves this by discarding those terms entirely. You pay for it in length: a 100-sample signal convolved with an 11-tap filter yields 90 valid samples, and you have lost five from each end. Same mode keeps the length but keeps the artefacts, which is the right trade when you are smoothing an image and can live with a slightly darker border. Full mode keeps everything, which is right when the tails carry meaning — the convolution of two probability distributions, for example, where the tails are the answer.

Normalising the kernel is the other correction worth knowing. A three-term boxcar (1, 1, 1) triples the level of a constant signal; divided by its sum it becomes a three-point moving average that leaves the level alone. That is precisely the operation our moving average calculator performs on a time series, and running the same data through both is a good way to see that a moving average is nothing more than convolution with a normalised boxcar.

The Same Arithmetic in Four Disguises

Multiplying two polynomials multiplies nothing more than their coefficient sequences under convolution. (1 + 2z + 3z² + 4z³) times (1 + z + z²) has coefficients (1, 3, 6, 9, 7, 4) — the same six numbers computed above. This is why fast polynomial multiplication and fast filtering use exactly the same algorithms.

The probability version is just as direct. If two independent random variables take integer values with probability sequences p and q, the sum takes value n with probability equal to the n-th term of the convolution of p and q. Convolve the uniform sequence for one fair die with itself and you get the familiar 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1 pattern of two-dice totals; our dice probability calculator shows the resulting distribution directly.

The transform version is the reason convolution is computationally cheap at scale. The convolution theorem says that convolution in one domain is ordinary pointwise multiplication in the transform domain, so an O(N²) sliding sum becomes an O(N log N) transform, multiply and inverse transform. MathWorld's page on the convolution theorem states it precisely. The catch is that the discrete transform gives circular convolution, which wraps the tail around onto the head, so the sequences must be zero-padded to the full output length first. This tool computes the direct sum, so that trap does not arise here.

Finally, the weighted-sum framing. Every output term is a weighted average of a window of the input with the kernel supplying the weights, which is why our weighted average calculator and our dot product calculator both compute what is effectively a single term of a convolution.

Need a calculator that shows its intermediate steps?

Arb Digital builds free tools that print the working, not just the answer.

Browse All Free Tools Talk To Our Team

Common Mistakes to Avoid

  • Using correlation when you meant convolution — with an asymmetric kernel the result is mirrored, and with a symmetric one you will never notice the bug until the kernel changes.
  • Forgetting to zero-pad before an FFT — the transform gives circular convolution, so without padding the tail wraps around and corrupts the first few terms.
  • Not normalising a smoothing kernel — a boxcar of ones scales the whole signal by the number of taps, which looks like a gain problem somewhere else entirely.
  • Reading edge terms as signal — the first and last few outputs of a full convolution are computed from partial overlaps and will always sag towards zero.
  • Assuming same mode centres exactly — with an even-length kernel there is no exact centre, so the trim is offset by half a sample in one direction by convention.

Related Free Tools From Arb Digital

Multiply and divide the same coefficient lists as algebra with the polynomial arithmetic calculator, smooth a series with the moving average calculator, take a single weighted window with the dot product calculator or the weighted average calculator, measure linear association with the correlation coefficient calculator, or see a convolved distribution in action with the dice probability calculator. The full free online tools hub lists every mathematics tool we publish.

Frequently Asked Questions

How long is the output of a convolution?

The full result of convolving a sequence of length Nx with one of length Nh has Nx plus Nh minus one terms. Same mode trims that back to the length of x, and valid mode gives Nx minus Nh plus one terms.

What is the difference between convolution and cross-correlation?

Only the flip. Convolution reverses the kernel before sliding it, correlation does not. For a symmetric kernel the two results are identical, which is why the distinction is so often missed.

How can I check the answer quickly?

The sum of the full output always equals the sum of the first sequence multiplied by the sum of the second. The tool displays that identity, and it catches almost every parsing or indexing error.

Why does convolution appear in polynomial multiplication?

Because collecting terms of a given degree in a product is exactly the sliding sum of coefficient pairs whose indices add to that degree, which is the definition of convolution.

Does the order of the two sequences matter?

No. Convolution is commutative, so swapping x and h leaves the full result unchanged. The swap button lets you confirm it, though the same and valid trims are defined relative to x.

What does normalising the kernel do?

It divides every kernel term by their sum, so the weights add to one. A smoothing kernel then preserves the average level of the signal instead of multiplying it by the number of taps.

Is this circular convolution?

No, it is linear convolution. Each sequence is treated as exactly zero outside its own range, with no wraparound. Circular convolution is what a discrete Fourier transform produces without zero padding.

Why do the first and last terms look too small?

Because only part of the kernel overlaps the data there, so fewer products contribute. That is the origin of edge artefacts, and valid mode removes those terms entirely.

This page explains a standard operation in discrete mathematics and signal processing for educational purposes. Results are computed in double-precision floating point, so long sequences with widely differing magnitudes may accumulate rounding error.

Advertisement
Advertisement

Take it further