To pose the constrained least squared error optimization problem, we use
a Lagrange multiplier formulation. First define the Lagrangian as
L
=
P
∫
0
π
(
A
(
ω
)
-
A
d
(
ω
)
)
2
d
ω
+
∑
i
μ
i
A
(
ω
i
)
-
[
A
d
(
ω
i
)
±
T
(
ω
i
)
]
L
=
P
∫
0
π
(
A
(
ω
)
-
A
d
(
ω
)
)
2
d
ω
+
∑
i
μ
i
A
(
ω
i
)
-
[
A
d
(
ω
i
)
±
T
(
ω
i
)
]
(1)where the μiμi are the necessary number of Langrange multipliers and
PP is a scale factor that can be chosen for simplicity later. The
first term in Equation 1 is the integral squared error of the frequency
response to be minimized and the second term will be zero when the equality
constraints are satisfied at the frequencies, ωiωi.
The function T(ω)T(ω) is the constraint function in that A(ω)A(ω)
must satisfy
A
d
(
ω
)
+
T
(
ω
)
≥
A
(
ω
)
≥
A
d
(
ω
)
-
T
(
ω
)
.
A
d
(
ω
)
+
T
(
ω
)
≥
A
(
ω
)
≥
A
d
(
ω
)
-
T
(
ω
)
.
(2)Necessary
conditions for the minimization of the integral squared error are that the
derivative of the Lagrangian with respect to the filter parameters a(n)a(n)
defined in Equation 49 from FIR Digital Filters
and to the Lagrange multipliers μiμi be zero [69].
The derivatives of the Lagrangian with respect to a(n)a(n) are
d
L
d
a
(
n
)
=
P
∫
0
π
2
(
A
(
ω
)
-
A
d
(
ω
)
)
d
A
d
a
d
ω
+
∑
i
μ
i
d
A
d
a
ω
i
d
L
d
a
(
n
)
=
P
∫
0
π
2
(
A
(
ω
)
-
A
d
(
ω
)
)
d
A
d
a
d
ω
+
∑
i
μ
i
d
A
d
a
ω
i
(3)where from Equation 49 from FIR digital Filters we have for n=1,2,⋯,Mn=1,2,⋯,M
d
A
(
ω
)
d
a
(
n
)
=
cos
(
ω
n
)
d
A
(
ω
)
d
a
(
n
)
=
cos
(
ω
n
)
(4)and for n=0n=0
d
A
(
ω
)
d
a
(
0
)
=
K
.
d
A
(
ω
)
d
a
(
0
)
=
K
.
(5)For n=1,2,⋯,Mn=1,2,⋯,M this gives
d
L
d
a
(
n
)
=
2
P
∫
A
(
ω
)
cos
(
ω
n
)
d
ω
-
∫
A
d
(
ω
)
cos
(
ω
n
)
d
ω
+
∑
i
μ
i
cos
(
ω
i
n
)
d
L
d
a
(
n
)
=
2
P
∫
A
(
ω
)
cos
(
ω
n
)
d
ω
-
∫
A
d
(
ω
)
cos
(
ω
n
)
d
ω
+
∑
i
μ
i
cos
(
ω
i
n
)
(6)and for n=0n=0 gives
d
L
d
a
(
0
)
=
2
P
K
∫
A
(
ω
)
d
ω
-
∫
A
d
(
ω
)
d
ω
+
∑
i
μ
i
K
.
d
L
d
a
(
0
)
=
2
P
K
∫
A
(
ω
)
d
ω
-
∫
A
d
(
ω
)
d
ω
+
∑
i
μ
i
K
.
(7)Using Equation 50 from FIR Digital Filters for n=1,2,⋯,Mn=1,2,⋯,M, we have
d
L
d
a
(
n
)
=
π
P
a
(
n
)
-
a
d
(
n
)
+
∑
i
μ
i
cos
(
ω
i
n
)
=
0
d
L
d
a
(
n
)
=
π
P
a
(
n
)
-
a
d
(
n
)
+
∑
i
μ
i
cos
(
ω
i
n
)
=
0
(8)and for n=0n=0
d
L
d
a
(
0
)
=
2
π
P
K
2
a
(
0
)
-
a
d
(
0
)
+
K
∑
i
μ
i
=
0
.
d
L
d
a
(
0
)
=
2
π
P
K
2
a
(
0
)
-
a
d
(
0
)
+
K
∑
i
μ
i
=
0
.
(9)Choosing P=1/πP=1/π gives
a
(
n
)
=
a
d
(
n
)
-
∑
i
μ
i
cos
(
ω
i
n
)
a
(
n
)
=
a
d
(
n
)
-
∑
i
μ
i
cos
(
ω
i
n
)
(10)and
a
(
0
)
=
a
d
(
0
)
-
1
2
K
∑
i
μ
i
a
(
0
)
=
a
d
(
0
)
-
1
2
K
∑
i
μ
i
(11)Writing Equation 10 and Equation 11 in matrix form gives
a
=
a
d
-
H
μ
.
a
=
a
d
-
H
μ
.
(12)where HH is a matrix with elements
h
(
n
,
i
)
=
cos
(
ω
i
n
)
h
(
n
,
i
)
=
cos
(
ω
i
n
)
(13)except for the first row which is
h
(
0
,
i
)
=
1
2
K
h
(
0
,
i
)
=
1
2
K
(14)because of the normalization of the a(0)a(0) term. The ad(n)ad(n) are the
cosine coefficients for the unconstrained approximation to the ideal
filter which result from truncating the inverse DTFT of Ad(ω)Ad(ω).
The derivative of the Lagrangian in Equation 1 with respect to the Lagrange
multipliers μiμi, when set to zero, gives
A
(
ω
i
)
=
A
d
(
ω
i
)
±
T
(
ω
i
)
=
A
c
(
ω
i
)
A
(
ω
i
)
=
A
d
(
ω
i
)
±
T
(
ω
i
)
=
A
c
(
ω
i
)
(15)which is simply a statement of the equality constraints.
In terms of the filter's cosine coefficients a(n)a(n), from Equation 49 from FIR Digital Filters, this
can be written"
A
c
(
ω
i
)
=
∑
n
a
(
n
)
cos
(
ω
i
n
)
+
K
a
(
0
)
A
c
(
ω
i
)
=
∑
n
a
(
n
)
cos
(
ω
i
n
)
+
K
a
(
0
)
(16)and as matrices
where AcAc is the vector of frequency response values which are the
desired response plus or minus the constraints evaluated at the
frequencies in the constraint set. The frequency response must
interpolate these values. The matrix GG is
g
(
i
,
n
)
=
cos
(
ω
i
n
)
g
(
i
,
n
)
=
cos
(
ω
i
n
)
(18)except for the first column which is
g
(
i
,
0
)
=
K
.
g
(
i
,
0
)
=
K
.
(19)Notice that if K=1/2K=1/2, the first rows and columns are such that we
have GT=HGT=H.
The two equations Equation 12 and Equation 17 that must be satisfied can be
written as a single matrix equation of the form
I
H
G
0
a
μ
=
a
d
A
c
I
H
G
0
a
μ
=
a
d
A
c
(20)or, if K=1/2K=1/2, as
I
G
T
G
0
a
μ
=
a
d
A
c
I
G
T
G
0
a
μ
=
a
d
A
c
(21)which have as solutions
μ
=
(
G
H
)
-
1
(
G
a
d
-
A
c
)
a
=
a
d
-
H
μ
μ
=
(
G
H
)
-
1
(
G
a
d
-
A
c
)
a
=
a
d
-
H
μ
(22)The filter corresponding to the cosine coefficients a(n)a(n) minimize the
L2L2 error norm subject the equality conditions in Equation 17.
Notice that the term in Equation 22 of the form GadGad is the
frequency response of the optimal unconstrained filter evaluated at the
constraint set frequencies. Equation Equation 22 could, therefore, be
written
μ
=
(
G
H
)
-
1
(
A
u
-
A
c
)
μ
=
(
G
H
)
-
1
(
A
u
-
A
c
)
(23)