# invfreqz matlab/octave function, underlying theory

Started by December 18, 2008
```Hello,
I would like to write (or find) a modified version of "invfreqz" that
gives poles and zeros instead of coefficients.  Of course I could first
compute the coefficients and then convert to poles and zeros by
root-finding, but I wonder if this isn't an unecessary detour.
Can anybody point me to documents that give me some insight into
the underlying mechanism applied by "invfreqz".  Of course I
can read the code of the function, but it would help to have
some additional mathematical documentation in order to understand
how (and why) the code works.
The help text goes like this:

[b,a] = invfreqz(h,w,nb,na)
"Computes a digital filter where the least squared fits to the frequency
response data. If you do not specify maxiter, tol, and 'trace', invfreqz
computes the filter that minimizes sum|b-h*a|^2*wf. Otherwise, invfreqz
uses the Gauss-Newton method to compute the filter that minimizes
sum|b/a-h|^2*wf."

Intuitively, I would think that one could also modify the poles
and zeros of the transfer function given in factored form, in
order to minimize sum|q/p-h|^2 using q/p (pole-zero form of
the polynomial).(?)

Additionaly, if anybody could explain me, how this relates to
the prony-method and yule-walker eq., it would be of help as well.
My understanding is that prony and yulewalker calculate the best
fit to the time-domain impulse-response.  I am exclusively interested
in the best approximation to the magnitudes of the freq-response.
That is why I chose to find out how invfreqz works, instead of digging
into prony's method or yulewalker.

thanks,
Bjoern

```
```banton wrote:

> [b,a] = invfreqz(h,w,nb,na)
> "Computes a digital filter where the least squared fits to the
> frequency response data. If you do not specify maxiter, tol, and
> 'trace', invfreqz computes the filter that minimizes
> sum|b-h*a|^2*wf. Otherwise, invfreqz uses the Gauss-Newton
> method to compute the filter that minimizes sum|b/a-h|^2*wf."
>
> Intuitively, I would think that one could also modify the poles
> and zeros of the transfer function given in factored form, in
> order to minimize sum|q/p-h|^2 using q/p (pole-zero form of
> the polynomial).(?)

While you can parametrize the filter any way you want, using
polynomial coefficients gives the tamest objective function. The
linear dependence on numerator coefficients has a part in that and
can also be exploited by specialized algorithms, and the problem is
easily linearized as your quotation mentions. By contrast, all
factored-form parameters enter through products which may slow
convergence and creates more local minima to get stuck in.

That said, both filter formulations have been tried in optimization;
see references following eq. 5.2 in . Regarding the workings of
invfreqz, information on both linear least-squares and Gauss-Newton
is abundant on the web.

 Lang, Algorithms for the constrained design of digital filters
with arbitrary mangnitude and phase responses

Martin

--
Quidquid latine scriptum est, altum videtur.
```
```>banton wrote:
>
>> [b,a] = invfreqz(h,w,nb,na)
>> "Computes a digital filter where the least squared fits to the
>> frequency response data. If you do not specify maxiter, tol, and
>> 'trace', invfreqz computes the filter that minimizes
>> sum|b-h*a|^2*wf. Otherwise, invfreqz uses the Gauss-Newton
>> method to compute the filter that minimizes sum|b/a-h|^2*wf."
>>
>> Intuitively, I would think that one could also modify the poles
>> and zeros of the transfer function given in factored form, in
>> order to minimize sum|q/p-h|^2 using q/p (pole-zero form of
>> the polynomial).(?)
>
>While you can parametrize the filter any way you want, using
>polynomial coefficients gives the tamest objective function. The
>linear dependence on numerator coefficients has a part in that and
>can also be exploited by specialized algorithms, and the problem is
>easily linearized as your quotation mentions. By contrast, all
>factored-form parameters enter through products which may slow
>convergence and creates more local minima to get stuck in.

Ok, I understand.  So maybe I should stick to the idea of
finding the coefficients first and use root finding on the
numerator and denominator polynomials to get to the poles and
zeros.

>That said, both filter formulations have been tried in optimization;
>see references following eq. 5.2 in . Regarding the workings of
>invfreqz, information on both linear least-squares and Gauss-Newton
>is abundant on the web.
>
> Lang, Algorithms for the constrained design of digital filters
>with arbitrary mangnitude and phase responses