IIR Filters
IIR Filters
IIR Filters
Specifications
4
Copyright 2005, S. K. Mitra
p
s
A2 1
6
Copyright 2005, S. K. Mitra
Butterworth Approximation
Butterworth Approximation
Gain in dB is G () = 10 log10 H a ( j) 2
As G (0) = 0 and
G (c ) = 10 log10 (0.5) = 3.0103 3 dB
c is called the 3-dB cutoff frequency
8
Butterworth Approximation
Butterworth Approximation
Butterworth Filter
N=2
N=4
N = 10
Magnitude
1
0.8
0.6
0.4
0.2
0
10
Copyright 2005, S. K. Mitra
Butterworth Approximation
Butterworth Approximation
12
Copyright 2005, S. K. Mitra
Butterworth Approximation
Transfer function of an analog Butterworth
lowpass filter is given by
cN
cN
H a ( s) = C = N
=
DN ( s ) s + lN=01d s l lN=1 ( s pl )
l
Butterworth Approximation
Example - Determine the lowest order of a
Butterworth lowpass filter with a 1-dB cutoff
frequency at 1 kHz and a minimum attenuation of 40
dB at 5 kHz
Now
10 log10 1 2 = 1
1 +
which yields 2 = 0.25895
and
10 log10 12 = 40
A
which yields A2 = 10,000
where
pl = c e j[ ( N + 2l1) / 2 N ] , 1 l N
Denominator DN (s ) is known as the
Butterworth polynomial of order N
13
14
Copyright 2005, S. K. Mitra
Chebyshev Approximation
Butterworth Approximation
A2 1 = 196.51334
1=
k1
Therefore
1 = s = 5
k p
and
Hence
log (1 / k1 )
N = 10
= 3.2811
log10 (1 / k )
cos( N cos 1 ),
TN () =
1
cosh( N cosh ),
We choose N = 4
15
1
>1
16
Copyright 2005, S. K. Mitra
Chebyshev Approximation
Chebyshev Approximation
Magnitude
N=2
N=3
N=8
1
0.8
0.6
0.4
0.2
0
17
18
Copyright 2005, S. K. Mitra
Chebyshev Approximation
Chebyshev Approximation
TN ( s / )
Magnitude
0.6
0.4
0.2
N=3
N=5
N=7
1
0.8
20
Copyright 2005, S. K. Mitra
Elliptic Approximation
Chebyshev Approximation
N=
21
cosh 1 (1 / k1 )
= 2.6059
cosh 1 (1 / k )
22
Copyright 2005, S. K. Mitra
Elliptic Approximation
Elliptic Approximation
where k ' = 1 k 2
0 = 1 k '
2(1 + k ')
= 0 + 2( 0 )5 + 15( 0 )9 + 150( 0 )13
23
= 0.0025513525
and hence N = 2.23308
Choose N = 3
24
Elliptic Approximation
Magnitude
0.8
0.6
0.2
0
25
26
Copyright 2005, S. K. Mitra
Gain, dB
0
-20
-40
-60
with
0.4
2000
4000
Frequency, Hz
6000
27
28
Copyright 2005, S. K. Mitra
Then
D
H LP ( s ) = HD ( s) s = F 1 ( s )
29
30
Copyright 2005, S. K. Mitra
p
p
p s
Stopband s p
Stopband
0
Passband
Stopband
Passband
p
s
Passband
Lowpass
Highpass
31
Spectral Transformation
o2
s 2 +
s = p
p2
p1 )
s(
Gain plots
-20
-20
-40
-60
33
-80
0
Highpass Filter
0
Gain, dB
Gain, dB
-40
-60
10
-80
0
4
6
8
10
Frequency, kHz
Copyright 2005, S. K. Mitra
34
Copyright 2005, S. K. Mitra
= p o
Bw
p2
p1 is the width of
where Bw =
o2
2
Bw
p s
Stopband s p
Stopband
0
Passband
Stopband
Passband
Stopband
Passband
Stopband
s1 0
o
s1
s2
s2
p2 o
p1
p1
p2
Lowpass
Bandpass
36
Copyright 2005, S. K. Mitra
p1
p2 >
s1
s2
Case 1:
s 2 we can either
To make p1 p 2 = s1
increase any one of the stopband edges or
decrease any one of the passband edges as
shown below
Passband
Stopband
s1
Stopband
p1
p2
s2
38
Copyright 2005, S. K. Mitra
s1
s2 /
p2
p1 to
(1) Decrease
larger passband and shorter
leftmost transition band
p1
p2 /
s2
s1 to
(2) Increase
o2 =
p1
p2 =
s1
s2
Note: The condition
p2
can also be satisfied by decreasing
which is not acceptable as the passband is
reduced from the desired value
Alternately, the condition can be satisfied
s 2 which is not acceptable
by increasing
as the upper stop band is reduced from the
desired value
39
40
Copyright 2005, S. K. Mitra
p1
p2 <
s1
s2
Case 2:
p1
p2 =
s1
s 2 we can either
To make
decrease any one of the stopband edges or
increase any one of the passband edges as
shown below
Passband
Stopband
s1
p1
p 2 to
s1
s2 /
p1
(1) Increase
larger passband and shorter
rightmost transition band
p1
p2 /
s1
s 2 to
(2) Decrease
No change in passband and shorter
rightmost transition band
p2
s2
Stopband
41
42
Copyright 2005, S. K. Mitra
Fs 2 = 8 kHz, p = 1 dB, s = 22 dB
o2 =
p1
p2 =
s1
s2
Note: The condition
p1
can also be satisfied by increasing
which is not acceptable as the passband is
reduced from the desired value
Alternately, the condition can be satisfied
s1 which is not acceptable
by decreasing
as the lower stopband is reduced from the
desired value
43
We choose p = 1
Hence
24 9
s =
= 1.4
(25 / 7) 3
Gain plot
Prototype Lowpass Filter
0
Gain, dB
Gain, dB
46
Copyright 2005, S. K. Mitra
-20
-40
-60
0
-20
-40
-60
0
5
10
15
Frequency,
kHz 2005, S. K. Mitra
Copyright
= s 2 w 2
o
Spectral Transformation
s2
s1 )
s(
s = s
2
2o
s +
where s is the stopband edge frequency
s1 and
s 2 are the lower
of H LP ( s ) , and
and upper stopband edge frequencies of the
desired bandstop filter H BS ( s)
47
Bandpass Filter
48
Copyright 2005, S. K. Mitra
Also,
p s
Stopband s p
Stopband
0
Passband
Passband
Stopband
Passband
Stopband
Passband
o
p1
o
p10
p2
p2
s2
s1
s1
s2
o2 =
p1
p2 =
s1
s2
Lowpass
Bandpass
49
50
Copyright 2005, S. K. Mitra
p1
p2 >
s1
s2
Case 1:
p1
p2 =
s1
s 2 we can either
To make
increase any one of the stopband edges or
decrease any one of the passband edges as
shown below
Passband
Passband
Stopband
51
p 2 to
s1
s2 /
p2
(1) Decrease
larger high-frequency passband
and shorter rightmost transition band
p1
p2 /
s2
s 2 to
(2) Increase
No change in passbands and
shorter rightmost transition band
p1
s1
s2
p2
52
Copyright 2005, S. K. Mitra
o2 =
p1
p2 =
s1
s2
Note: The condition
can also be satisfied by decreasing
p1
which is not acceptable as the low-
frequency passband is reduced from the
desired value
Alternately, the condition can be satisfied
s1 which is not acceptable
by increasing
as the stopband is reduced from the desired
value
p1
p2 <
s1
s2
Case 1:
s 2 we can either
To make p1 p 2 = s1
decrease any one of the stopband edges or
increase any one of the passband edges as
shown below
53
Passband
54
Copyright 2005, S. K. Mitra
Passband
Stopband
p1
s1
s2
p2
p1 to
s1
s2 /
p1
(1) Increase
larger passband and shorter
leftmost transition band
s1 to
p1
p2 /
s1
(2) Decrease
No change in passbands and
shorter leftmost transition band
55
56
Copyright 2005, S. K. Mitra
10
HHP (e j )
c 0
c2 c1
HBS (e j )
HBP (e j )
c1
c2
c2 c1
c1
c2
1 p G ( e j ) 1 + p ,
11
10
2(3 103 )
= 0.24
25 103
13
Advantages in using an FIR filter (1) Can be designed with exact linear phase,
(2) Filter structure always stable with
quantized coefficients
Disadvantages in using an FIR filter - Order
of an FIR filter, in most cases, is
considerably higher than the order of an
equivalent IIR filter meeting the same
specifications, and FIR filter has thus higher
computational complexity
H ( z ) = h[n] z n
n =0
16
18
20
22
T 1+ z 1
Bilinear Transformation
Bilinear transformation 1
s = 2 1 z 1
T 1 + z
23
24
Bilinear Transformation
Bilinear Transformation
For s = o + jo
2
2
(1 + o ) + jo
2 (1 + o ) + o
z=
z =
(1 o ) jo
(1 o ) 2 + o2
o = 0 z = 1
Thus,
o < 0 z < 1
o > 0 z > 1
25
26
Bilinear Transformation
Bilinear Transformation
27
29
= tan(/2)
Bilinear Transformation
Bilinear Transformation
Nonlinear mapping introduces a distortion
in the frequency axis called frequency
warping
Effect of warping shown below
Steps in the design of a digital filter (1) Prewarp ( p , s ) to find their analog
equivalents ( p , s )
(2) Design the analog filter H a (s )
(3) Design the digital filter G(z) by applying
bilinear transformation to H a (s )
Transformation can be used only to design
digital filters with prescribed magnitude
response with piecewise constant values
Transformation does not preserve phase
response of analog filter
30
Example - Consider
c
s + c
Applying bilinear transformation to the above
we get the transfer function of a first-order
digital lowpass Butterworth filter
H a ( s) =
1+ z 1
where
c (1 + z 1 )
=
(1 z 1 ) + c (1 + z 1 )
31
32
33
H a ( j 0) = H a ( j) = 1
o is called the notch frequency
If H a ( j 2 ) = H a ( j1 ) = 1 / 2 then
B = 2 1 is the 3-dB notch bandwidth
Copyright 2005, S. K. Mitra
Then
=
35
1+
1 2 z + z
2 1 2 (1 + ) z 1 + z 2
1 + o2 B 1 tan( Bw / 2)
=
1 + o2 + B 1 + tan( Bw / 2)
1 o2
=
= cos o
Copyright 2005, S. K. Mitra
1 + o2
34
G( z) =
2
0
-10
-20
-30
= 0.587785
Copyright 2005, S. K. Mitra
where =
Gain, dB
= 0.90993
G ( z ) = H a ( s ) s =1 z
1+ z 1
2
2
(1 + o ) 2(1 o ) z 1 + (1 + o2 ) z 2
(1 + o2 + B) 2(1 o2 ) z 1 + (1 + o2 B ) z 2
1
2
1 c 1 tan(c / 2)
=
1 + c 1 + tan(c / 2)
Phase, radians
G ( z ) = H a ( s ) s =1 z 1
1
G ( z ) = 1 1 + z 1
2 1 z
36
-40
0
50
100
150
Frequency, Hz
200
1
0
-1
-2
0
50
100
150
Frequency, Hz
200
Prewarping we get
p = tan( p / 2) = tan(0.25 / 2) = 0.4142136
s = tan(s / 2) = tan(0.55 / 2) = 1.1708496
The inverse transition ratio is
1 s
=
= 2.8266809
k p
The inverse discrimination ratio is
If G (e j 0 ) = 1 this implies
20 log10 G (e j 0.25 ) 0.5
20 log10 G (e j 0.55 ) 15
37
38
N=
We choose N = 3
To determine c we use
2
1
1
=
2N
1 + ( p / c )
1 + 2
39
Ha ( s ) = Han
0.588148
40
1+ z 1
0
-10
Gain, dB
Magnitude
41
-20
-30
0.2
0
0.2
0.4
0.6
/
0.8
-40
0
0.2
0.4
0.6
We then get
c = 1.419915 ( p ) = 0.588148
log10 (1 / k1 )
= 2.6586997
log10 (1 / k )
H a ( j p ) =
A2 1
= 15.841979
1
=
k1
0.8
Copyright
2005, S. K. Mitra
/
42
43
46
s = tan(s / 2) = 1.0
Using = p p we get s = 1.962105
0
Gain, dB
-10
s = 1.926105 , p = 1dB, s = 32 dB
Copyright 2005, S. K. Mitra
2 Fp
2 700
=
= 0.7
FT
2000
2 Fs 2 500
s =
=
= 0.5
FT
2000
p =
47
-20
-30
-40
48
-50
0
0.2
0.4
0.6
/
0.8
1
Copyright 2005, S. K. Mitra
p 2 = tan( p 2 / 2) = 1.6318517
p2
p1 = 0.777771
Width of passband Bw =
o2 =
p1
p 2 = 1.393733
s1
s 2 = 1.23010325
o2
s1and
exhibit
geometric
symmetry
with
s2
o2
respect to
s1 = 0.5773031
We set
For the prototype analog lowpass filter we
choose p = 1
s1 = tan(s1 / 2) = 0.5095254
s 2 = tan(s 2 / 2) = 2.41421356
49
50
2 2
Using = p o we get
Bw
s =
1.393733 0.3332788
= 2.3617627
0.5773031 0.777771
0
Gain, dB
-10
-20
-30
-40
-50
52
0.2
0.4
0.6
0.8
/
Copyright 2005, S. K. Mitra
p 2 = 2.4142136
p1 = 0.5095254,
s2
s1 = 0.777771
Width of stopband Bw =
p1and
p2
p1so that
We therefore modify
exhibit geometric symmetry with respect to
o2
53
o2 =
s 2
s1 = 1.393733
o2
p 2 p1 = 1.230103
Copyright 2005, S. K. Mitra
p1 = 0.577303
We set
For the prototype analog lowpass filter we
choose s = 1
B
Using = s 2 w 2 we get
o
0.5095254 0.777771
p =
= 0.4234126
1.393733 0.3332787
54
-10
-20
-30
-40
-50
0
55
0.2
0.4
0.6
0.8
/
Copyright 2005, S. K. Mitra
10
H d (e j ) = hd [n]e jn
n =
where
hd [n] =
1
1
j jn
H d (e )e d, n
2
n =
M
M 1
n =
n = M +1
H t (e j ) = ht [n]e jn
n= M
= ht [n] hd [n]
hLP [n] =
c 0
HHP (e j )
1
6
Copyright 2005, S. K. Mitra
sin c n
n , n
1 c ,
n=0
hHP [n] =
sin( n)
nc , n 0
HBS (e j )
HBP (e j )
1
1
c2 c1
c2 c1
c1
c2
c2
1 (c 2 c1 ) ,
n=0
hBS [n] =
sin( n) sin(c 2n)
nc1
n , n 0
sin(c 2 n) sin(c1n) , n 0
n
n
hBP [n] =
c 2 c1
n=0
,
c1
8
Copyright 2005, S. K. Mitra
A5
A1
A4
A2
A3
H ML (e j ) = Ak ,
j, < < 0
H HT (e j ) =
j , 0 < <
k 1 k ,
k = 1, 2,K, L
for n even
0,
hHT [n] =
2/ n, for n odd
sin( n)
hML [n] = ( Al Al +1) nL
L
l =1
10
Copyright 2005, S. K. Mitra
Gibbs Phenomenon
Gibbs phenomenon - Oscillatory behavior in
the magnitude responses of causal FIR filters
obtained by truncating the impulse response
coefficients of ideal filters
1.5
11
Magnitude
n=0
0,
hDIF [ n] = cos n
n , n 0
12
Copyright 2005, S. K. Mitra
N = 20
N = 60
0.5
0
0
0.2
0.4
0.6
0.8
/
Copyright 2005, S. K. Mitra
Gibbs Phenomenon
13
Gibbs Phenomenon
Gibbs phenomenon can be explained by
treating the truncation operation as an
windowing operation:
ht [n] = hd [n] w[ n]
In the frequency domain
H t ( e j ) =
14
1
2
j
j ( )
) d
H d (e ) ( e
Gibbs Phenomenon
Gibbs Phenomenon
15
Gibbs Phenomenon
Gibbs Phenomenon
30
Amplitude
20
18
Copyright 2005, S. K. Mitra
side lobe
M=4
0
-10
-1
main lobe
M = 10
10
-0.5
0
/
0.5
Gibbs Phenomenon
19
Gibbs Phenomenon
Rectangular window has an abrupt transition
to zero outside the range M n M , which
results in Gibbs phenomenon in H t (e j )
Gibbs phenomenon can be reduced either:
(1) Using a window that tapers smoothly to
zero at each end, or
(2) Providing a smooth transition from
passband to stopband in the magnitude
specifications
20
Copyright 2005, S. K. Mitra
-40
-60
-100
0.2
0.4
0.6
0.8
-100
0.2
0.4
0.6
Hamming window
Blackman window
0
-20
-40
-40
Gain, dB
0
-20
-60
-100
-60
-80
-80
0.8
-60
-80
0.2
0.4
0.6
0.8
-100
0.2
0.4
0.6
0.8
1
/
Copyright 2005, S. K. Mitra
0
-20
-80
Hann window
Gain, dB
Gain, dB
Rectangular window
Gain, dB
Observe H t (e j (c + ) ) + H t (e j (c ) ) 1
Thus,
H t (e jc ) 0.5
Passband and stopband ripples are the same
5
10
Gain, dB
Gain, dB
-50
-50
-100
-100
0
0.2
0.4
0.6
0.8
0.2
0.4
0.6
0.8
Gain, dB
-50
-100
11
0.2
0.4
0.6
/
0.8
12
Dolph-Chebyshev Window M
w[n] = 1 [1 + 2 Tk ( cos k ) cos 2nk ],
2M + 1
2M + 1
2M + 1
k =1
M nM
amplitude of sidelobe
where
=
main lobe amplitude
= cosh( 1 cosh 1 1 )
2M
and
cos(l cos 1 x ),
x 1
Tl ( x) =
1
cosh(l cosh x), x > 1
13
14
Gain, dB
0
-20
-40
-60
0.2
0.4
0.6
0.8
-80
0
15
16
Kaiser Window -
I 0{ 1 (n / M ) }
, M nM
I 0 ()
where is an adjustable parameter and I 0 (u )
is the modified zeroth-order Bessel function
of the first kind:
(u / 2) r
I 0 (u ) = 1 + [
]2
r!
r =1
Note I 0 (u ) > 0 for u > 0
20 (u / 2) r
In practice I 0 (u ) 1 + [
]2
r!
r =1
17
w[n] =
0.1102( s 8.7 ),
N=
for s > 50
for 21 s 50
for s < 21
s 8
2.285()
sin(0.4 n)
Hence ht [ n] =
w[n], 12 n 12
n
where w[n] is the n-th coefficient of a
length-25 Kaiser window with = 3.3953
-20
Gain, dB
-20
-40
-80
0
20
0.2
0.4
0.6
0.8
-80
0.2
0.4
0.6
0.8
c = ( p + s ) / 2
c / ,
= s p
c / ,
-40
-60
21
-60
Kaiser Window
Gain, dB
n=0
n=0
n >0
n >0
22
Magnitude
P = 1, N = 40
P = 2, N = 60
0.8
0.6
0.4
0.2
0
0
0.2
0.4
0.6
0.8
23
[dsp TIPS&TRICKS]
Greg Berchin
5 2
6 4
x
7
=
y
9
x
5
=
y
6
1
= 38
16
7
8
=
1
7
9
1
16
7
5
9
32
9
16
.
21
45
+
16
32
2
4
5 2
7
x
6 4
= 9 or
y
1 1
5
1
5 2 T
5 2
x
6 4 6 4
y
1 1
1 1
T
5 2
7
for THIS case:
6 4 9
p_inv(X) =
1 1
5
[inv(X'X)][X']
0.3716
,
2.8491
where T denotes the matrix transpose. Of
course, the mathematical derivation of
the matrix inverse and pseudoinverse,
and the definition of least-squares, can
be found in any basic linear algebra text
[1]. And while our more mathematically
inclined readers will point out that there
are better ways than this to compute the
pseudoinverse, this method is adequate
for our example.
You may also remember that filter
specifications are commonly expressed in
terms of passband width and flatness,
transition band width, and stopband
attenuation. There may also be some general specifications about phase response
DSP Tips and Tricks introduces practical design and implementation signal processing algorithms that you
may wish to incorporate into your
designs. We encourage readers to
submit their contributions to
Associate Editors Rick Lyons
(r.lyons@ieee.org) or Britt Rorabaugh
(dspboss@aol.com).
1053-5888/07/$25.002007IEEE
[dsp TIPS&TRICKS]
continued
Let us conclude our background section with a comment on what a frequency response value means. In a simple
example, if the frequency response of a
system at a frequency 1 is given in
magnitude/phase form as A1 1 , the
output amplitude will be A1 times the
input amplitude and the output phase
will be shifted an angle 1 relative to the
input phase when a steady-state sine
wave of frequency 1 is applied to the
system. For instance, if the input to the
system described above at time k is
u1 (k) = cos(k1 ts ), where ts is the sampling period (equal to one over the sampling frequency), then the output will be
y1 (k) = A1 cos(k1 ts + 1 ) . The input
and output values at any sample time
can be determined in a similar manner.
For example, the input sample value N
samples
in
the
past
was
u1 (k N) = cos ((k N )1 ts ) and the
output sample value D samples in the
past was y1 (k D) = A1 cos ((k D)
1 ts + 1 ). For our purposes, since k
represents the current sample time, its
value can conveniently be set to zero.
u1 (0) . . . u1 (N )]
b0 .
.
..
bN
(Note that the current-sample index k
has been set to zero.) If we repeat using
A2 2 at a different frequency 2 , we
obtain a second equation in D + N + 1
unknowns as shown in (a) at the bottom
of the page. And if we repeat at many
more different frequencies M than we
have unknowns D + N + 1, we know
from our review of linear algebra that the
pseudoinverse will compute values for
the set of coefficients a1 . . . aD and
b0 . . . bN that come as close as possible
to solving all of the equations, which is
exactly what we need to design our filter.
So now we can write (b), shown at the
bottom of the page. We can denote the
y1 (0) . . . yM (0) column vector above as
Y, the matrix as X, and the a1 . . . bN col-
+ b0 u(k) + + bN u(k N ),
where the a and b coefficients are exactly
the same as in the transfer function
above, k is the time index, u(k) and y(k)
are the current values of the input and
output (respectively), u(k N ) was the
input value N samples in the past, and
y(k D) was the output value D samples
in the past. We can write the equation
above in matrix form as
y(k) = [y(k 1) . . . y(k D)
a
1
..
.
aD
u(k) . . . u(k N )]
b0 .
.
..
y1 (1) . . .
y1 (0)
=
y2 (0)
y2 (1) . . .
y1 (D)
y2 (D)
u1 (0) . . .
u2 (0) . . .
a
1
..
.
u1 (N)
aD .
u2 (N)
b
0
.
..
(a)
bN
y1 (1) . . .
y1 (0)
y2 (0) y2 (1) . . .
.. =
..
.
.
yM (0)
yM (1) . . .
y1 (D)
y2 (D)
..
.
u1 (0)
u2 (0)
..
.
yM (D)
uM (0) . . .
bN
IEEE SIGNAL PROCESSING MAGAZINE [138] JANUARY 2007
...
...
a
1
..
u1 (N) .
u2 (N)
aD
..
b0 .
.
.
uM (N) ..
bN
(b)
Magnitude (dB)
(X T X )1 X T Y .
0
10
20
30
40
50
102
101
100
Frequency (Hz)
101
102
[FIG1] Magnitude responses of the filter designed using the bilinear transform, impulse
invariance, and FDLS methods.
150
Phase (degrees)
100
50
0
50
100
150
102
100
Frequency (Hz)
101
102
[FIG2] Phase responses of the filter designed using the bilinear transform, impulse
invariance, and FDLS methods.
CONCLUSION
FDLS is a powerful method for designing digital filters. As is the case with all
approximation techniques, there are
circumstances in which the FDLS
method works well and others in which
it does not. The FDLS method does not
replace other filter design methods; it
provides one more method from which
to choose. FDLS is most useful in cases
where a specified frequency response
must be duplicated to within tight tolerances over a wide frequency range or
when the frequency response of an
existing system is known but the coefficients of the systems transfer function are unknown. It is up to the
designer to determine whether to use
it in any given situation. Detailed
examples and a MATLAB code implementation of the FDLS algorithm are
available at http://apollo.ee.columbia.
edu/spm/?i=external/tipsandtricks.
ACKNOWLEDGMENTS
My thanks to Jaime Andrs Aranguren
Cardona for providing the example
shown in Figures 1 and 2, originally
posted on the comp.dsp Newsgroup on
9 January 2005, which ultimately led to
this article.
AUTHOR
Greg Berchin (berchin@ieee.org) is a signal processing algorithm engineer who
provides contract engineering services
from Naperville, Illinois.
REFERENCES
FDLS Examples
by Greg Berchin and Richard Lyons [January 2007]
The following material provides additional examples of the FDLS algorithm described in the
January 2007 IEEE Signal Processing magazine DSP Tips & Tricks column article "Precise Filter
Design" by Greg Berchin.
Algebraic Example
Recall the FDLS matrix expression
a1
y1 (0) y1 ( 1) K y1 ( D ) u1 (0) K u1 ( N ) M
y (0) y ( 1) K y ( D ) u (0) K u ( N ) a
2
2
2
2
D ,
2 =
b0
M
M
M
M
M
y M (0) y M ( 1) K y M ( D ) u M (0) K u M ( N ) M
bN
which we wrote as Y = X.
Each individual element in the Y column vector is of the form Amcos(m), and each
element in the X matrix is of the form A1cos(k1ts + 1) or cos(k1ts). Because all of these
elements are of the form of a product (Amplitude)[cos(angle)], each element in Y and X is equal
to a constant.
Now if, say, D = 10 and N = 9, then:
y1(0) = A1cos(1)
...
u1(9) = cos[(9)1ts] = cos(91ts).
IEEE Copyright All Rights Reserved
Page 1 of 5
phase samples, shown as dots in Figure E1, available to us as input values to the FDLS
algorithm.
M=8
m = 2 . fm :
1.5
A5
Linear
1
Desired magnitude response
0.5
A1
(a)
A8
0
0
100
f1 = 0 Hz
200
300
Frequency
f7 = 106.3 Hz
400
500
1 = 2(0.0)
2 = 2(19.69)
3 = 2(35.43)
4 = 2(51.18)
5 = 2(59.05)
6 = 2(66.93)
7 = 2(106.30)
8 = 2(389.76)
f8 = 389.76 Hz
f4 = 51.18 Hz
(b)
Phase (radians)
4
5
2
1
0
2
8
0
100
200
300
Frequency
400
500
Fig E1
Page 2 of 5
0.0
19.6850
35.4331
fm = 51.1811
59.0551
66.9291
106.299
389.764
0.0
0.1237
0.2226
mts = 0.3216
0.3711
0.4205
0.6679
2.449
0.2172
0.2065
0.1696
Am = 0.0164
1.3959
0.6734
0.3490
0.3095
0.0
0.0156
0.0383
m = 3.0125
2.3087
0.955
0.0343
0.0031
where the fm vector is in Hz, the mts vector is in radians, and 1 m 8. The first two
elements of the Y vector are:
y1(0) = A1cos(1) = 0.2172cos(0) = 0.2172.
y2(0) = A2cos(2) = 0.2065cos(0.0156) = 0.2065.
Y =
A1cos(1)
A2cos(2)
A3cos(3)
A4cos(4)
A5cos(5)
A6cos(6)
A7cos(7)
A8cos(8)
0.2172
0.2065
0.1695
= 0.0162
0.9390
0.6605
0.3488
0.3095
The two elements of the "y1" part of the first row of the X vector are:
y1(1) = A1cos(1ts + 1) = 0.2172cos(0 + 0) = 0.2172.
y1(2) = A1cos(21ts + 1) = 0.2172cos(0 + 0) = 0.2172.
The two elements of the "y8" part of the eighth row of the X vector are:
y8(1) = A8cos(8ts + 8) = 0.3095cos(2.449 + 0.0031) = 0.2376.
y8(2) = A8cos(28ts + 8) = 0.3095cos(4.898 + 0.0031) = 0.562.
Page 3 of 5
The three elements of the "u1" part of the first row of the X matrix are:
u1(0) = cos(0) = 1
u1(1) = cos(1ts) = cos(0) = 1
u1(2) = cos(21ts) = cos(0) = 1.
The three elements of the "u8" part of the eighth row of the X matrix are:
u8(0) = cos(0) = 1
u8(1) = cos(8ts) = cos(2.449) = 0.7696
u8(2) = cos(28ts) = cos(4.898) = 0.1845.
A1cos(11ts+1)
A2cos(12ts+2)
A3cos(13ts+3)
X = A4cos(14ts+4)
A5cos(15ts+5)
A6cos(16ts+6)
A7cos(17ts+7)
A8cos(18ts+8)
0.2172
0.2045
0.1639
= 0.0147
0.5007
0.6564
0.2812
0.2376
0.2172
0.994
0.1502
0.0117
0.0059
0.5378
0.0928
0.0562
A1cos(21ts+1)
A2cos(22ts+2)
A3cos(23ts+3)
A4cos(24ts+4)
A5cos(25ts+5)
A6cos(26ts+6)
A7cos(27ts+7)
A8cos(28ts+8)
1.00
1.00
1.00
1.00
1.00
1.00
1.00
1.00
1.0000
0.9924
0.9753
0.9487
0.939
0.9129
0.7851
0.7696
cos(0)
cos(0)
cos(0)
cos(0)
cos(0)
cos(0)
cos(0)
cos(0)
cos(1ts)
cos(2ts)
cos(3ts)
cos(4ts)
cos(5ts)
cos(6ts)
cos(7ts)
cos(8ts)
cos(21ts)
cos(22ts)
cos(23ts)
cos(24ts)
cos(25ts)
cos(26ts)
cos(27ts)
cos(28ts)
1.0000
0.9696
0.9025
0.8002 .
0.7370
0.6667
0.2328
0.1845
Given the above Y vector and the X matrix, the FDLS algorithm computes the 2nd-order
(N = D = 2) transfer function coefficients vector M=8 as
M=8 =
1.8439
0.9842
0.3033
0.5762
0.3034
Page 4 of 5
y(k)
z 1
1.8439
z 1
0.3033
0.5762
0.3034
0.9842
Fig E2
(a)
Magnitude (dB)
The frequency-domain performance of the filter are the solid red curves shown in Figure E3.
There we see that the M=8 coefficients provide an accurate approximation to the desired
frequency response in Figure E1.
20
40
0
100
200
300
Frequency
400
500
400
500
(b)
Phase (radians)
4
2
0
2
0
100
200
300
Frequency
Fig E3
Page 5 of 5