# IIR issues when order is high

Thanks to all the people who helped me here, I finally achieved to implement a notch filter (*), with coefficients given by : http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html

When I do order=2 (number of poles=4, according to this website), all is working very well with :

y[n] = a0*x[n-4] + a1*x[n-3] + a2*x[n-2] + a3*x[n-1] + a4*x[n]
+ b0*y[n-4] + b1*y[n-3] + b2*y[n-2] + b3*y[n-1]


Great!

When I try to increase order (example : order=4 or even order=3 => number of poles=6), then the filter doesn't work anymore. Very quickly (after n=10 or 100), the signal is saturated to the max value : overflow !

(Nota : I work in double (64 bits) floating point).

Somebody told that the higher the order, the more unstable ! What to do then to solve this problem ?

Thank you very much in advance.

(*) The IIR filter is even ... linear-phase ... thanks to the trick that someone gave me (apply the filter on the signal, then reverse the signal, then apply the filter again, then reverse the signal) !

• Did you check to make sure that the passband gain is 1.0 ? Other than that, the ringing artefacts from a high Q notch may well result in clipping (take a look at the impulse response), so you may need to reduce the overall gain considerably to cope with this. Oct 18 '13 at 21:46
• PaulR, I used these settings (here www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html) : Butterworth, Bandstop, Filterorder=3, Samplerate=96000, cornerfreq1=430, cornerfreq2=450 (ie centered around 440hz, just for an example)... I haven't set any other setting. What do you mean by gain with this website-coefficient-generator?
– Basj
Oct 18 '13 at 21:48
• The passband gain is the ratio of output signal to input signal for e.g. a sine wave whose frequency is in the passband (i.e. nowhere near the notch). Typically you might want it to be 1.0 (so that most frequencies have unity gain) but if you have a lot of ringing artefacts then you might need to reduce it considerably to avoid clipping. Oct 18 '13 at 21:52
• If I change gain to something different to 1.0, then I'm unable to do subtraction between original file and filtered signal... I really need that !
– Basj
Oct 18 '13 at 21:54
• Not really - you can just scale the input file too, e.g. use a filter gain of 0.1 and then the subtraction would be 0.1 * input_file - filtered_file. Or you could use a floating point file format, and then clipping would be irrelevant (until you get to the point where you actually want to hear the resulting output). Oct 18 '13 at 22:00

Break higher order filters down into cascaded second order sections (or biquads). This is covered in every text book on DSP such as https://ccrma.stanford.edu/~jos/filters/

• So I'll continue to read these documentations. Does it give exactly the same result (cascaded second order sections instead of high order filter) ?
– Basj
Oct 18 '13 at 21:59
• Yes. The results are mathematically identical. Numerically it's not the same as the cascaded implementation is much more stable and has lower numerical noise. Oct 18 '13 at 22:24
• Waw this text book seems great but very very wide, do you remember in which part he speaks about "in order to do a filter of order 4, you must do ...x... passes of a filter order 2, with parameters ...y... and ...z...." ?
– Basj
Oct 18 '13 at 22:46

Try this link, its a bit easier to use than an online program. It can generate notch filters up to 20 poles (even if it is a bit absurd).

http://www.iowahills.com/4IIRFilterPage.html

The program gives both 2nd order coefficients (biquads) and Nth order polynomial coefficients. There is also example C code on the site that shows how to implement the filter in either form.

• Waw! Very interesting link and ressources! This is really the thing I was looking for! Thanks so much.
– Basj
Oct 19 '13 at 16:36