Convolution is mathematically well understood, both in the continuous and discrete domains. There is a simple formula to comupte it. However, I recently needed to implement this in code and found that it was not all too easy. In this post, I tried to come up with a formula that can be used for programming convolution. In later posts about this, I will also try to analyze the computational complexity and spruce it up with some real working convolution code.

Firstly, what is discrete convolution? There is a straight-forward formula :

For generality we will assume that and are discrete functions (i.e. functions from the Integers to the Reals). For example, might be such that it is defined from to and it is zero outside. This is the most general representation for the signal. Similarly, let be defined on and zero outside. When we are asked to convolve these two signals, it is apparent that would play some role in the computation. However, MATLAB for example, does not care about these values. So, it is slightly confusing how convolution is carried out. Let us examine.

In the definition of convolution, what are the values of that are interesting? Before thinking about that, it is better to understand what values of are important for our considerations. Fix any and note that

- , because outside of this range, is zero and hence does not add to the convolution
- Similarly, which implies that

Clearly, if , the convolution is zero and we do not have to care about such an . Otherwise, one can immediately see that the interesting values of are :

Let us rewrite the formula again (for those such that ):

Now, what are the values for for which ? Consider, , then

When , and hence the convolution is zero. The upper limit on can similarly be found to be . Therefore, the full definition of convolution useful for computer implementation is:

Upon further thought, it can be easily seen that are not important for the *core* convolution. If the signal is replaced by and is replaced by there would no difference in the computation of the main convolution function. Only the range of for which the convolution is defined change. This is the primary reason why MATLAB does not care about these things.

### Like this:

Like Loading...

*Related*