Discrete Convolution Calculator: x(t) * h(t)
Calculate the output of the convolution between two discrete-time signals, often denoted as y[n] = x[n] * h[n].
Convolution Calculator
What is Convolution?
Convolution, denoted by an asterisk (*), is a mathematical operation on two functions (f and g) that produces a third function expressing how the shape of one is modified by the other. The term convolution refers to both the result function and to the process of computing it. For discrete signals like the ones in this calculator, it’s a “fancy multiplication” that calculates a weighted sum of one signal’s past values, where the weights are determined by the second signal.
Imagine one signal, h[n], is a “filter” or “kernel”. Convolution “slides” this filter over the other signal, x[n], and at each point, it calculates the sum of the products of the overlapping elements. This process is fundamental in digital signal processing, image processing, and the study of Linear Time-Invariant (LTI) systems.
The Discrete Convolution Formula
To calculate the output using convolution for discrete signals x[n] and h[n], we use the following summation formula:
y[n] = (x * h)[n] = ∑k=-∞∞ x[k] · h[n - k]
This formula essentially says that the n-th value of the output signal, y[n], is found by flipping one signal (h[k] becomes h[-k]), shifting it by n positions, and then summing the products of the overlapping elements with the other signal, x[k].
| Variable | Meaning | Unit | Typical Range |
|---|---|---|---|
y[n] |
The output signal at index n. | Unitless (or product of input units) | Calculated value |
x[k] |
The input signal at index k. | Unitless | User-defined |
h[n-k] |
The value of the second signal (impulse response), flipped and shifted by n. | Unitless | User-defined |
n |
The index of the output signal being calculated. | Integer | From 0 to (length of x + length of h – 2) |
Practical Examples
Example 1: Simple Averaging Filter
Let’s say our input signal is x[n] = {1, 2, 6, 2, 1} and our filter is a simple two-point averaging kernel h[n] = {0.5, 0.5}. The convolution will smooth the input signal.
- Inputs:
x[n] = {1, 2, 6, 2, 1},h[n] = {0.5, 0.5} - Units: Unitless
- Result:
y[n] = {0.5, 1.5, 4, 4, 1.5, 0.5}. Notice how the sharp peak of ‘6’ is smoothed down to ‘4’.
Example 2: Echo Effect
Convolution can create echoes. If x[n] is an impulse representing a sound, and h[n] represents the original sound plus a delayed, quieter version, the result is an echo.
- Inputs:
x[n] = {1, 0, 0, 0, 0}(an impulse),h[n] = {1, 0, 0.5}(original sound and an echo at half volume) - Units: Unitless
- Result:
y[n] = {1, 0, 0.5, 0, 0}. The output shows the original impulse and a second, smaller impulse, which is the echo. Check out this Fourier Analysis guide to see how this relates to frequency components.
How to Use This Convolution Calculator
- Enter Input Signal x[n]: In the first input field, type your first sequence of numbers, separated by commas. This could be your raw data or input signal.
- Enter Signal h[n]: In the second field, enter your second sequence. This is often an impulse response, filter, or kernel you want to apply to x[n].
- Calculate: Click the “Calculate Convolution” button.
- Interpret Results: The primary result is the convolved output signal
y[n]. The intermediate values show the lengths of your input and output signals. - Visualize: The chart plots your two input signals and the resulting output signal, making it easy to see the effect of the convolution, like smoothing or shifting. More details on signal visualization can be found in our article about Z-Transforms.
Key Factors That Affect Convolution
- Signal Length: The length of the output signal is
length(x) + length(h) - 1. Longer signals result in a longer output. - Signal Shape (Kernel): The shape of
h[n]is critical. A flat kernel (like{0.5, 0.5}) acts as a smoothing filter, while a kernel with gaps (like{1, 0, 0.5}) can create echoes or shifts. - Amplitude of Values: The magnitude of the numbers in both signals directly scales the output. Doubling the values in
x[n]will double the values iny[n]. - Zero-Padding: While this calculator handles it automatically, the concept of padding signals with zeros is crucial for ensuring the filter can fully “slide” over the entire input signal.
- Commutativity: The order of convolution does not matter:
x[n] * h[n]is the same ash[n] * x[n]. This property is useful in many Digital Filtering applications. - Impulse Signal: Convolving any signal
x[n]with a perfect impulse (a single 1, e.g.,h[n] = {1}) results in the original signalx[n].
Frequently Asked Questions (FAQ)
- 1. What does it mean to “calculate the output using convolution x t h t”?
- This is a common way to phrase the operation, asking to find the output of a system by convolving an input signal x(t) with the system’s impulse response h(t). Our calculator does this for discrete signals x[n] and h[n].
- 2. Are the inputs and outputs unitless?
- In this calculator, yes. The inputs are treated as raw numerical sequences. In a real-world scenario (e.g., physics or engineering), if x[n] had units of Volts and h[n] was unitless, the output y[n] would also be in Volts.
- 3. What happens if I enter non-numeric text?
- The calculator’s script will attempt to parse numbers and will treat any non-numeric entries (like ‘abc’) as zero to prevent errors.
- 4. Why is the output signal longer than the input signals?
- The output length is
len(x) + len(h) - 1because the convolution operation computes values for every position where the two signals can overlap, from the moment they first touch to the moment they last touch as one “slides” past the other. - 5. What is the difference between convolution and correlation?
- They are very similar operations. The main difference is that for convolution, one of the signals is flipped (
h[n-k]) before the multiplication and summation, while for correlation, it is not flipped. - 6. How is convolution used in image processing?
- In image processing, a 2D convolution is used. A small matrix called a kernel (like h[n]) is convolved with an image (like x[n]) to achieve effects like blurring, sharpening, and edge detection. You can learn more with our Image Processing Kernels tool.
- 7. Can I use this for continuous functions?
- This calculator is specifically for discrete signals (sequences of numbers). Continuous convolution requires solving a definite integral, which is a different mathematical process.
- 8. What is a “system’s impulse response”?
- It’s the output of a system when the input is a perfect, instantaneous spike called an impulse. It fully characterizes a Linear Time-Invariant (LTI) system, and convolving it with any input signal reveals how the system will respond to that input. This is a core concept in System Impulse Response theory.
Related Tools and Internal Resources
Explore these related topics for a deeper understanding of signal processing and mathematical transforms:
- Fourier Analysis Explained: Understand how signals can be decomposed into frequencies.
- Z-Transform Calculator: A powerful tool for analyzing discrete-time signals in the frequency domain.
- A Guide to Digital Filtering: Learn how convolution is used to create low-pass, high-pass, and other filters.
- Image Processing Kernels Explorer: An interactive tool to see 2D convolution in action.
- Understanding System Impulse Response: A deep dive into the importance of h(t).
- Laplace Transform Calculator: The continuous-time equivalent of the Z-Transform.