# Combining multiple bandstop filters works only sometimes

for a school project, we were supposed to filter out 4 rogue cosine waves of a given frequency. I created a filter of my own by choosing zeroes and poles by hand. Here, I made 4 poles and 4 zeroes (and a conjugated pair to each one):

I put these zeroes in one array, all these poles into another, and by using np.poly on both of these arrays, I made the B and A coefficients of a filter. The resulting filter frequency response was what I expected:

However, this filter was not perfect enough, so I made a different one using scipy.buttord and scipy.butter. I made four separate bandstop filters, one for each rogue cosine wave. Each bandstop filter had 4 zeroes on the same place and 4 poles around the same-place zeroes (they had their conjugate parts on the other side of the unit circle) like this:

What I wanted to do next was combine these four filters into one. So what I did was concatenate the four arrays of zeroes into one, then concatenate four different arrays of poles into one. Then, using np.poly, I thought I would receive the coefficients of the resulting filter. However, the frequency response looks like this (obviously wrong):

I did some reading and I've been unable to see why this happens. If combining multiple filters like this was not possible, why did it work the first time in my handmade filter? If it is possible, why does it not work here, for the generated filter?

edit:

This is how the frequency response of a single filter looks like. The remaining three look the same, except the zero is at different frequencies.

• how is this "obviously" wrong? Does it not have nulls at the frequencies you need to suppress? I honestly don't understand why that amplitude response should be wrong, could you please elaborate? Dec 27, 2021 at 14:38
• @MarcusMüller The frequency response should look very similar to the one I made by hand. It should be 1 everywhere except the frequencies I need to filter out (875, 1750, 2625, 3500) where it should be 0. Dec 27, 2021 at 14:39
• hm, to me it looks much better at being constant over most of the range than your manual design. And again, from the plot I really can't say whether your four frequencies are suppressed or not – it's simply not a useful visualization for that, it probably doesn't sample the frequency response at these points, exactly Dec 27, 2021 at 14:41
• @MarcusMüller I edited my question, I added the response of a single filter. Dec 27, 2021 at 14:41
• @MarcusMüller I thought it should be 0 at the frequencies I need to remove (875, 1750, 2625, 3500), whereas from the combined frequency response it is apparent that it does not supress the 1750Hz one, it even amplifies it. Dec 27, 2021 at 14:43