You are on page 1of 93

7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

7: Optimal FIR filters

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 1 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

H() = H(e ) =

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

P M2

M
2

h[n]ejn

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

H() = H(e ) =

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

P M2

M
2

jn

h[n]e

= h[0] + 2

P M2
1

h[n] cos n

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

P M2

jn

P M2

= h[0] + 2 1 h[n] cos n




j

H() is real but not necessarily positive (unlike H(e ) ).
H() = H(e ) =

DSP and Digital Filters (2014-5490)

M
2

h[n]e

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

P M2

jn

P M2

= h[0] + 2 1 h[n] cos n




j

H() is real but not necessarily positive (unlike H(e ) ).

Weighted error: e() = s() H() d() where d() is the target.
H() = H(e ) =

DSP and Digital Filters (2014-5490)

M
2

h[n]e

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

P M2

jn

P M2

= h[0] + 2 1 h[n] cos n




j

H() is real but not necessarily positive (unlike H(e ) ).

Weighted error: e() = s() H() d() where d() is the target.
Choose s() to control the error variation with .
H() = H(e ) =

DSP and Digital Filters (2014-5490)

M
2

h[n]e

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

P M2

jn

P M2

= h[0] + 2 1 h[n] cos n




j

H() is real but not necessarily positive (unlike H(e ) ).

Weighted error: e() = s() H() d() where d() is the target.
Choose s() to control the error variation with .
H() = H(e ) =

M
2

h[n]e

Example: lowpass filter

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

P M2

jn

P M2

= h[0] + 2 1 h[n] cos n




j

H() is real but not necessarily positive (unlike H(e ) ).

Weighted error: e() = s() H() d() where d() is the target.
Choose s() to control the error variation with .
H() = H(e ) =

M
2

h[n]e

Example: lowpass filter

d() =

DSP and Digital Filters (2014-5490)

1 0 1
0 2

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

P M2

jn

P M2

= h[0] + 2 1 h[n] cos n




j

H() is real but not necessarily positive (unlike H(e ) ).

Weighted error: e() = s() H() d() where d() is the target.
Choose s() to control the error variation with .
H() = H(e ) =

M
2

h[n]e

Example: lowpass filter

d() =

1 0 1
0 2

(
1 0 1
s() = 1

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

P M2

jn

P M2

= h[0] + 2 1 h[n] cos n




j

H() is real but not necessarily positive (unlike H(e ) ).

Weighted error: e() = s() H() d() where d() is the target.
Choose s() to control the error variation with .
H() = H(e ) =

M
2

h[n]e

Example: lowpass filter

d() =

1 0 1
0 2

(
1 0 1
s() = 1

2
e() = 1 when H() lies at the edge of the specification.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 2 / 11

Optimal Filters
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

We restrict ourselves to zero-phase filters of odd length M + 1, symmetric


around h[0], i.e. h[n] = h[n].
j

P M2

jn

P M2

= h[0] + 2 1 h[n] cos n




j

H() is real but not necessarily positive (unlike H(e ) ).

Weighted error: e() = s() H() d() where d() is the target.
Choose s() to control the error variation with .
H() = H(e ) =

M
2

h[n]e

Example: lowpass filter

d() =

1 0 1
0 2

(
1 0 1
s() = 1

2
e() = 1 when H() lies at the edge of the specification.
Minimax criterion: h[n] = arg minh[n] max |e()|: minimize max error
DSP and Digital Filters (2014-5490)

Optimal FIR: 7 2 / 11

Alternation Theorem
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

Want to find the best fit line: with the smallest maximal error.

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

8
6
4
2
2

Optimal FIR: 7 3 / 11

Alternation Theorem
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Want to find the best fit line: with the smallest maximal error.
Best fit line always attains the
maximal error three times with
alternate signs

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

8
6
4
2
2

Optimal FIR: 7 3 / 11

Alternation Theorem
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Want to find the best fit line: with the smallest maximal error.
Best fit line always attains the
maximal error three times with
alternate signs

8
6
4
2
2

Proof:
Assume the first maximal deviation from the line is negative as shown.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 3 / 11

Alternation Theorem
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Want to find the best fit line: with the smallest maximal error.
Best fit line always attains the
maximal error three times with
alternate signs

8
6
4
2
2

Proof:
Assume the first maximal deviation from the line is negative as shown.
There must be an equally large positive deviation; or else just move the line
downwards to reduce the maximal deviation.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 3 / 11

Alternation Theorem
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Want to find the best fit line: with the smallest maximal error.
Best fit line always attains the
maximal error three times with
alternate signs

8
6
4
2
2

Proof:
Assume the first maximal deviation from the line is negative as shown.
There must be an equally large positive deviation; or else just move the line
downwards to reduce the maximal deviation.
This must be followed by another maximal negative deviation; or else you
can rotate the line and reduce the deviations.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 3 / 11

Alternation Theorem
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Want to find the best fit line: with the smallest maximal error.
Best fit line always attains the
maximal error three times with
alternate signs

8
6
4
2
2

Proof:
Assume the first maximal deviation from the line is negative as shown.
There must be an equally large positive deviation; or else just move the line
downwards to reduce the maximal deviation.
This must be followed by another maximal negative deviation; or else you
can rotate the line and reduce the deviations.
Alternation Theorem:
A polynomial fit of degree n to a bounded set of points is minimax if and
only if it attains its maximal error at n + 2 points with alternating signs.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 3 / 11

Alternation Theorem
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Want to find the best fit line: with the smallest maximal error.
Best fit line always attains the
maximal error three times with
alternate signs

8
6
4
2
2

Proof:
Assume the first maximal deviation from the line is negative as shown.
There must be an equally large positive deviation; or else just move the line
downwards to reduce the maximal deviation.
This must be followed by another maximal negative deviation; or else you
can rotate the line and reduce the deviations.
Alternation Theorem:
A polynomial fit of degree n to a bounded set of points is minimax if and
only if it attains its maximal error at n + 2 points with alternating signs.
There may be additional maximal error points.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 3 / 11

Alternation Theorem
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Want to find the best fit line: with the smallest maximal error.
Best fit line always attains the
maximal error three times with
alternate signs

8
6
4
2
2

Proof:
Assume the first maximal deviation from the line is negative as shown.
There must be an equally large positive deviation; or else just move the line
downwards to reduce the maximal deviation.
This must be followed by another maximal negative deviation; or else you
can rotate the line and reduce the deviations.
Alternation Theorem:
A polynomial fit of degree n to a bounded set of points is minimax if and
only if it attains its maximal error at n + 2 points with alternating signs.
There may be additional maximal error points.
Fitting to a continuous function is the same as to an infinite number of
points.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 3 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

H() = H(e ) = h[0] + 2

P M2
1

h[n] cos n

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 4 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

H() = H(e ) = h[0] + 2


But

P M2
1

h[n] cos n

cos 2 = 2 cos2 1

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 4 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

H() = H(e ) = h[0] + 2


But

P M2
1

h[n] cos n

cos 2 = 2 cos2 1
cos 3 = 4 cos3 3 cos

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 4 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

H() = H(e ) = h[0] + 2

P M2
1

h[n] cos n

But cos n = Tn (cos ): Chebyshev polynomial of 1st kind

cos 2 = 2 cos2 1 = T2 (cos )


cos 3 = 4 cos3 3 cos = T3 (cos )

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 4 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

H() = H(e ) = h[0] + 2

P M2
1

h[n] cos n

But cos n = Tn (cos ): Chebyshev polynomial of 1st kind

cos 2 = 2 cos2 1 = T2 (cos )


cos 3 = 4 cos3 3 cos = T3 (cos )
Recurrence Relation:

Tn+1 (x) = 2xTn (x) Tn1 (x) with T0 (x) = 1, T1 (x) = x

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 4 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

H() = H(e ) = h[0] + 2

P M2
1

h[n] cos n

But cos n = Tn (cos ): Chebyshev polynomial of 1st kind

cos 2 = 2 cos2 1 = T2 (cos )


cos 3 = 4 cos3 3 cos = T3 (cos )
Recurrence Relation:

Tn+1 (x) = 2xTn (x) Tn1 (x) with T0 (x) = 1, T1 (x) = x


Proof: cos (n + ) + cos (n ) = 2 cos cos n

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 4 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

H() = H(e ) = h[0] + 2

P M2
1

h[n] cos n

But cos n = Tn (cos ): Chebyshev polynomial of 1st kind

cos 2 = 2 cos2 1 = T2 (cos )


cos 3 = 4 cos3 3 cos = T3 (cos )
Recurrence Relation:

Tn+1 (x) = 2xTn (x) Tn1 (x) with T0 (x) = 1, T1 (x) = x


Proof: cos (n + ) + cos (n ) = 2 cos cos n
So H() is an M
2 order polynomial in cos : alternation theorem applies.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 4 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

H() = H(e ) = h[0] + 2

h[n] cos n

But cos n = Tn (cos ): Chebyshev polynomial of 1st kind

cos 2 = 2 cos2 1 = T2 (cos )


cos 3 = 4 cos3 3 cos = T3 (cos )

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

Recurrence Relation:

Tn+1 (x) = 2xTn (x) Tn1 (x) with T0 (x) = 1, T1 (x) = x


Proof: cos (n + ) + cos (n ) = 2 cos cos n
So H() is an M
2 order polynomial in cos : alternation theorem applies.
Example: Low-pass filter of length 5 (M = 4)
1.4

M=4

1.2
1
|g|

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

3.5

Optimal FIR: 7 4 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

H() = H(e ) = h[0] + 2

h[n] cos n

But cos n = Tn (cos ): Chebyshev polynomial of 1st kind

cos 2 = 2 cos2 1 = T2 (cos )


cos 3 = 4 cos3 3 cos = T3 (cos )

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

Recurrence Relation:

Tn+1 (x) = 2xTn (x) Tn1 (x) with T0 (x) = 1, T1 (x) = x


Proof: cos (n + ) + cos (n ) = 2 cos cos n
So H() is an M
2 order polynomial in cos : alternation theorem applies.
Example: Low-pass filter of length 5 (M = 4)
1.4

M=4

M=4

1.2

|g| (dB)

1
|g|

0.8
0.6

-5
-10

0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

-15
0.5

1.5

2.5

3.5

0.5

1.5

2.5

Optimal FIR: 7 4 / 11

Chebyshev Polynomials
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

H() = H(e ) = h[0] + 2

h[n] cos n

But cos n = Tn (cos ): Chebyshev polynomial of 1st kind

cos 2 = 2 cos2 1 = T2 (cos )


cos 3 = 4 cos3 3 cos = T3 (cos )

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

Recurrence Relation:

Tn+1 (x) = 2xTn (x) Tn1 (x) with T0 (x) = 1, T1 (x) = x


Proof: cos (n + ) + cos (n ) = 2 cos cos n
So H() is an M
2 order polynomial in cos : alternation theorem applies.
Example: Low-pass filter of length 5 (M = 4)
1.4

M=4

M=4

1.2

M=2

0
1

|g|

0.8
0.6

-5
g

|g| (dB)

0.5

-10

0.4
0
0.2
0
0

DSP and Digital Filters (2014-5490)

-15
0.5

1.5

2.5

3.5

0.5

1.5

2.5

-1

-0.5

0
cos()

0.5

Optimal FIR: 7 4 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

Maximal error locations occur either at band


edges or when dH
d = 0

1.2

M=18

1
0.8
|H|

7: Optimal FIR filters

0.6

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

0.4
0.2
0
0

0.5

1.5

2.5

Optimal FIR: 7 5 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

Maximal error locations occur either at band


edges or when dH
d = 0

1.2

M=18

1
0.8
|H|

7: Optimal FIR filters

0.6

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

0.4
0.2
0
0

0.5

1.5

2.5

Optimal FIR: 7 5 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Maximal error locations occur either at band


edges or when dH
d = 0

H() = h[0] + 2

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

P M2
1

1.2

M=18

1
0.8

h[n] cos n

|H|

7: Optimal FIR filters

0.6
0.4
0.2
0
0

0.5

1.5

2.5

Optimal FIR: 7 5 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Maximal error locations occur either at band


edges or when dH
d = 0

P M2

H() = h[0] + 2
= P (cos )

M=18

1
0.8

h[n] cos n

where P (x) is a polynomial of order M


2 .

DSP and Digital Filters (2014-5490)

1.2

|H|

7: Optimal FIR filters

0.6
0.4
0.2
0
0

0.5

1.5

2.5

Optimal FIR: 7 5 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Maximal error locations occur either at band


edges or when dH
d = 0

P M2

H() = h[0] + 2
= P (cos )

M=18

1
0.8

h[n] cos n

where P (x) is a polynomial of order M


2 .
dH
d

1.2

|H|

7: Optimal FIR filters

0.6
0.4
0.2
0
0

0.5

1.5

2.5

= P (cos ) sin

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 5 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Maximal error locations occur either at band


edges or when dH
d = 0

P M2

H() = h[0] + 2
= P (cos )

h[n] cos n

= P (cos ) sin
= 0 at = 0, and at most

DSP and Digital Filters (2014-5490)

M=18

1
0.8
0.6
0.4
0.2

where P (x) is a polynomial of order M


2 .
dH
d

1.2

|H|

7: Optimal FIR filters

M
2

0
0

0.5

1.5

2.5

1 zeros of polynomial P (x).

Optimal FIR: 7 5 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Maximal error locations occur either at band


edges or when dH
d = 0

P M2

H() = h[0] + 2
= P (cos )

h[n] cos n

= P (cos ) sin
= 0 at = 0, and at most

0.6
0.4
0.2

M
2

With two bands, we have at most

DSP and Digital Filters (2014-5490)

M=18

0.8

where P (x) is a polynomial of order M


2 .
dH
d

1.2

|H|

7: Optimal FIR filters

0
0

0.5

1.5

2.5

1 zeros of polynomial P (x).

M
2

+ 3 maximal error frequencies.

Optimal FIR: 7 5 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Maximal error locations occur either at band


edges or when dH
d = 0

P M2

H() = h[0] + 2
= P (cos )

M=18

1
0.8

h[n] cos n

= P (cos ) sin
= 0 at = 0, and at most

0.6
0.4
0.2

where P (x) is a polynomial of order M


2 .
dH
d

1.2

|H|

7: Optimal FIR filters

M
2

0
0

0.5

1.5

2.5

1 zeros of polynomial P (x).

With two bands, we have at most M


2 + 3 maximal error frequencies.
We require M
2 + 2 of alternating signs for the optimal fit.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 5 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Maximal error locations occur either at band


edges or when dH
d = 0

P M2

H() = h[0] + 2
= P (cos )

M=18

1
0.8

h[n] cos n

= P (cos ) sin
= 0 at = 0, and at most

0.6
0.4
0.2

where P (x) is a polynomial of order M


2 .
dH
d

1.2

|H|

7: Optimal FIR filters

M
2

0
0

0.5

1.5

2.5

1 zeros of polynomial P (x).

With two bands, we have at most M


2 + 3 maximal error frequencies.
We require M
2 + 2 of alternating signs for the optimal fit.
Only three possibilities exist (try them all):

(a) = 0 + two band edges + M


2 1 zeros of P (x).

1
zeros
of
P
(x).
(b) = + two band edges + M
2

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 5 / 11

Maximal Error Locations

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Maximal error locations occur either at band


edges or when dH
d = 0

P M2

H() = h[0] + 2
= P (cos )

M=18

1
0.8

h[n] cos n

= P (cos ) sin
= 0 at = 0, and at most

0.6
0.4
0.2

where P (x) is a polynomial of order M


2 .
dH
d

1.2

|H|

7: Optimal FIR filters

M
2

0
0

0.5

1.5

2.5

1 zeros of polynomial P (x).

With two bands, we have at most M


2 + 3 maximal error frequencies.
We require M
2 + 2 of alternating signs for the optimal fit.
Only three possibilities exist (try them all):

(a) = 0 + two band edges + M


2 1 zeros of P (x).

1
zeros
of
P
(x).
(b) = + two band edges + M
2

(c) = {0 and } + two band edges + M


2 2 zeros of P (x).

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 5 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 6 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).
2. Determine the error magnitude, , and the M
2 + 1 coefficients of
the polynomial that passes through the maximal error locations.

M=4
Iteration 1

1.5

|g|

1
0.5
0
-0.5
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).
2. Determine the error magnitude, , and the M
2 + 1 coefficients of
the polynomial that passes through the maximal error locations.
3. Find the local maxima of the error
 function by evaluating
e() = s() H() d() on a dense set of .

M=4
Iteration 1

1.5

|g|

1
0.5
0
-0.5
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).
2. Determine the error magnitude, , and the M
2 + 1 coefficients of
the polynomial that passes through the maximal error locations.
3. Find the local maxima of the error
 function by evaluating
e() = s() H() d() on a dense set of .

4. Update the maximal error frequencies to be an alternating subset of


the local maxima + band edges + {0 and/or }.

M=4
Iteration 1

1.5

|g|

1
0.5
0
-0.5
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).
2. Determine the error magnitude, , and the M
2 + 1 coefficients of
the polynomial that passes through the maximal error locations.
3. Find the local maxima of the error
 function by evaluating
e() = s() H() d() on a dense set of .

4. Update the maximal error frequencies to be an alternating subset of


the local maxima + band edges + {0 and/or }.
If maximum error is > , go back to step 2.

M=4
Iteration 1

1.5

|g|

1
0.5
0
-0.5
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).
2. Determine the error magnitude, , and the M
2 + 1 coefficients of
the polynomial that passes through the maximal error locations.
3. Find the local maxima of the error
 function by evaluating
e() = s() H() d() on a dense set of .

4. Update the maximal error frequencies to be an alternating subset of


the local maxima + band edges + {0 and/or }.
If maximum error is > , go back to step 2.

M=4
Iteration 1

1.5

M=4
Iteration 2
1

|g|

|g|

1
0.5
0

0.5

-0.5
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).
2. Determine the error magnitude, , and the M
2 + 1 coefficients of
the polynomial that passes through the maximal error locations.
3. Find the local maxima of the error
 function by evaluating
e() = s() H() d() on a dense set of .

4. Update the maximal error frequencies to be an alternating subset of


the local maxima + band edges + {0 and/or }.
If maximum error is > , go back to step 2. (typically 15 iterations)

M=4
Iteration 1

1.5

M=4
Iteration 2
1

|g|

|g|

1
0.5
0

0.5

-0.5
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).
2. Determine the error magnitude, , and the M
2 + 1 coefficients of
the polynomial that passes through the maximal error locations.
3. Find the local maxima of the error
 function by evaluating
e() = s() H() d() on a dense set of .

4. Update the maximal error frequencies to be an alternating subset of


the local maxima + band edges + {0 and/or }.
If maximum error is > , go back to step 2. (typically 15 iterations)

M=4
Iteration 1

1.5

M=4
Iteration 2

M=4
Iteration 3

0.5
0

|g|

|g|

|g|

1
0.5

0.5

-0.5
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

0.5

1.5

2.5

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).
2. Determine the error magnitude, , and the M
2 + 1 coefficients of
the polynomial that passes through the maximal error locations.
3. Find the local maxima of the error
 function by evaluating
e() = s() H() d() on a dense set of .

4. Update the maximal error frequencies to be an alternating subset of


the local maxima + band edges + {0 and/or }.
If maximum error is > , go back to step 2. (typically 15 iterations)

M=4
Iteration 1

1.5

M=4
Iteration 2

M=4
Iteration 3

0.5
0

|g|

|g|

|g|

1
0.5

0.5

-0.5
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

0.5

1.5

2.5

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Remez Exchange Algorithm


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

1. Guess the positions of the M


2 + 2 maximal error frequencies and give
alternating signs to the errors (e.g. choose evenly spaced ).
2. Determine the error magnitude, , and the M
2 + 1 coefficients of
the polynomial that passes through the maximal error locations.
3. Find the local maxima of the error
 function by evaluating
e() = s() H() d() on a dense set of .

4. Update the maximal error frequencies to be an alternating subset of


the local maxima + band edges + {0 and/or }.
If maximum error is > , go back to step 2. (typically 15 iterations)
5. Evaluate H() on M + 1 evenly spaced and do an IDFT to get h[n].
M=4
Iteration 1

1.5

M=4
Iteration 2

M=4
Iteration 3

0.5
0

|g|

|g|

|g|

1
0.5

0.5

-0.5
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

0.5

1.5

2.5

0.5

1.5

2.5

Optimal FIR: 7 6 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

(1)i
s(i )

= h[0] + 2

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

(1)i
s(i )

= h[0] + 2

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1:
M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

= h[0] + 2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1:
M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .
In step 3, evaluate H() = h[0] + 2

DSP and Digital Filters (2014-5490)

P M2

n=1

h[n] cos ni

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

= h[0] + 2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1: (Computation time M 3 )


M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .
In step 3, evaluate H() = h[0] + 2

DSP and Digital Filters (2014-5490)

P M2

n=1

h[n] cos ni

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

= h[0] + 2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1: (Computation time M 3 )


M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .
In step 3, evaluate H() = h[0] + 2

P M2

n=1

h[n] cos ni

Method 2: Dont calculate h[n] explicitly


Q
1
Multiply equations by ci = j6=i cos cos
and add:

P M2 +2
i=1

DSP and Digital Filters (2014-5490)

i

P M2
ci h[0] + 2 n=1 h[n] cos n +

(1)i
s(i )

P M2 +2
i=1

ci d(i )

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

= h[0] + 2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1: (Computation time M 3 )


M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .
In step 3, evaluate H() = h[0] + 2

P M2

n=1

h[n] cos ni

Method 2: Dont calculate h[n] explicitly


Q
1
Multiply equations by ci = j6=i cos cos
and add:

i
j

 PM
P M2
(1)i
2 +2
h[n]
cos
n
+
c
h[0]
+
2
=
i
n=1
i=1
i=1 ci d(i )
s(i )
All terms involving h[n] sum to zero leaving
P M2 +2 (1)i ci
P M2 +2
i=1
i=1 ci d(i )
s(i ) =

P M2 +2

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

= h[0] + 2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1: (Computation time M 3 )


M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .
In step 3, evaluate H() = h[0] + 2

P M2

n=1

h[n] cos ni

Method 2: Dont calculate h[n] explicitly


Q
1
Multiply equations by ci = j6=i cos cos
and add:

i
j

 PM
P M2
(1)i
2 +2
h[n]
cos
n
+
c
h[0]
+
2
=
i
n=1
i=1
i=1 ci d(i )
s(i )
All terms involving h[n] sum to zero leaving
P M2 +2 (1)i ci
P M2 +2
i=1
i=1 ci d(i )
s(i ) =

P M2 +2

Solve for

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

= h[0] + 2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1: (Computation time M 3 )


M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .
In step 3, evaluate H() = h[0] + 2

P M2

n=1

h[n] cos ni

Method 2: Dont calculate h[n] explicitly


Q
1
Multiply equations by ci = j6=i cos cos
and add:

i
j

 PM
P M2
(1)i
2 +2
h[n]
cos
n
+
c
h[0]
+
2
=
i
n=1
i=1
i=1 ci d(i )
s(i )
All terms involving h[n] sum to zero leaving
P M2 +2 (1)i ci
P M2 +2
i=1
i=1 ci d(i )
s(i ) =

P M2 +2

Solve for then calculate the H(i )

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

= h[0] + 2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1: (Computation time M 3 )


M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .
In step 3, evaluate H() = h[0] + 2

P M2

n=1

h[n] cos ni

Method 2: Dont calculate h[n] explicitly


Q
1
Multiply equations by ci = j6=i cos cos
and add:

i
j

 PM
P M2
(1)i
2 +2
h[n]
cos
n
+
c
h[0]
+
2
=
i
n=1
i=1
i=1 ci d(i )
s(i )
All terms involving h[n] sum to zero leaving
P M2 +2 (1)i ci
P M2 +2
i=1
i=1 ci d(i )
s(i ) =

P M2 +2

Solve for then calculate the H(i ) then use Lagrange interpolation:

H() = P (cos ) =
DSP and Digital Filters (2014-5490)

P M2 +2
i=1

H(i )

cos cos j
j6=i cos i cos j

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

= h[0] + 2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1: (Computation time M 3 )


M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .
In step 3, evaluate H() = h[0] + 2

P M2

n=1

h[n] cos ni

Method 2: Dont calculate h[n] explicitly


Q
1
Multiply equations by ci = j6=i cos cos
and add:

i
j

 PM
P M2
(1)i
2 +2
h[n]
cos
n
+
c
h[0]
+
2
=
i
n=1
i=1
i=1 ci d(i )
s(i )
All terms involving h[n] sum to zero leaving
P M2 +2 (1)i ci
P M2 +2
i=1
i=1 ci d(i )
s(i ) =

P M2 +2

Solve for then calculate the H(i ) then use Lagrange interpolation:

P M2 +2

cos cos

H() = P (cos ) = i=1 H(i ) j6=i cos i cos jj



M
2 + 1 -polynomial going through all the H(i ) [actually order

DSP and Digital Filters (2014-5490)

M
2 ]

Optimal FIR: 7 7 / 11

Determine Polynomial
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

For each extremal frequency, i for 1 i M


2 +2

d(i ) = H(i ) +

(1)i
s(i )

= h[0] + 2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

P M2

n=1

h[n] cos ni +

(1)i
s(i )

Method 1: (Computation time M 3 )


M
Solve M
2 + 2 equations in 2 + 2 unknowns for h[n] + .
In step 3, evaluate H() = h[0] + 2

P M2

n=1

h[n] cos ni

Method 2: Dont calculate h[n] explicitly (Computation time M 2 )


Q
1
Multiply equations by ci = j6=i cos cos
and add:

i
j

 PM
P M2
(1)i
2 +2
h[n]
cos
n
+
c
h[0]
+
2
=
i
n=1
i=1
i=1 ci d(i )
s(i )
All terms involving h[n] sum to zero leaving
P M2 +2 (1)i ci
P M2 +2
i=1
i=1 ci d(i )
s(i ) =

P M2 +2

Solve for then calculate the H(i ) then use Lagrange interpolation:

P M2 +2

cos cos

H() = P (cos ) = i=1 H(i ) j6=i cos i cos jj



M
2 + 1 -polynomial going through all the H(i ) [actually order

DSP and Digital Filters (2014-5490)

M
2 ]

Optimal FIR: 7 7 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

Filter Specifications:
Bandpass = [0.5, 1],

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

M=36

|H|

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

M=36

|H|

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

M=36

|H|

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB
Passband Ripple: 0.3 dB

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

M=36

|H|

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB
Passband Ripple: 0.3 dB
Determine gain tolerances for each band:
25 dB = 0.056, 0.3 dB = 1 0.034, 15 dB = 0.178

M=36

|H|

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB
Passband Ripple: 0.3 dB
Determine gain tolerances for each band:
25 dB = 0.056, 0.3 dB = 1 0.034, 15 dB = 0.178
Predicted order: M = 36

M=36

|H|

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB
Passband Ripple: 0.3 dB
Determine gain tolerances for each band:
25 dB = 0.056, 0.3 dB = 1 0.034, 15 dB = 0.178
Predicted order: M = 36
M
2 + 2 extremal frequencies are distributed between the bands

M=36

|H|

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB
Passband Ripple: 0.3 dB
Determine gain tolerances for each band:
25 dB = 0.056, 0.3 dB = 1 0.034, 15 dB = 0.178
Predicted order: M = 36
M
2 + 2 extremal frequencies are distributed between the bands
Filter meets specs ,

M=36

|H|

0.8
0.6
0.4
0.2
0
0

DSP and Digital Filters (2014-5490)

0.5

1.5

2.5

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB
Passband Ripple: 0.3 dB
Determine gain tolerances for each band:
25 dB = 0.056, 0.3 dB = 1 0.034, 15 dB = 0.178
Predicted order: M = 36
M
2 + 2 extremal frequencies are distributed between the bands
Filter meets specs ,; clearer on a decibel scale

M=36

|H| (dB)

|H|

0.8
0.6
0.4

DSP and Digital Filters (2014-5490)

-10
-15
-20
-25

0.2
0
0

M=36

-5

0.5

1.5

2.5

-30
0

0.5

1.5

2.5

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB
Passband Ripple: 0.3 dB
Determine gain tolerances for each band:
25 dB = 0.056, 0.3 dB = 1 0.034, 15 dB = 0.178
Predicted order: M = 36
M
2 + 2 extremal frequencies are distributed between the bands
Filter meets specs ,; clearer on a decibel scale
Most zeros are on the unit circle + three reciprocal pairs
1

M=36

|H| (dB)

|H|

0.8
0.6
0.4

DSP and Digital Filters (2014-5490)

1
0.5

-10
-15

-20

-0.5

-25

0.2
0
0

M=36

-5

0.5

1.5

2.5

-30
0

-1
0.5

1.5

2.5

-1

Optimal FIR: 7 8 / 11

Example Design
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Filter Specifications:
Bandpass = [0.5, 1], Transition widths: = 0.2
Stopband Attenuation: 25 dB and 15 dB
Passband Ripple: 0.3 dB
Determine gain tolerances for each band:
25 dB = 0.056, 0.3 dB = 1 0.034, 15 dB = 0.178
Predicted order: M = 36
M
2 + 2 extremal frequencies are distributed between the bands
Filter meets specs ,; clearer on a decibel scale
Most zeros are on the unit circle + three reciprocal pairs
Reciprocal pairs give a linear phase shift
1

M=36

|H| (dB)

|H|

0.8
0.6
0.4

DSP and Digital Filters (2014-5490)

1
0.5

-10
-15

-20

-0.5

-25

0.2
0
0

M=36

-5

0.5

1.5

2.5

-30
0

-1
0.5

1.5

2.5

-1

Optimal FIR: 7 8 / 11

FIR Pros and Cons


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Can have linear phase


no envelope distortion, all frequencies have the same delay ,
symmetric or antisymmetric: h[n] = h[n]n or h[n]n
antisymmetric filters have H(ej0 ) = H(ej ) = 0
symmetry means you only need M
2 + 1 multiplications

DSP and Digital Filters (2014-5490)

to implement the filter.

Optimal FIR: 7 9 / 11

FIR Pros and Cons


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Can have linear phase


no envelope distortion, all frequencies have the same delay ,
symmetric or antisymmetric: h[n] = h[n]n or h[n]n
antisymmetric filters have H(ej0 ) = H(ej ) = 0
symmetry means you only need M
2 + 1 multiplications
to implement the filter.

Always stable ,

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 9 / 11

FIR Pros and Cons


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Can have linear phase


no envelope distortion, all frequencies have the same delay ,
symmetric or antisymmetric: h[n] = h[n]n or h[n]n
antisymmetric filters have H(ej0 ) = H(ej ) = 0
symmetry means you only need M
2 + 1 multiplications
to implement the filter.

Always stable ,
Low coefficient sensitivity ,

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 9 / 11

FIR Pros and Cons


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Can have linear phase


no envelope distortion, all frequencies have the same delay ,
symmetric or antisymmetric: h[n] = h[n]n or h[n]n
antisymmetric filters have H(ej0 ) = H(ej ) = 0
symmetry means you only need M
2 + 1 multiplications
to implement the filter.

Always stable ,
Low coefficient sensitivity ,
Optimal design method fast and robust ,

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 9 / 11

FIR Pros and Cons


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Can have linear phase


no envelope distortion, all frequencies have the same delay ,
symmetric or antisymmetric: h[n] = h[n]n or h[n]n
antisymmetric filters have H(ej0 ) = H(ej ) = 0
symmetry means you only need M
2 + 1 multiplications
to implement the filter.

Always stable ,
Low coefficient sensitivity ,
Optimal design method fast and robust ,
Normally needs higher order than an IIR filter /
dBatten
Filter order M 3.5
where is the most rapid transition

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 9 / 11

FIR Pros and Cons


7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Can have linear phase


no envelope distortion, all frequencies have the same delay ,
symmetric or antisymmetric: h[n] = h[n]n or h[n]n
antisymmetric filters have H(ej0 ) = H(ej ) = 0
symmetry means you only need M
2 + 1 multiplications
to implement the filter.

Always stable ,
Low coefficient sensitivity ,
Optimal design method fast and robust ,
Normally needs higher order than an IIR filter /
dBatten
Filter order M 3.5
where is the most rapid transition
dBatten
dBatten
fs = 3.5
fs2
Filtering complexity M fs 3.5
fs2 for a given specification in unscaled units.

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 9 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

Optimal Filters: minimax error criterion

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors


in different frequency bands

Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

DSP and Digital Filters (2014-5490)

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

DSP and Digital Filters (2014-5490)

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

DSP and Digital Filters (2014-5490)

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs

Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs

Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)

multiple constant-gain bands separated by transition regions

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs

Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)

multiple constant-gain bands separated by transition regions


very robust, works for filters with M > 1000

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs

Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)

multiple constant-gain bands separated by transition regions


very robust, works for filters with M > 1000
Efficient: computation M 2

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs

Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)

DSP and Digital Filters (2014-5490)

multiple constant-gain bands separated by transition regions


very robust, works for filters with M > 1000
Efficient: computation M 2
can go mad in the transition regions

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs

Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)

multiple constant-gain bands separated by transition regions


very robust, works for filters with M > 1000
Efficient: computation M 2
can go mad in the transition regions

Modified version works on arbitrary gain function

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs

Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)

multiple constant-gain bands separated by transition regions


very robust, works for filters with M > 1000
Efficient: computation M 2
can go mad in the transition regions

Modified version works on arbitrary gain function

Does not always converge

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 10 / 11

Summary
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

Optimal Filters: minimax error criterion

use weight function, s(), to allow different errors

in different frequency bands


symmetric filter has zeros on unit circle or in reciprocal pairs
Response of symmetric filter is a polynomial in cos
Alternation Theorem: M
2 + 2 maximal errors with alternating signs

Remez Exchange Algorithm (also known as Parks-McLellan Algorithm)

multiple constant-gain bands separated by transition regions


very robust, works for filters with M > 1000
Efficient: computation M 2
can go mad in the transition regions

Modified version works on arbitrary gain function

Does not always converge


For further details see Mitra: 10.
DSP and Digital Filters (2014-5490)

Optimal FIR: 7 10 / 11

MATLAB routines
7: Optimal FIR filters

Optimal Filters
Alternation Theorem
Chebyshev Polynomials
Maximal Error Locations
Remez Exchange
Algorithm

firpm
firpmord
cfirpm
remez

optimal FIR filter design


estimate require order for firpm
arbitrary-response filter design
[obsolete] optimal FIR filter design

Determine Polynomial
Example Design
FIR Pros and Cons
Summary
MATLAB routines

DSP and Digital Filters (2014-5490)

Optimal FIR: 7 11 / 11

You might also like