$ \frac{1}{f^2} $ Weighting for Least Squares FIR I am currently modifying the firls.m from Octave to allow all types of FIRs, differentiators, and Hilbert transformers, while taking a peak at Matlab's. I see there that, for differentiators, the default weighting is 1/f^2. In Selesnick's paper there's no mention of this. Does anyone know how to achieve it?

My thoughts go to $\int{K(\omega)\cos(n\omega)d\omega}$ (and the rest). Does it derive from $\int{K(\omega)^2\cos(n\omega)d\omega}$ ? Or from $\int{\left[\int{K(\omega)d\omega}\right]\cos(n\omega)d\omega}$ ? Does anyone have a hint?



I just thought of it this way: if it uses a $1/f^2$ weighting, doesn't that mean that the weighting $K(\omega)$ becomes $1/\omega^2$ ? So, the integral would become:

$$\frac{1}{\pi}\int_0^{\pi}{K(\omega)\cos(n\omega)d\omega}=\frac{1}{\pi}\int_0^{\pi}{\frac{\cos(n\omega)}{\omega^2}d\omega}$$

which is similar to the exponential cosine integral, without the log part. Further on there's:

$$\frac{in}{2}\left[\Gamma(-1,in\omega)-\Gamma(-1,-in\omega)\right]$$

The nice thing is that there is no imaginary part in the result. Maybe I'm hoping too much?
Well the page you link to says:


  'differentiator' for type III and type IV filters, using a special weighting technique. For nonzero amplitude bands, the integrated squared error has a weight of (1/f)2 so that the error at low frequencies is much smaller than at high frequencies. For FIR differentiators, which have an amplitude characteristic proportional to frequency, the filters minimize the relative integrated squared error (the integral of the square of the ratio of the error to the desired amplitude).


Bolding mine.

So, following the paper:
$$
\epsilon_2 = \int_0^\pi W(\omega)(A(\omega)−D(\omega))^2d\omega
$$
for the differentiator, we want:
$$
W(\omega) = \frac{1}{\omega^2}\\
D(\omega) = \omega
$$
and $A(\omega)$ has the same form as before.

So
$$
\epsilon_2 = \int_0^\pi \frac{1}{\omega^2}(A(\omega) - \omega)^2 d\omega\\
= \int_0^\pi \left[\frac{A^2(\omega)}{\omega^2} - 2\frac{A(\omega)}{\omega} + 1 \right] d\omega
$$
Just substitute the expression for $A(\omega)$ and you're done.