Sei sulla pagina 1di 9

Difference Equations

Difference Equations

Andrew W. H. House

10 June 2004

1 The Basics of Difference Equations


Recall that in a previous section we saw that IIR systems cannot be evaluated using the con-
volution sum because it would require an infinite number of operations. We showed, however,
that sometimes difference equations can be used to evaluate/implement such systems.
Thus, an important class of DT LTI systems are those whose inputs/outputs satisfy linear
constant-coefficient (LCC) difference equations of the following form. Note that this is the
DT version of the LCC differential equation in CT.

a0 y(n) + a1 y(n − 1) + a2 y(n − 2) + . . . + aN y(n − N )


= b0 x(n) + b1 x(n − 1) + b2 x(n − 2) + . . . + bN x(n − N )

To solve this general difference equation, we need N initial conditions.


Now, if we wish to solve the above equation causally, for example, we must rewrite it to
focus on the current output, y(n).

b0 b1 b2 bN
y(n) = x(n) + x(n − 1) + x(n − 2) + . . . + x(n − N )
a0 a0 a0 a0
a1 a2 aN
− y(n − 1) − y(n − 2) − . . . − y(n − N )
a0 a0 a0

Suppose x(n) = u(n), so we start calculating y(n) at n = 1, 2, 3, . . . . To do this, we need N


initial conditions: y(−1), y(−2), . . . y(−N ).
If the equation under consideration is to represent a strictly LTI system, the initial conditions
(I.C.’s) must be zero [y(−1) = y(−2) = . . . = y(−N ) = 0] and must float with the input.

ENGI 7824 – Discrete-Time Systems and Signals 1


Difference Equations

This last condition means that if, say, x(n) = u(n − 12), then we start y(n) at n = 12, 13, 14,
. . . so we need [y(11) = y(10) = . . . = y(12 − N ) = 0].
We can encapsulate this requirement with the initial rest condition.
Definition of IR (initial rest): If x(n) = 0 for n < no , then y(n) = 0 for n < no . (Note that
IR only describes causal systems).

1.1 Whence Difference Equations

Where do difference equations come from? There are a number of possible sources.
1. Difference equations can be exact models of DT systems.

Example 1.1: Interest-Bearing Bank Account

y(n) = 1.αy(n − 1) + x(n)

A bank account could be considered a naturally discrete system. In the


above equation, y(n) is today’s balance, y(n − 1) is yesterday’s balance, α is
the interest rate, and x(n) is the current day’s net deposit/withdrawal.

2. Difference equations can be approximations of CT differential equations.


We can sample signals in a CT differential equation, as shown in the following example.

Example 1.2: Sampling a CT Differential Equation


Consider a CT differential equation,

y 00 (t) + 2y 0 (t) + y(t) = x(t) − x0 (t) , IR

and suppose we sample,

xd (n) = x(t)|t=nT , yd (n) = y(t)|t=nT , T >0

then what difference equation can process these signals?


Recall in CT,
y(t) − y(t − ∆t)
y 0 (t) = lim
∆t→0 ∆t
and so define
yd0 (n) = y 0 (t)|t=nT

ENGI 7824 – Discrete-Time Systems and Signals 2


Difference Equations

which leads to the following approximation of yd0 (n).

yd (n) − yc (n − 1)
yd0 (n) ∼
=
T
Similarly, we can find yd00 (n) using yd0 (n) as the basis.

y 0 (n) − yc0 (n − 1)
yd00 (n) ∼
= d
T
We can likewise also find x0 (n) from x(t) and x0 (t). Substituting the DT
values into our CT equation, we get the following overall difference equation
for the DT system.

 
yd (n) − 2yd (n − 1) + yd (n − 2) yd (n) − yd (n − 1)
+2 + yd (n)
T2 T
xd (n) − xd (n − 1)
= xd (n) − , IR
T

We can group the like terms to get a more proper-looking difference equation.
   
1 2 2 1 2
yd (n − 2) − + 2 yd (n − 1) + + + 1 yd (n)
T2 T T T2 T
 
1 1
= 1+ xd (n) + xd (n − 1) , IR
T T

3. Difference equations can be designed to produce desired effects in DT.


In other words, the difference equation can be used to implement the system.

1.2 Sample Difference Equations

Let’s look at some sample difference equations.


1. y(n) = x(n − 5) is a pure delay system. Here, a0 = 1, b5 = 1, and all other values
ak , bk = 0.
2. y(n) = x(n) − x(n − 1) is a differencer. In this case, a0 = b0 = b1 = 1 and all other
values ak , bk = 0.
Both of these cases are non-recursive difference equations, since the only appearing
value of the output is the current y(n).

ENGI 7824 – Discrete-Time Systems and Signals 3


Difference Equations

3. The system
n
X
y(n) = x(k)
k=−∞

is an accumulator. We can rewrite this as a difference equation that is recursive on


y(n).
Xn n−1
X
y(n) = x(k) = x(n) + x(k) = x(n) + y(n − 1)
k=−∞ k=−∞

So y(n) − y(n − 1) = x(n), IR. As we said, this is clearly recursive on y(n).


4. We have seen the system
n  n−k  n
X 1 1
y(n) = x(k) = x(n) ∗ u(n)
k=−∞
2 2

and shown that it can be written as a difference equation.


n  n−k
X 1
y(n) = x(k)
k=−∞
2
n−1  n−k
X 1
= x(n) + x(k)
k=−∞
2
n−1  n−k−1
1 X 1
= x(n) + x(k)
2 k=−∞ 2
1
= x(n) + y(n − 1)
2
So y(n)− 12 y(n−1) = x(n), IR. This is a recursive difference equation that is equivalent
to the convolution sum.

2 Using Difference Equations


What can we do with difference equations?
1. We can implement DT LTI systems. (This is illustrated in the handout and in the
next section).
2. We can get the difference equation from the h(n) of a DT LTI system, so the difference
equation is equivalent the convolution sum and can be used to evaluate convolution.
For example, if  n
1
h(n) = u(n)
2

ENGI 7824 – Discrete-Time Systems and Signals 4


Difference Equations

then we can write it as a difference equation


n  n−k
X 1 1
x(n) −→ h(n) −→ y(n) = x(k) = x(n) + y(n − 1) , IR
k=−∞
2 2

so
1
y(n) = x(n) + y(n − 1) , IR
2
and we can implement the difference equation.
3. We can solve difference equations for a given x(n), either in time (recursively or via
formal methods like the CT differential equation) or in frequency (which we’ll cover
later). The recursive solution is an actual system implementation.

Example 2.1: Solution of Difference Equations


Consider the following system.
1
y(n) − y(n − 1) = x(n) , IR
2

We want to find y(n) if x(n) = u(n).


The first step is to write the equation causally.
1
y(n) = x(n) + y(n − 1) , IR
2

The IR condition means that y(n) = 0 for n < 0.


So, we can evaluate recursively from n = 0.
1
y(0) = x(0) + 21 y(0 − 1) = 1 + ·0=1
2
1 3
y(1) = x(1) + 12 y(1 − 1) = 1 + ·1=
2 2
1 3 7
y(2) = x(2) + 12 y(2 − 1) = 1 + · =
2 2 4
1 7 15
y(3) = x(3) + 12 y(3 − 1) = 1 + · =
2 4 8
.. .. ..
. . .

We notice a trend in the values, so we can express the output as follows.


  n 
1
y(n) = 2 − u(n) u(n) = s(n) This is the step response.
2

ENGI 7824 – Discrete-Time Systems and Signals 5


Difference Equations

Let’s try this for x(n) = δ(n). Again, evaluating recursively from n = 0.
1
y(0) = x(0) + 12 y(0 − 1) = 1 + ·0=1
2
1 1 1
y(1) = x(1) + 2 y(1 − 1) = 0 + ·1=
2 2
1 1 1 1
y(2) = x(2) + 2 y(2 − 1) = 0 + · =
2 2 4
1 1 1 1
y(3) = x(3) + 2 y(3 − 1) = 0 + · =
2 4 8
.. .. ..
. . .
Not surprisingly, we see a trend here, and as expected, this output is the impulse
response of the system.
 n
1
y(n) = h(n) = u(n)
2

This means of solution will work for any input x(n). Consider the following x(n).

We see that x(n) = 0 for n < 1, so y(n) = 0 for n < 1 due to IR condition. We
evaluate recursively from n = 1.
1
y(1) = x(1) + 12 y(1 − 1) = 1 + · 0 = 1
2
1 5
y(2) = x(2) + 12 y(2 − 1) = 2 + · 1 =
2 2
1 5 9
y(3) = x(3) + 12 y(3 − 1) = 1 + · =
2 2 4
1 9 1
y(4) = x(4) + 12 y(4 − 1) = −1 + · =
2 4 8
1 1 17
y(5) = x(5) + 12 y(5 − 1) = 1 + · =
2 8 16
1 17 17
y(6) = x(6) + 12 y(6 − 1) = 0 + · =
2 16 32
1 17 17
y(7) = x(7) + 12 y(7 − 1) = 0 + · =
2 32 64
.. .. ..
. . .

ENGI 7824 – Discrete-Time Systems and Signals 6


Difference Equations

There is no overall form to represent this output, but we can see that y(n) for
n > 7 are going to follow the trend of 17/2n−1 that was apparent since n = 5.
We can plot y(n), shown below.

So this recursive method of solutions works for any x(n) so long as we have IR,
and is easily implementable in software or hardware.

3 Graphical Representation of Difference Equations


Note: This material summarizes the handout.
We can represent the general form of LCC difference equations as
N
X N
X
ak y(n − k) = bk x(n − k)
k=0 k=0

where ak , bk are scalars.


Clearly, there are only three operations involved: multiplication by a scalar, addition, and
shifting in time. Shifting in time is done via the unit delay component. We can represent
these graphically, shown below.

ENGI 7824 – Discrete-Time Systems and Signals 7


Difference Equations

That means we have an easy way to visualize difference equations. Furthermore, this graph-
ical representation lends itself to analysis.
Say we had the difference equation

y(n) = x(n) + 2x(n − 1) − 3y(n − 1) , IR

which is represented graphically as shown below. (Note that we can group the input terms
and can represent them as w(n)).

We can swap the two halves of the graphical representation,

and then we can combine the unit delays to reduce the storage requirements of the imple-
mentation. This, this form of graphical analysis provides tools and techniques allowing more
efficient implementation.

ENGI 7824 – Discrete-Time Systems and Signals 8


Difference Equations

There is some question as to why this swapping of halves of the difference equation imple-
mentation can work. We can consider this in the context of the above sample difference
equation.
We already stated that
y(n) = w(n) − 3y(n − 1) , IR where w(n) = x(n) + 2x(n − 1)
for our initial graphical representation.
For our swapped and reduced version, we have a different intermediate signal, z(n), and we
see the following relationships.
z(n) = x(n) − 3z(n − 1)
y(n) = z(n) + 2z(n − 1)
This y(n) does not look much like our originally defined y(n). However, if we substitute the
value of z(n) into this new equation for y(n) for both z(n) and z(n − 1) we see the following.
y(n) = z(n) + 2z(n − 1)
= [x(n) − 3z(n − 1)] + 2 [x(n − 1) − 3z(n − 2)]
= x(n) − 3z(n − 1) + 2x(n − 1) − 6z(n − 2)
= x(n) + 2x(n − 1) − 3z(n − 1) − 6z(n − 2)
= x(n) + 2x(n − 1) − 3 [z(n − 1) + 2z(n − 2)]
= x(n) + 2x(n − 1) − 3y(n − 1) if we consider y(n) in terms of z(n)
Thus, the new form of the difference equation is still equivalent to the original, but has
allowed us to remove one of the unit delay components and thus provide a more efficient
implementation. This sort of optimization would be difficult to find without using these
graphical techniques.
Signals and Systems, 2E: Chapter 2.4.2–2.4.3, page(s) 121–127.
Signal Processing First: Chapter 5-2, page(s) 103.

ENGI 7824 – Discrete-Time Systems and Signals 9

Potrebbero piacerti anche