Convolution Calculator
The sequences 1, 2, 3 and 4, 5 convolve to 4, 13, 22, 15. Each output adds the sliding products of the two sequences, so the second output is 1 x 5 + 2 x 4 = 13, and an input length of 3 against 2 produces 4 outputs.
Type two sequences of numbers, separated by spaces or commas. The calculator convolves them and shows every output, the length rule and a sum check. Everything runs in your browser.
| Convolution | |
| Outputs (n + m - 1) | |
| Products used (n x m) | |
| Sum of the outputs | |
| Sum check (sum A x sum B) |
All calculations run in your browser, and nothing you type is uploaded or stored.
Enter two sequences of numbers and the calculator convolves them, showing every output, the length rule and a sum check for the result.
Key takeaways
- Discrete convolution sums sliding products: (1, 2, 3) and (4, 5) give 4, 13, 22, 15
- Output length is n + m - 1, so length 3 against length 2 gives 4 outputs from 6 products
- Polynomial multiplication hides one: (1 + 2x + 3x^2) times (4 + 5x) carries coefficients 4, 13, 22, 15
- A sum check catches typos: the outputs add to 54, which is 6 x 9, the input sums multiplied
- Two-dice totals are a convolution: 7 leads with 6 ways in 36, or 16.7 percent
On this page
What convolution computes
Convolution takes two sequences of numbers and blends them into a third. To get each output, flip one sequence, slide it across the other, multiply the numbers that line up, and add the products. Written out, output k equals the sum of a[i] x b[k - i] over every position i where both sequences have an entry.
That flip-and-slide recipe sounds strange until you see what it buys. It is the standard way to answer questions shaped like this: the effect now is the sum of the past effects, each weighted by how long ago it happened. MIT OpenCourseWare's Signals and Systems course builds filters, echoes and smoothing on exactly this operation, and Wolfram MathWorld describes it as the amount of overlap of one function as it shifts over another.
A small example shows the whole idea. Convolving 1, 2, 3 with 4, 5 gives 4, 13, 22, 15. Four outputs come out of six multiply-and-add steps, and the calculator above runs the same steps on any two sequences you type, including decimals and negative numbers.
A worked example, term by term
Take A = (1, 2, 3) and B = (4, 5). The first output lines up 1 with 4 and nothing else, so it is 1 x 4 = 4. The second lines up two pairs, 1 with 5 and 2 with 4, so 1 x 5 + 2 x 4 = 5 + 8 = 13. The third lines up 2 with 5 and 3 with 4, so 2 x 5 + 3 x 4 = 10 + 12 = 22. The last pairs 3 with 5, so 3 x 5 = 15. The result reads 4, 13, 22, 15.
Notice that the entries of B get used in reverse order as the slide progresses. The reversal is not a printing quirk in the textbook: it is what makes the operation fit time systems, where an effect that started k steps ago should be weighted by the response k steps back.
| First sequence | Second sequence | Result | Outputs | Products used |
|---|---|---|---|---|
| (1, 2, 3) | (4, 5) | 4, 13, 22, 15 | 4 | 6 |
| (2, 1) | (3, 4, 5) | 6, 11, 14, 5 | 4 | 6 |
| (1, -2) | (1, 1, 1) | 1, -1, -1, -2 | 4 | 6 |
| (1) | (7, 8, 9) | 7, 8, 9 | 3 | 3 |
Negative numbers behave like any other entries. The third row mixes one negative value into the second sequence and gets negative outputs in the middle, and nothing about the method changes.
Length and arithmetic rules
Three counting rules cover every discrete convolution. The result has n + m - 1 outputs for inputs of length n and m, so 3 against 2 gives 4 outputs. The total number of multiply-and-add steps is n x m, so the example above uses 3 x 2 = 6 of them. And the outputs add up to the product of the input sums: (1 + 2 + 3) x (4 + 5) = 6 x 9 = 54, which matches 4 + 13 + 22 + 15 = 54. That sum check catches a flipped sign or a dropped term faster than recomputing everything.
Order does not matter either. Convolving 1, 2, 3 with 4, 5 produces the same four numbers as convolving 4, 5 with 1, 2, 3, because each of the n x m products appears exactly once in either direction. The calculator reports the same result if you swap the two boxes, which is a handy way to confirm a hand calculation.
Zero padding explains where the two end outputs come from. Pad the first sequence with zeros at both ends, set the flipped second sequence underneath, and each column of aligned pairs contributes one output. The padding is why the result runs longer than either input, and it is the mental picture to reach for when the counting stops adding up.
Polynomials hide a convolution
Multiply (1 + 2x + 3x^2) by (4 + 5x) and collect the terms. The constant term is 1 x 4 = 4. The x term collects 1 x 5 and 2 x 4, which adds to 13. The x^2 term collects 2 x 5 and 3 x 4, which adds to 22. The x^3 term is 3 x 5 = 15. The product reads 4 + 13x + 22x^2 + 15x^3, the same four numbers as the convolution example, in the same order.
This is why multiplying polynomials by hand and computing a convolution are the same exercise in different notation. It also hands you a free self-check for homework: any coefficient computed both ways has to agree. The calculator serves as that check, since the boxes accept a polynomial's coefficients and nothing else about the powers matters.
Dice, probability and moving averages
Roll two dice and add the faces. The distribution of that total is the convolution of the face distribution with itself. Each face turns up once in six, so convolving six values of 1/6 with six values of 1/6 produces the familiar pyramid: 7 is the most likely total with 6 ways out of 36, while 2 and 12 land once in 36 each.
| Total | Ways | Probability |
|---|---|---|
| 2 | 1 | 2.8% |
| 3 | 2 | 5.6% |
| 4 | 3 | 8.3% |
| 5 | 4 | 11.1% |
| 6 | 5 | 13.9% |
| 7 | 6 | 16.7% |
| 8 | 5 | 13.9% |
| 9 | 4 | 11.1% |
| 10 | 3 | 8.3% |
| 11 | 2 | 5.6% |
| 12 | 1 | 2.8% |
The same operation smooths data. Convolve the readings 10, 20, 30, 40 with the two-term average 0.5, 0.5 and the outputs are 5, 15, 25, 35, 20: the second output is 10 x 0.5 + 20 x 0.5 = 15, each output averaging a pair of neighbors. Sound engineers run the idea at scale, convolving a dry recording with the impulse response of a concert hall to place the listener inside it.
Sequences that shift, scale and smooth
A few short sequences act like tools, and convolving with them is a quick way to check your work or to build a signal.
| Convolve with | Effect | Example on (5, 6, 7) |
|---|---|---|
| (1) | leaves the sequence alone | 5, 6, 7 |
| (0, 1) | shifts everything one place later | 0, 5, 6, 7 |
| (2) | doubles every term | 10, 12, 14 |
| (1, 1) | adds neighboring pairs | 5, 11, 13, 7 |
| (1, 1, 1) | moving sum of three terms | 5, 11, 18, 13, 7 |
| (0.5, 0.5) | moving average of two terms | 2.5, 5.5, 6.5, 3.5 |
The shift row is the one worth memorizing. A sequence with a zero in front delays a signal without changing it, which is how systems textbooks write the sentence "the effect arrives k steps later." Combining a handful of these rows covers a surprising share of homework answers, and each row is fast to confirm in the calculator.
The rows chain, too. Convolving (5, 6, 7) with (0, 1) and then with (1, 1) gives 0, 5, 11, 13, 7, which is the shifted sequence with neighboring pairs added. Each step is easy to check on its own, so a long chain of small convolutions stays as trustworthy as the single four-output example.
Mistakes that produce the wrong sequence
Four habits cause nearly all wrong convolutions, and each one leaves a fingerprint in the output.
| Mistake | What comes out | Fix |
|---|---|---|
| Skipping the flip | (1, 2) against (3, 4) gives 11, 4 instead of 3, 10, 8 | Flip the second sequence before it slides |
| Dropping the partial overlaps | Keeping only the full-overlap product gives 10 instead of 3, 10, 8 | The ends count, even when one pair lines up |
| Adding where you should multiply | The first output of (1, 2) against (3, 4) is 1 x 3, not 1 + 3 | Multiply the aligned pairs, then add the products |
| Expecting the input length back | Two length-2 inputs return 3 numbers, not 2 | Count n + m - 1 before you start |
The first row is the common one, and skipping the flip even carries its own name, cross-correlation, with its own uses. The outputs differ in length as well as value: correlation returns 2 numbers where convolution returns 3, so a length mismatch is an early warning that the flip went missing.
Where convolution shows up beyond homework
The same sliding multiply-and-add runs a lot of the modern world. Audio plug-ins convolve a dry track with a concert hall's impulse response to add believable echo. Image editors blur or sharpen a photo by convolving it with a small grid of weights. Neural networks named for the operation, convolutional networks, slide learned filters across images to pick out edges and shapes. Statisticians reach for convolution whenever two independent random quantities add, which is why the dice table above looks the way it does.
The encyclopedia entry on convolution catalogs dozens more uses, from probability to differential equations to optics. The common thread is a system whose response spreads over time or space, so effects from different moments pile up. Once you can compute the four-output example by hand, the size of the application stops mattering, because the arithmetic never changes.
Long multiplication is the same arithmetic with digits. The partial rows of 123 x 45 = 5,535 shift and add the way convolution outputs do, which is why the schoolroom method and the convolution formula feel like cousins. The calculator keeps the sequence view instead of the digit view, but the products involved are identical.
Frequently asked questions
What is convolution in simple terms?
It is a flip, a slide, and a sum of products. Convolving 1, 2, 3 with 4, 5 gives 4, 13, 22, 15, where each output multiplies the aligned pairs and adds them.
How do I calculate a convolution by hand?
Flip the second sequence, slide it across the first, and add the products at each position. For 1, 2, 3 against 4, 5, the second output is 1 x 5 + 2 x 4 = 13.
What is the convolution of (1, 2) and (3, 4)?
3, 10, 8. The outputs are 1 x 3 = 3, then 1 x 4 + 2 x 3 = 10, then 2 x 4 = 8.
How long is the result of a convolution?
An input of length n against length m returns n + m - 1 outputs. Lengths 3 and 5 give 7 outputs, and two length-2 inputs give 3.
Does the order of the two sequences matter?
No. Convolving 1, 2, 3 with 4, 5 gives 4, 13, 22, 15 either way, because the same six products appear in both directions.
Why do I flip one of the sequences?
The flip is the definition, and it matches how systems respond over time. Skipping it gives cross-correlation instead: (1, 2) against (3, 4) returns 11, 4 rather than 3, 10, 8.
What does convolving with (0, 1) do?
It shifts the sequence one place later. The sequence 5, 6, 7 becomes 0, 5, 6, 7, with a zero filling the vacated first slot.
How is convolution related to polynomial multiplication?
The coefficients match term for term. Multiplying (1 + 2x + 3x^2) by (4 + 5x) gives coefficients 4, 13, 22, 15, the same as convolving 1, 2, 3 with 4, 5.
Why is 7 the most likely total when rolling two dice?
More pairs add to 7 than to any other total, 6 out of 36, which is 16.7 percent. That pyramid of counts is the convolution of the face distribution with itself.
Can a convolution contain negative numbers or decimals?
Yes. Convolving 1, -2 with 1, 1, 1 gives 1, -1, -1, -2, and the calculator handles decimal entries the same way.
What is a moving average in convolution terms?
Convolving with 0.5, 0.5. The readings 10, 20, 30, 40 become 5, 15, 25, 35, 20, so each output averages a pair of neighbors.
What do the outputs of a convolution add up to?
The product of the input sums. Here (1 + 2 + 3) x (4 + 5) = 6 x 9 = 54, and the outputs 4 + 13 + 22 + 15 = 54 agree.
Is convolution the same as regular multiplication?
No. Multiplication combines two numbers into one, while convolution combines two sequences into a longer one. Long multiplication hides a convolution: the digits of 123 x 45 = 5,535 follow the same sliding products.
Does the calculator work for long sequences?
Yes. Paste any two sequences of numbers separated by spaces or commas, and it returns every output along with the length and sum checks.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.