Chapter04 Convolution
Chapter04 Convolution
4.1 Introduction
Convolution is one of the major concepts of linear time-invariant system theory. Convolution relates an LTIs system's input to its
output thus it is a mathematical operation of fundamental importance in the theory of signals and systems. Convolution yields the
output of a relaxed (zero initial conditions) LTI system, given the input xn and the system's impulse response hn. A system's
impulse response is a unique property of the system that completely characterizes its dynamic behavior (under the assumption of
linearity). The impulse response, as the name suggests, is the output of a system given a unit impulse (sample) input.
ht = dt
response of the system is the output to a unit impulse input.
(4.1)
For example, if the system is the RC filter, then it is well-known that the output voltage measured aross the capacitor resulting from
a unit impulse input at the source takes the form of a decaying exponential. The impulse response of an RC filter with R = C = 1
and zero initial conditions is therefore:
ht = ‰-t ut
xt =
¶
xt dt - t „ t (4.2)
-¶
Using the fact that xt is independent of, or constant with respect to the system , we get
yt =
¶
xt ht - t „ t (4.5)
-¶
2 Chapter04_Convolution.nb
This last result shows that the output of any LTI system may be obtained by evaluating the integral in Eq. (1.4) given an input and
the impulse response of the system. The integral in Eq. (1.5) is known as the convolution integral. Convolution is then the opera-
tion of computing this integral for two signal, the input signal xt and the impulse response signal ht. Convolution is frequently
denoted by the symbol * as in yt = xt * ht. Convolution is known to satisfy the commutative, associative, and distributive laws
of algebra therefore xt * ht = ht * xt and therefore the convolution integral may be written in the following two equivalent ways.
The output of an LTI system at time t is the area of the intersection of the input with a time shifted and reversed copy of the
impulse response (or vice versa). Clearly, evaluating thi integral may be difficult, unless the signals xt and ht are “nice”, simple
functions. The simplest possible convolution problem involves two signals that are ideal pulses. This problem can be easily solved
by hand calculation. Here I define signals xt and ht as pulses of width 2 and 1, respectively.
In[9]:= Clearx, h, y;
xt_ : Piecewise1, 0 t 2;
ht_ : Piecewise1, 0 t 1;
xt ht
1.0 1.0
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
-2 -1 1 2 3 4 -2 -1 1 2 3 4
It is typical to use a “divide-and-conquer” approach with the region of integration broken up into non-overlapping subregions. The
sum of the individual solutions in each of the subregions gives the total solution. The following plots will illustrate the mechanics of
evaluating equation (4.6).
This shows the shifted and reflected signal ht across the domain of the signal xt. In the first example, the two signals do not
overlap and therefore (1.6) evaluates to zero.
1.0
0.8
0.6
0.4
0.2
t
-4 -2 0 2 4
yt_ : 0 ; t 0
As the signal ht - t shifts to the right, it will begin to overlap signal xt. What is the value of t at which the two signals "touch"
each other?
Chapter04_Convolution.nb 3
1
t
t
Therefore, we define the output signal as
yt_ : t ; 0 t 1
Continuing to shift to the right, signal ht enters a region in which it is completely overlapped by signal xt. Clearly, at this stage
the integral evaluates to a constant value of 1 (find the area inside the red rectangle).
Thus,
yt_ : 1 ; 1 t 2
Continuing, a partial overlap occurs involving the trailing edge of ht.
4 Chapter04_Convolution.nb
2
1
t1
3t
and
yt_ : 3 t ; 2 t 3
Finally, ht shifts beyond the leading edge of xt. Since the two signals do not overlap, the integral is again zero.
1.0
0.8
0.6
0.4
0.2
-2 -1 0 1 2 3 4
yt_ : 0 ; t 3
Having defined the output yt for all values of t, we plot the result.
Plotyt, t, 2, 6, Exclusions None, ImageSize Small
1.0
0.8
0.6
0.4
0.2
-2 2 4 6
The derivation shown above describes the traditional manual method of evaluating the convolution integral using paper-and-
pencil. Here, however, is the evaluation using Mathematica’s Integrate function.
Chapter04_Convolution.nb 5
In[16]:= Cleary;
Out[17]//OutputForm=
Piecewise[{{1, 1 < t <= 2}, {3 - t, 2 < t < 3}, {t, 0 < t <= 1}}]
Finally, here is an interactive demonstration of the convolution operation on the two pulses defined in the preceding example.
Here is a demonstration showing the response of the RC circuit to a sinusoidal source. Recall that the impulse response of the RC
circuit, the voltage across the capacitor is a decaying exponential, ht = ‰-t ut.
1. Obtain the output of an LTI system defined by the impulse response ht = ‰-t ut to a pulse input of duration 2 seconds, starting at time
t = 0.
2. Obtain the output of an LTI system defined by the impulse response ht = ‰-t ut to the sinusoidal source xt = sint ut, as
Verify your result by comparing to the solution of the differential equation y ' t + yt == sint ut with zero initial condition (y0 = 0).
demonstrated above, by identifying the relevant solution regions, writing and solving the defining convolution integrals for each of them.
6 Chapter04_Convolution.nb
(4.7)
k=-¶ k=-¶
where hn is the so-called impulse response, xn the input and yn the output of a discrete-time LTI system. Convolution
satisfies the commutative, associative and distributive laws of algebra. These formulas can be easily derived. Consider an
arbitrary input signal as a superposition of scaled and shifted unit samples.
xn = ... + x-1 dn + 1 + x0 dn + x1 dn - 1 + x2 dn - 2 + ... = xk dn - k
¶
(4.8)
k=-¶
Now, the system response to a unit sample input is the sequence hn, namely, dn Ø hn. In a linear, time-invariant system, the
output of the system to input xn must be a superposition of the responses to each of the scaled and time-shifted impulses in
(2.2). We therefore get the following convolution formula.
yn = ... + x-1 hn + 1 + x0 hn + x1 hn - 1 + x2 hn - 2 + ... = xk hn - k
¶
(4.9)
k=-¶
As an example, consider the evaluation of the output of an LTI system with the impulse response and input shown below.
1, n = 0
hn = - 1, n = 1
0, otherwise
1, n = 0
2, n = 1, 2
xn =
-1, n = 3
0, otherwise
The output yn, by virtue of linearity and shift-invariance, is given by the following sum of scaled and shifted impulse responses.
yn = hn + 2 hn - 1 + 2 hn - 2 - hn - 3
Substitution of the algebraic formula for the impulse response yields the following summation.
dn -dn - 1
+
2 dn - 1 -2 dn - 2
yn = +
2 dn - 2 -2 dn - 3
+
- dn - 3 dn - 4
Simplifying, we get the following output signal.
yn = dn + dn - 1 - 3 dn - 3 + dn - 4
Here is an interactive presentation of the flip-and-slide method of evaluating a discrete-time convolution. Observe how the impulse
response h slides across the sequence of numbers x. At each position n the sum of products of the two sequences is shown
confirming the result previously derived using an algebraic approach.
Chapter04_Convolution.nb 7
0 1 2 2 1 0
1 1
1 1 0
2
0, otherwise
Determine the output of this system in response to the input
1, n = 0
xn =
2, n = 1, 2
-1, n = 3
0, otherwise
Here is a second example of convolving two numerical sequences using (1.7):
hn = un
2 n
3
and
xn =
1, 0§ n§ 9
0, else
This defines the two sequences.
In[21]:= Clearh, x
2 n
In[22]:= hn_ : UnitStepn;
3
xn_ : UnitStepn UnitStepn 10;
This example illustrate the so-called "flip-and-slide" operation which arises naturally as a consequence of formula (1.7). For each
value of n, the sum of the point-by-point products of the two sequences is evaluated yielding a single output value. When evalu-
ated for all values of n, we get the result shown below. An examination of the regions of support of the two sequences reveals that
there are three disjoint, but contiguous regions we need to consider when evaluating the convolution sum.
Region 1. For n < 0 there is no overlap between hm (blue) and xn - m (red).
n
8 Chapter04_Convolution.nb
So the result is
yn = 0, for n < 0
Region 2. For 0 § n < 9 there is a partial overlap between hm and xn - m.
hm OutputForm
n
In[24]:=
m0
Out[24]//OutputForm=
1 + n 1 + n
2 - 3
Piecewise[{{1, n == 0}}, -(---------------)]
--------------
n
3
1-
nm=0 =3-2
2 n+1
2 m 2 n
yn = =
3
3 2 3
1-
3
Region 3. For n ¥ 9 we have full overlap between xm and hn - m.
hm Simplify
n
Using a formula for the finite sum we obtain the following result for n ¥ 9 :
-
yn = nm=n-9
2 n-9 2 n+1
2 m 58 025 2 n
= =
3 3
3 2 512 3
1-
3
Putting together the results for all three regions we get the following piecewise function:
, 0 n 9,
2 n 58 025 2 n
yn_ : Piecewise3 2 , n 9;
3 512 3
This shows the result.
This result can be confirmed by evaluating the convolution sum directly in Mathematica:
In[25]:= DiscreteConvolvexm, hm, m, n Simplify OutputForm
Out[25]//OutputForm=
-9 + n 1 + n
58025 2 2
Piecewise[{{-------------,
------------ n >= 10}}, 3 - ------]
-----
n n
3 3
4. Repeat the convolution calculation for the sequences in (2.4) by flipping-and-sliding sequence hn.
FIR filters
An important category of discrete-time systems exhibits a finite impulse response (FIR), so hn has finite support. It is common to
define hn on the interval 0 § n § Lh - 1. Sequence hn is then called a causal FIR filter of length Lh . In practice, the sequence
xn is also finite in length, so that yn can be computed in finite time. Consider two sequences xn and hn, defined for positive
values of n only, of length Lx and Lh , respectively. Equation (1.7) then reduces to the following finite summation:
with the output sequence yn supported on the finite domain 0 § n < Lx + Lh - 1. It is instructive to evaluate the sum for all
values of n in this domain. Begin by defining the sequences and their lengths.
10 Chapter04_Convolution.nb
Clearx, h, y;
Lx 8; Lh 3;
xn_ : 0 ; n 0 n Lx ;
hn_ : 0 ; n 0 n Lh ;
Here is a Mathematica implementation of (1.10).
i0
5. How many non-zero output values result from convolving sequences xn and hn in preceding example? How many multiplication and
addition operations are needed to obtain a single output value? All the output values?
Now, use the built-in convolution operator ListConvolve to obtain the result. By default only the steady-state values are
returned.
ListConvolveh, x
1, 0, 3
This returns all the non-zero values assuming zero-padding on both ends of the given lists of numbers.
ListConvolveh, x, 1, 1, 0
1, 1, 0, 3, 1
Example
As an example, we use convolution to smooth a noisy data sequence. The data values are monthly S&P 500 composite index
1000
500
A popular method of smoothing noisy data is to "locally" average the data. Such an operation may be conveniently expressed by
the following formula:
hn =
1
, for - N § n § N
2 N+1 (4.12)
0, otherwise
6. Verify (1.12) by evaluating (1.11) for a unit sample input, namely, xn = dn.
Thus the operation of smoothing signal xn may be implemented by convolving with impulse response hn. Here we show the
This gives output of the moving average filter using the built-in function ListConvolve.
smooth ListConvolvefir, data;
This plots the smoothed data. By default, Mathematica returns the steady-state values of the convolution sum.
12 Chapter04_Convolution.nb
This returns both the steady-state and transient samples for different lengths of moving average filter given by the parameter n.
filter length, n
1400
1200
1000
800
600
400
200
7. Discuss how the number of steady-state and transient samples changes with length of moving average filter.
Equation (4.13) illustrates a fundamental property of the unit impulse, namely that it is an identity element of convolution. This
property also holds for discrete convolution.
It is also of interest to obtain formulas for the step response of a system, given that its impulse response is known. In the case of
continuous-time systems we get
We can now use the result derived in (1.15) to find the step response of a system with ht = ‰-t ut. We get the following well-
known result.
yt = ht - t „ t = = ‰-t-t ut - t „ t = ‰-t-t „ t = ‰-t ‰ t „ t = ‰-t ‰ t t0 = ‰-t ‰t - 1 = 1 - ‰-t .
¶ ¶ t t
0 0 0 0
This shows a graphical interpretation of the result derived in Equation (1.15). The impulse response ht = ‰-t ut is used.
Chapter04_Convolution.nb 13
8. Obtain the step response of a system with impulse response given by ht = 1 - t ut - ut - 1.
Following similar steps as in Equaton (1.15), here is the step response of a discrete-time system given its impulse (unit sample)
response.
Using (1.16) we now find the step response of a system with hn = un.
2 n
3
4.5 Solutions