C99 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C9 · Lesson 9 · Differential and difference equations

Systems described by their equations and block diagrams

Most LTI systems aren't handed to you as an impulse response. A circuit comes as a differential equation from Kirchhoff's laws; a digital filter comes as a few lines of code that compute each output from recent inputs and outputs. That line of code is a difference equation, and running it is a recursion: the output feeds back into its own next value. A two-line recursion can ring like a tuning fork, and seeing how its coefficients set the ringing is the first step toward the z-transform.

  • The stems are the impulse response of y[n]=2rcos⁡θy[n−1]−r2y[n−2]+x[n]: two multiplies and two adds per sample.
  • θ sets how fast it oscillates (a full cycle every 2π/θ samples) and r how fast it dies: by a factor r per sample.
  • Push r to 1: the ringing never stops. Past 1 it grows: the recursion has become unstable.

Predict

y[n]=0.5y[n−1]+x[n] starts at rest and is fed a single impulse, x[0] = 1. What is y[3]?

Name it

Difference equations

A causal LTI digital filter computes

y[n]=∑k=1Naky[n−k]+∑k=0Mbkx[n−k]

starting at rest (all earlier outputs zero), which is what makes it LTI. If every ak is zero, the output is a weighted sum of recent inputs, the impulse response is just b0,b1,…,bM, and the filter is FIR (finite impulse response). With feedback (ak≠0) it's IIR.

The first-order recursion y[n]=ay[n−1]+bx[n] has h[n]=banu[n], settles to bC/(1−a) for a constant input C, and is stable for |a| < 1. The second-order one in the play has h[n]=rnsin⁡((n+1)θ)/sin⁡θ when a1=2rcos⁡θ and a2=−r2: a decaying oscillation, stable for r < 1.

Block diagrams

A difference equation is built from three blocks: a delay by one sample (drawn z−1), a gain, and an adder. Direct form I uses a chain of delays on the input and another on the output, N + M of them; direct form II shares one chain and needs only max(N, M). Each delay is one number of memory.

Differential equations

Continuous-time LTI systems come from linear differential equations with constant coefficients. An RC low-pass obeys τy′+y=x, with h(t)=1τe−t/τu(t); a series RLC is second order. The order is the number of energy-storing elements, as the order of a difference equation is the number of delays it needs.

Worked example

Run y[n]=0.5y[n−1]+x[n] on a step, x[n] = 1 for n ≥ 0.

Show the solution
  1. Run the recursion. y[0]=1y[1]=1.5y[2]=1.75y[3]=1.875y[4]=1.9375
  2. Final value. It closes on 1/(1−0.5)=2
  3. The pattern. Each step halves the remaining distance to 2.

Answer y = 1, 1.5, 1.75, 1.875, 1.9375, and so on, closing on 2.

Worked example

Describe y[n]=0.9y[n−1]−0.81y[n−2]+x[n].

Show the solution
  1. Radius. r2=0.81sor=0.9
  2. Angle. 2rcos⁡θ=0.9cos⁡θ=0.5θ=π/3
  3. What it does. So it rings with a period of 6 samples and loses 10% of its size each sample: h=1,0.9,0,−0.729,−0.656,0,0.531,…
  4. Structure. It needs two delays in direct form II.

Answer it rings with a period of 6 samples (θ = π/3) and loses 10% of its size each sample (r = 0.9); it needs two delays in direct form II.

Worked example

Is y[n]=1.5y[n−1]−0.5y[n−2]+x[n] stable?

Show the solution
  1. Find the roots. z2−1.5z+0.5=0 gives z = 1 and z = 0.5.
  2. Fit the impulse response. Fitting h[n]=A+B(0.5)n to h[0] = 1 and h[1] = 1.5 gives A = 2 and B = −1: h[n]=2−0.5n
  3. Test stability. It stays bounded, but it doesn't die away, so ∑|h| diverges and the system isn't BIBO stable: a step input makes the output grow like a ramp.
  4. The boundary case. A pole exactly on the unit circle is the boundary case.

Answer no, it isn't BIBO stable: h[n]=2−0.5n doesn't die away, because of the pole at z = 1 on the unit circle.

Check

y[n]=0.8y[n−1]+0.5x[n] starts at rest and gets an impulse at n = 0. What is y[5]?

Check

y[n]=0.75y[n−1]+2x[n] is fed a constant 10 for a long time. What does y settle to?

Check

y[n]=0.5y[n−1]+x[n] starts at rest and is fed a unit step. What is y[2]?

Check

An FIR filter computes y[n]=1x[n]+2x[n−1]+0.25x[n−2].

(a)

What is h[1]?

(b)

What does a constant input of 1 give at the output, once the filter is full?

Check

A filter has feedback terms up to y[n − 4] and input terms up to x[n − 1].

(a)

How many delays does direct form I use?

(b)

How many does direct form II use?

Check

The recursion y[n]=2rcos⁡θy[n−1]−r2y[n−2]+x[n] has r = 0.8 and θ = 0.5. What is h[6]?

Check

A system obeys τy′+y=x with τ = 0.1 s. What is its impulse response at t = 1τ?

Check

y[n]=0.8y[n−1]+x[n] is driven by a step from n = 0.

(a)

What is y[2]?

(b)

Where does it settle?

Check

A resonator y[n]=a1y[n−1]+a2y[n−2]+x[n] should ring with a period of 6 samples and lose 0.9 of its size each sample (pole radius r = 0.9).

(a)

What is a1?

(b)

What is a2?

Explain why

Why does a one-line recursion like y[n]=0.9y[n−1]+x[n] have an infinitely long impulse response, while an FIR filter's ends?

Practice

Keep practicing

12 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.