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 : 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
starts at rest and is fed a single impulse, x[0] = 1. What is y[3]?
0.125. y[0] = 1, then each output is half the one before: 0.5, 0.25, 0.125. The impulse response is , infinitely long though the equation is one line. That's an IIR (infinite impulse response) system.
Name it
Difference equations
A causal LTI digital filter computes
starting at rest (all earlier outputs zero), which is what makes it LTI. If every is zero, the output is a weighted sum of recent inputs, the impulse response is just , and the filter is FIR (finite impulse response). With feedback () it's IIR.
The first-order recursion has , settles to for a constant input C, and is stable for |a| < 1. The second-order one in the play has when and : a decaying oscillation, stable for r < 1.
Block diagrams
A difference equation is built from three blocks: a delay by one sample (drawn ), 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 , with ; 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 on a step, x[n] = 1 for n ≥ 0.
Show the solution
- Run the recursion.
- Final value. It closes on
- 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 .
Show the solution
- Radius.
- Angle.
- What it does. So it rings with a period of 6 samples and loses 10% of its size each sample:
- 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 stable?
Show the solution
- Find the roots. gives z = 1 and z = 0.5.
- Fit the impulse response. Fitting to h[0] = 1 and h[1] = 1.5 gives A = 2 and B = −1:
- Test stability. It stays bounded, but it doesn't die away, so diverges and the system isn't BIBO stable: a step input makes the output grow like a ramp.
- The boundary case. A pole exactly on the unit circle is the boundary case.
Answer no, it isn't BIBO stable: doesn't die away, because of the pole at z = 1 on the unit circle.
Check
starts at rest and gets an impulse at n = 0. What is y[5]?
Check
is fed a constant 10 for a long time. What does y settle to?
Check
starts at rest and is fed a unit step. What is y[2]?
Check
An FIR filter computes .
(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 has r = 0.8 and θ = 0.5. What is h[6]?
Check
A system obeys with τ = 0.1 s. What is its impulse response at t = 1τ?
Check
is driven by a step from n = 0.
(a)
What is y[2]?
(b)
Where does it settle?
Check
A resonator 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 ?
(b)
What is ?
Explain why
Why does a one-line recursion like have an infinitely long impulse response, while an FIR filter's ends?
In the recursion, each output is computed from the previous output, so the impulse that entered at n = 0 is carried forward forever: y[1] holds 0.9 of it, y[2] holds 0.9 of that, and so on, shrinking but never reaching zero. An FIR filter only looks back at inputs, never at its own outputs, so once the impulse has passed through its last tap, M samples later, nothing remembers it and the output is exactly zero. Feedback is what lets a few coefficients produce a long, decaying response, which is why IIR filters are so cheap for a given sharpness.
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.