# Least Squares Filter Design: Deriving the Objective Function

I'm following the derivation in this paper A Comb Filter Design Using Fractional-Sample Delay to obtain the objective function for the least-squares filter design.

N-order FIR filter:

$$H(z) = \sum_{n=0}^N h(n)z^{-n}$$

Frequency response:

$$H(\omega) = \mathbf{h}^T\mathbf{e}(\omega) = \mathbf{e}^T(\omega)\mathbf{h}$$

where $$\mathbf{h}=[h(0)\quad h(1) \quad\dots \quad h(N)]$$ and $$\mathbf{e}=[1\quad e^{-j\omega} \quad\dots \quad e^{-jN\omega}]$$

Least squares error:

$$J(h)=\int_{\omega \in R^+\cup R^-} |H(\omega)-F_d(\omega)|^2 d\omega$$

where $$R^+=[0,\alpha\omega]$$ and $$R^-=[-\alpha\omega,0]$$

Which is rewritten in the quadratic form: $$J(h) =h^TQh - 2h^Tp + c$$

$$Q$$, $$p$$, and $$c$$ are given in the paper as follows: $$F_d(\omega)= e^{-jD\omega}$$ and $$h(n)$$ is real.

I've been having trouble with getting these expressions for the Q matrix and p vector. How can I obtain them?

$$J(h) = \int_{R^+UR-}|e^Th-F_d|^2d\omega\tag{1}\\ = \int(e^Th-F_d)^H(e^Th-F_d)d\omega\\ = \int((e^Th)^H(e^Th) + F_d^HF_d -(e^Th)^HF_d - F_d^He^Th)d\omega\\ = h^H(\int(e^T)^He^Td\omega) h + \int |F_d|^2d\omega -\int (2 Re\{(e^Th)^HF_d\})d\omega$$ The second term in above integral is the integral of $$L_2$$ norm of $$F_d$$ in the region $$R^+ U R^-$$. Since $$F_d(\omega)$$ is symmetric about $$\omega = 0$$, this integral will be $$2 \times \int_{R^+}|F_d(\omega)|^2d\omega$$ which is $$c$$ in your questions.
The first term, the argument inside integral is the outer product of column vector $$(e^H)^T$$ with row vector $$e^T$$. Again, this will conjugate of each for the regions $$R^+$$ and $$R^-$$ (shown later in the appendix). So integral over both regions will result in the real value of integral $$e^H e$$. Also, since $$H$$ is real, $$h^H=h^T$$. So the first term can be rewritten as (for simplicity dropping $$T$$ notation as it is assumed to be a column vector) $$h^T(\int_{R^+}2Re\{ ee^H\}d\omega )h\\ = h^TQh$$
The third term is the result of sum of 2 conjugate terms. Again this is symmetric about $$\omega=0$$. Also, since $$H$$ is real, $$h^H=h^T$$. Taking out $$2h^T$$ from the integral we have $$2h^T\int_{R+}2Re\{F_de^H \}d\omega = 2h^Tp$$ Therefore, summing and rearranging the 3 terms, $$J(h) = h^TQh - 2h^Tp + c$$
Appendix: Showing that $$ee^H$$ is conjugate of each other in $$R^+$$ and $$R^-$$. $$E_{mn}$$, element of $$ee^H$$ is $$e^{-jm\omega}e^{-jn\omega} = e^{-j(m+n)\omega}$$. In $$R^-$$, this element is $$e^{j(m+n)\omega}$$ which is $$E_{mn}^*$$