calculator.onl
Categories50

Discrete convolution calculator

Calculate linear or circular convolution with explicit starting indices and inspect the products that contribute to an output sample.

A worked example

Move the reading head to another output sample and follow the products in the sum.

y[n]0, 1, 2.5, 4, 1.5Σ (n₀ + p)(1 × 0) = 0n₀0n₁4
n

x[k]

h[k]

k₀ (x) · -10000 … 10000

k₀ (h) · -10000 … 10000

p (n₀ + p) · 0 … 127

Updates as you type

Use a dot or comma for decimals. No thousands separators.

YOUR RESULT

y[n]

0, 1, 2.5, 4, 1.5

Calculated from your inputs

n₀0
n₁4
Σ (n₀ + p)(1 × 0) = 0
The numbers, at a glance

Calculations run in your browser.
UNDERSTAND THE RESULT

A little context. A clearer answer.

↑ Back to calculator

When this calculator is useful

Doubling every coefficient in the second sequence doubles its contribution at every output position in this linear convolution. Change “h[k]” from 0, 1, 0.5 to 0, 2, 1 and keep the other inputs from the worked example. The value for “y[n]” goes from 0, 1, 2.5, 4, 1.5 to 0, 2, 5, 8, 3. For a related calculation, try Matrix calculator.

A single click in a recording may produce a direct sound followed by an echo two samples later. If the recording contains several clicks, each click creates its own copy of the same response. Their copies add wherever they coincide. This is a practical way to understand discrete linear convolution. Enter the signal in the first box and the response to one unit impulse in the second. Both lists advance one sample per entry. Set a starting index for each list if either one includes time before your chosen origin.

Consider a signal with amplitudes two, one and zero, and an echo response with amplitudes one, zero and one half. The initial two produces a direct two and a delayed one. The following one produces a direct one and a delayed one half. The resulting five samples are two, one, one, one half and zero. Keeping the final zero records the endpoint implied by the two input lists. Removing silent endpoints is a separate editing decision, which may also change the index associated with the first displayed sample.

To check a particular index n, select one value from the signal at position k and one from the response at n minus k. Multiply the pair and add all such products. Missing values beyond either list are treated as zero. You can do the same work with a small grid on paper. Write signal values along the top and response values down the side. Fill each cell with a product. The cells on each diagonal contribute to one output position, which explains both the overlapping sums and the length of the result.

If the first input starts at index minus two and the second at index one, the earliest output occurs at minus one. A three-sample signal starting at minus two ends at zero. A two-sample response starting at one ends at two. Their output therefore runs from minus one through two inclusive. Moving an entire sequence one step later also moves its contribution to every sum one step later. Changing the origin alone leaves the output amplitudes unchanged. Compare the index limits before comparing two published answers.

Use a unit impulse as a quick check. Convolving any list with a single one at index zero returns that list. Replacing the one with a two doubles its amplitudes. A two-point averaging response of one half followed by one half spreads each isolated unit of input over two adjacent positions. Only part of that averaging window overlaps the input at the extreme ends. Those edge samples belong to the full convolution and are included in the output even if a later analysis crops them.

The graph traces discrete output values in their chronological order, including their signs. For a smoothing response it can show where short changes spread over neighbouring sample positions. For an alternating response it reveals cancellations hidden in the individual inputs. The full numeric list lets you check smaller values that share a vertical scale with a much larger peak. This calculator accepts short real-valued sequences and uses zero extension. For a repeating cycle choose the modulo N option. It folds contributions whose indices differ by a multiple of N onto the same position. With period three the five terms in the worked example fold into three bins: four, two and a half, and two and a half. Enter p to inspect up to eight products at offset p from the first output. The expression displays an ellipsis when further terms contributed.

What to enter

InputWhat it meansExample value
nnn ∈ ℤ
x[k]x[k]1, 2, 3
h[k]h[k]0, 1, 0.5
k₀ (x)k₀ (x) · -10000 … 100000
k₀ (h)k₀ (h) · -10000 … 100000
N (mod N)N (mod N) · 1 … 128—
p (n₀ + p)p (n₀ + p) · 0 … 1270

How the calculation works

  1. Calculate linear or circular convolution with explicit starting indices and inspect the products that contribute to an output sample.
  2. y[k] = Σⱼ x[j]h[k−j]
  3. The full convolution of [1, 2, 3] with [0, 1, 0.5] is [0, 1, 2.5, 4, 1.5]. At index two, the products are 1 × 0.5, 2 × 1 and 3 × 0.
The formulay[k] = Σⱼ x[j]h[k−j]

A worked example

The full convolution of [1, 2, 3] with [0, 1, 0.5] is [0, 1, 2.5, 4, 1.5]. At index two, the products are 1 × 0.5, 2 × 1 and 3 × 0.

Example you can load

What to enter
Result for this example · y[n]0, 1, 2.5, 4, 1.5

This is a fixed example; changing the form above does not change these numbers.

Worked comparisons

Start with these reference inputs — n = n ∈ ℤ, x[k] = 1, 2, 3, h[k] = 0, 1, 0.5, k₀ (x) = 0, k₀ (h) = 0, N (mod N) = 3, p (n₀ + p) = 0. The corresponding results, in the order shown on the form, are — y[n] = 0, 1, 2.5, 4, 1.5, n₀ = 0, n₁ = 4, Σ (n₀ + p) = (1 × 0) = 0. Each example starts again from the reference inputs. The arrows show exactly which entries to change. All other entries keep their original values.

Case 1. Change one setting or the indicated combination to reproduce this case — x[k] 1, 2, 3 → 2, 1, 0, h[k] 0, 1, 0.5 → 1, 0, 0.5, k₀ (x) 0 → -2, k₀ (h) 0 → 1, p (n₀ + p) 0 → 2. Read the following results — y[n] = 2, 1, 1, 0.5, 0, n₀ = -1, n₁ = 3, Σ (n₀ + p) = (2 × 0.5) + (1 × 0) + (0 × 1) = 1.

Case 2. For the second comparison, restore the reference settings first, then enter — n n ∈ ℤ → n mod N, N (mod N) 3 → 3, p (n₀ + p) 0 → 1. Compare the new answers with the reference result above — y[n] = 4, 2.5, 2.5, n₀ = 0, n₁ = 2, Σ (n₀ + p) = (1 × 1) + (2 × 0) + (3 × 0.5) = 2.5.

Case 3. For a third check use the following changes — n n ∈ ℤ → n ∈ ℤ, x[k] 1, 2, 3 → 3, 3, 3, h[k] 0, 1, 0.5 → 1, -1, p (n₀ + p) 0 → 2. The calculation now gives — y[n] = 3, 0, 0, -3, n₀ = 0, n₁ = 3, Σ (n₀ + p) = (3 × -1) + (3 × 1) = 0.

Case 4. For the last case enter — n n ∈ ℤ → n mod N, x[k] 1, 2, 3 → 1, -2, 4, h[k] 0, 1, 0.5 → 1, -1, N (mod N) 3 → 1. Read across the outputs to see which quantities changed and which stayed fixed — y[n] = 0, n₀ = 0, n₁ = 0, Σ (n₀ + p) = (1 × 1) + (1 × -1) + (-2 × 1) + (-2 × -1) + (4 × 1) + (4 × -1) = 0.

Assumptions & limits

Circular convolution wraps indices modulo N.

Frequently asked questions

How do I separate samples?

Use commas or spaces. Use a decimal point for fractional samples. Each input may contain one to thirty-two numbers.

Why is the result longer than either input?

The first pair contributes at the sum of the two starting indices. The last pair contributes at the sum of the two final indices. Every index between them is included.

What does changing the starting index do?

It shifts the output along the index axis by the same amount. The amplitudes stay the same.