# Summation of two IIR filters

Actually my question is how to get the weighted average of two or three IIR filters given their transfer functions, which is nearly equal to this question. How to calculate the total transfer function of the summation of two IIR filters? For example, I have two filters as following

$$H_1(z) = \frac{b_0+b_1z^{-1}+b_2z^{-2}}{1+a_1z^{-1}+a_2z^{-2}}$$

$$H_2(z) = \frac{b_0'+b_1'z^{-1}+b_2'z^{-2}}{1+a_1'z^{-1}+a_2'z^{-2}}$$

I can directly solve the sum of these two fractions as $$H(z) = H_1(z)+H_2(z)$$, but the problem is that my filter orders are generally around dozens, I have no idea how to do it.

I also know that I can put a signal through this two filters and sum the output together, but it requires double computational complexity.

Is there any other way to solve this problem? Thanks!

In theory you just do it the same way. The transfer function of a weighted sum of filters with weights $$w_i$$ is just

$$H_{total}(z)=\sum_iw_iH_i(z)\tag{1}$$

where $$H_i(z)$$ are the individual transfer functions.

However, in general the order of the total transfer function is the sum of the orders of the individual filters, unless some filters share the same poles. Consequently, the resulting filter order can become too large for a practical implementation. If the orders of the individual filters "are generally around dozens" then you have a problem, even using floating point arithmetic.

• Thank you Matt. Therefore, the computational complexity of weighted sum of outputs and that of a total transfer function are generally the same. So is there any approximate or interpolation methods to calculate the total transfer function with the same filter order? – ZR Han Dec 14 '20 at 8:14
• @ZRHan: It really depends on the filter's transfer function. I actually think that there's some issue with the problem formulation. Individual filters with orders of several dozens shouldn't be necessary in the first place. – Matt L. Dec 14 '20 at 8:19
• My fundamental problem is that I use yule-walk's method to model a head-related transfer function (HRTF), and due to HRTF is measured at discrete positions, I need to interpolate the spatial filters. The filter order I use is around 20 or 30. BTW, I tried to directly use the average of numerators and denominators respectively as the new coefficients, which seems work fine and will not derive an unstable filter. The reason I guess may be that the filter responses used for interpolation are close enough. – ZR Han Dec 14 '20 at 9:10
• @ZRHan: If computational complexity is not the limiting factor, I would try to solve that using FIR filters. – Matt L. Dec 14 '20 at 10:52
• Lower computational cost is still prefered. FIR filters are theoretical correct, but require too much taps (generally 512 or 256 taps at 48kHz), and FFT is also not computational efficient enough. – ZR Han Dec 14 '20 at 10:59

Here I find a solution and the idea is originated from MATLAB's sos2tf function, which uses the conv function to multiply all of the numerator and denominator second-order polynomials together.

Say the numerator vectors and denominator vectors of two IIR filters are $$b_1$$, $$a_1$$, $$b_2$$ and $$a_2$$, respectively. The numerator and denominator of the total transfer function are $$\begin{equation} a = a_1*a_2 \end{equation}$$

$$\begin{equation} b = b_1*a_2 + b_2*a_1 \end{equation}$$ respectively, where $$*$$ represents linear convolution.

Here's some validation code

b1 = [1 2 3 4 5];
a1 = [5 4 3 2 1];
b2 = [6 7 8 9 10];
a2 = [10 9 8 7 6];
b = conv(b1, a2) + conv(b2, a1);
a = conv(a1, a2);

h1 = impz(b1, a1, 60);
h2 = impz(b2, a2, 60);
h = impz(b, a, 60);

figure; subplot(211); stem(h)
subplot(212); stem(h1 + h2)


The results are 