Suppose you are measuring the temperature of a room with an electronic sensor. The actual temperature changes slowly, but the measurements fluctuate slightly because of electrical noise, imperfections in the sensor, and other disturbances.
How can we remove these fluctuations without losing the information we want?
One answer is a digital filter. Surprisingly, the mathematics behind a simple digital filter is closely related to the mathematics of Fibonacci numbers.
In our earlier article, How to Find the 100th Fibonacci Number Using the Z-Transform, we introduced the Z-transform as a way to turn a recurrence relation into an algebraic equation. Now we will see how the same idea helps us solve more general recurrences and understand digital signal processing.
1. The Z-Transform: A Brief Reminder
For a sequence
a_0,a_1,a_2,\ldots,its one-sided Z-transform is defined by
A(z)=\sum_{n=0}^{\infty}a_nz^{-n}.The important feature is that shifting a sequence corresponds to multiplying its transform by powers of z, with corrections for the initial values.
For example,
\mathcal Z\{a_{n+1}\}=zA(z)-za_0,and
\mathcal Z\{a_{n+2}\}=z^2A(z)-z^2a_0-za_1.These identities allow us to replace recurrence relations with ordinary algebraic equations.
2. Solving a Recurrence with an External Input
Consider the recurrence
a_{n+2}=3a_{n+1}-2a_n+2^n,with initial conditions
a_0=0,\qquad a_1=0.Unlike the Fibonacci recurrence, this equation contains an additional term, 2^n, called a forcing term. It represents an external input that drives the system.
Let A(z) be the Z-transform of the sequence. Since the initial conditions are zero, transforming the recurrence gives
z^2A(z)=3zA(z)-2A(z)+\frac{z}{z-2}.We used the geometric-series identity
\mathcal Z\{2^n\}=\frac{z}{z-2},\qquad |z|>2.Collecting the terms involving A(z), we obtain
(z^2-3z+2)A(z)=\frac{z}{z-2}.Since
z^2-3z+2=(z-1)(z-2),we find
A(z)=\frac{z}{(z-1)(z-2)^2}.The recurrence has now become a rational function.
Recovering the Sequence
Partial fractions give
A(z)=\frac{z}{z-1}-\frac{z}{z-2}+\frac{z}{(z-2)^2}.We use the transform identities
\mathcal Z\{1\}=\frac{z}{z-1},
\mathcal Z\{2^n\}=\frac{z}{z-2},
and
\mathcal Z\{n2^{n-1}\}=\frac{z}{(z-2)^2}.Taking the inverse Z-transform gives the explicit formula
\boxed{a_n=1-2^n+n2^{n-1}.}For example, the first few terms are
0,\ 0,\ 1,\ 5,\ 17,\ 49,\ldots.The formula allows us to calculate any term directly, without computing all preceding terms.
Notice the factor n2^{n-1}. It arises because the denominator contains a repeated factor (z-2)^2. Repeated poles of a Z-transform often produce polynomial factors multiplying exponential sequences.
3. From Recurrences to Digital Filters
Now consider a practical problem.
Suppose a sensor produces measurements
x_0,x_1,x_2,\ldots,and we want to construct a smoother sequence
y_0,y_1,y_2,\ldots.A particularly simple digital filter is defined by
\boxed{y_n=\frac12x_n+\frac12y_{n-1}.}In words, each new filtered value is the average of the current measurement and the previous filtered value.
For example, suppose the measurements are
10,\ 12,\ 9,\ 11,\ 10,\ 12,\ 9.Starting with y_{-1}=10, we obtain the following values:
| Step | Measurement | Filtered value |
|---|---|---|
| 0 | 10 | 10.0000 |
| 1 | 12 | 11.0000 |
| 2 | 9 | 10.0000 |
| 3 | 11 | 10.5000 |
| 4 | 10 | 10.2500 |
| 5 | 12 | 11.1250 |
| 6 | 9 | 10.0625 |
The original measurements fluctuate between 9 and 12, while the filtered values generally fluctuate less.

But why does this recurrence reduce noise?
4. The Transfer Function of a Filter
Let X(z) and Y(z) denote the Z-transforms of the input and output sequences.
Assume the filter starts from rest, so y_{-1}=0. Taking the Z-transform of
y_n=\frac12x_n+\frac12y_{n-1}gives
Y(z)=\frac12X(z)+\frac12z^{-1}Y(z).Rearranging,
Y(z)\left(1-\frac12z^{-1}\right)=\frac12X(z).Therefore,
\boxed{H(z)=\frac{Y(z)}{X(z)}=\frac{1/2}{1-\frac12z^{-1}}.}The function H(z) is called the transfer function of the filter. It describes how the filter transforms an input signal into an output signal.
Notice that we have replaced a recurrence involving infinitely many possible measurements with a simple rational function.
5. Why Does the Filter Remove Noise?
To understand the filter, consider two extreme types of input.
A Constant Signal
Suppose the input is constant:
x_n=C.A constant output y_n=C satisfies the filter equation because
C=\frac12C+\frac12C.Thus, a constant signal passes through unchanged in steady state.
A Rapidly Alternating Signal
Now suppose the input alternates between positive and negative values:
x_n=(-1)^n.Such rapid oscillations are a simple mathematical model of high-frequency fluctuations.
Look for a steady-state output of the form
y_n=A(-1)^n.Substituting into the filter equation,
A(-1)^n=\frac12(-1)^n+\frac12A(-1)^{n-1}.Since (-1)^{n-1}=-(-1)^n, division by (-1)^n gives
A=\frac12-\frac12A.Therefore,
\boxed{A=\frac13.}The input oscillates between -1 and 1, but the steady-state output oscillates between -1/3 and 1/3.
The amplitude of this rapidly alternating signal has been reduced by a factor of three.
This is the basic idea of a low-pass filter: slowly varying components pass through relatively easily, while rapidly oscillating components are attenuated.
6. A Frequency-Domain Explanation
The Z-transform gives a more general explanation.
To examine oscillations of different frequencies, substitute
z=e^{i\omega}into the transfer function, where \omega is the angular frequency measured in radians per sample.
We obtain
H(e^{i\omega})=\frac{1/2}{1-\frac12e^{-i\omega}}.The magnitude of this expression measures how strongly a sinusoidal input of frequency \omega is transmitted.
Using
|1-\tfrac12e^{-i\omega}|^2=\frac54-\cos\omega,we obtain
\boxed{|H(e^{i\omega})|=\frac{1}{\sqrt{5-4\cos\omega}}.}
At zero frequency,
|H(1)|=1.At the highest frequency representable by an alternating sampled sequence, \omega=\pi,
|H(e^{i\pi})|=\frac13.Thus, the transfer function confirms what we discovered directly: constant signals pass through without attenuation, while the fastest alternating signal has its amplitude reduced to one-third.
The filter does not eliminate all noise. It reduces high-frequency components, and it may also smooth or delay genuine rapid changes in the signal.
7. Why Are Poles Important?
Our filter has transfer function
H(z)=\frac{z}{2z-1}.The denominator vanishes at
z=\frac12.This value is called a pole of the transfer function.
To understand its significance, consider the more general filter
y_n=(1-r)x_n+ry_{n-1},where the parameter satisfies
0\lt r\lt 1.Its transfer function is
H(z)=\frac{1-r}{1-rz^{-1}}.The pole is located at
z=r.If the input is zero, the recurrence becomes
y_n=ry_{n-1}.Consequently,
y_n=r^{n+1}y_{-1}.Since the parameter is between zero and one, these values approach zero. The effect of the initial condition gradually disappears.
For this first-order filter, a pole strictly inside the unit circle corresponds to a decaying response and a stable system.
By contrast, the forced recurrence from Section 2 contains a pole at
z=2.Its solution includes exponentially growing terms.
We therefore see a fundamental distinction between stable filters and recurrences whose solutions grow without bound.
8. The Bigger Picture
The same mathematical idea appears in several different settings:
- Fibonacci numbers: A recurrence becomes a rational function, allowing us to find an explicit formula.
- Forced recurrences: External inputs can be incorporated into the algebraic equation.
- Digital filters: The transfer function explains how different frequencies are amplified or attenuated.
- Discrete dynamical systems: Poles help us understand stability and long-term behavior.
The Z-transform is powerful because it replaces relationships between successive terms with algebraic relationships between functions.
In our next article, How Can We Solve Differential Equations Using Algebra? The Laplace Transform, we move from discrete sequences to continuous functions.
The central lesson: A complicated recurrence can become a simple rational function, and that function can reveal much more than an explicit formula. It can explain the behavior of an entire system.

Leave a Reply