11.2 Linear Constant-Coefficient Difference Equations
11.2 Linear Constant-Coefficient Difference Equations
This section demonstrates sequence generation and closed-form solutions to a second-order difference
equation. The difference equation is solved by z-transforming the equation and solving for the transform of
the solution sequence. You provide:
Background
For difference equations with constant coefficients, you can obtain the solution in closed form by
transforming the equation, and solving for the transform of the solution sequence. Then find the inverse
transform of the solution by expanding in partial fractions, as shown in Section 11.1: z-Transform and
Inverse Transform.
Given constants a, b and initial values s0, s1, Mathcad can generate the beginning of the difference sequence
by iteration. The range variable m starts at 2, so that m - 1 and m - 2 will be defined as index variables. Fig.
11.2.1 shows this calculated solution sequence, which has a sinusoidal appearance.
n ≔ 2 ‥ 100 i ≔ 0 ‥ 100
a ≔ −1 b ≔ 1.9
s ≔1 s ≔ −.1 s ≔b⋅s +a⋅s
0 1 n n−1 n−2
s
i
You can use z-transforms to obtain a solution in closed form. A closed form solution is often more useful,
since it allows you to find the amplitude at large n without calculating all the intermediate values, and shows
how the solution behaves over all time. First, transform the equation; shifting the sequence forward
corresponds to subtracting the first term of the sequence from the transform and multiplying by z. Thus Y, the
solution of the transform, satisfies the following equation:
a ⋅ Y + b ⋅ ⎛Y − s ⎞ ⋅ z = ⎛ ⎛Y − s ⎞ ⋅ z − s ⎞ ⋅ z
⎝ 0⎠ ⎝⎝ 0⎠ 1⎠ b = 1.9
Using the symbolic processor, we can solve for Y symbolically. Copy the above equation. Place the cursor
on the right side of the equation, and insert the symbolic keyword solve, then enter a comma, then enter Y.
Mathcad Ribbon: Symbolics panel: Keyword solve. Assign the solution for Y to a function of z.
where r is the radius of a circle in the complex plane that includes all the poles of F.
The inverse transform of Y gives the solution sequence. For example, the fifth term of the solution is
−15
x (5 , Y) = −3.379 + 6.432j ⋅ 10 s = −3.379
5
To find the corresponding time sequence in closed form, expand Y in partial fractions. The partial-fraction
expansion of Y depends on the roots of the denominator. If the discriminant
b ≔ 1.9
2
D ≔ b + 4 ⋅ a = −0.39
is nonzero, the denominator of Y has two distinct roots r1 and r2, and Y can be expanded in partial fractions
as follows:
⎛ ⎛ ⎞⎞
r1 ≔ .5 ⋅ ⎝b + if ⎝b > 0 , ‾‾
D , − ‾‾
D ⎠⎠ = 0.95 + 0.312j
−a
r2 ≔ ―― = 0.95 − 0.312j
r1
For example,
20 100
4
3.2
2.4
1.6
0.8
0
S (i) -0.8
-1.6
-2.4
-3.2
-4
0 10 20 30 40 50 60 70 80 90 100
i
Fig. 11.2.2 Closed-form sequence
In real terms, the solution is
S (n) ≔ 2 ⋅ |A| ⋅ cos (n ⋅ arg (r1) + arg (A))
so the solution sequence oscillates with amplitude
2 ⋅ |A| = 3.508
and period
2⋅π
――― = 19.786
arg (r1)
To examine other choices for the coefficients and initial values, modify the definitions above and recalculate.
The calculations will be correct as long as Y has two distinct poles, that is, as long as D is nonzero.
In this last example, the coefficients and initial values for the difference equation have been chosen so that the
roots of the denominator of the z-transform are equal and nonzero (that is, D is zero):
a ≔ −.81 b ≔ 1.8 s ≔1 s ≔ .5 s ≔b⋅s +a⋅s
1 0 n n−1 n−2
s
i
⎛ B ⎞ n
S (n) ≔ ⎜A + ―⋅ n⎟ ⋅ r
⎝ r ⎠
As a check:
s = 2.1 S (5) = 2.1
5