IIR filters can create sharp changes in signals using fewer parts. This makes them faster and simpler to use.
Why IIR filters achieve sharp response with fewer coefficients in Signal Processing
y[n] = b0*x[n] + b1*x[n-1] + ... + bM*x[n-M] - a1*y[n-1] - ... - aN*y[n-N]
This formula shows how IIR filters use both current and past inputs (x) and past outputs (y).
The 'a' and 'b' values are coefficients that control the filter's behavior.
y[n] = 0.5*x[n] + 0.5*x[n-1] - 0.3*y[n-1]
y[n] = 0.2*x[n] + 0.2*x[n-1] + 0.2*x[n-2] - 0.4*y[n-1] - 0.1*y[n-2]
This code shows how an IIR filter uses a few coefficients to create a sharp frequency response. It plots the filter's amplitude across frequencies and prints how many coefficients it uses.
import numpy as np import matplotlib.pyplot as plt from scipy.signal import lfilter, freqz # Define IIR filter coefficients (simple low-pass) b = [0.2929, 0.5858, 0.2929] # numerator coefficients a = [1.0, 0.0, 0.1716] # denominator coefficients # Frequency response w, h = freqz(b, a, worN=8000) # Plot frequency response plt.plot(w / np.pi, 20 * np.log10(abs(h))) plt.title('IIR Filter Frequency Response') plt.xlabel('Normalized Frequency (xπ rad/sample)') plt.ylabel('Amplitude (dB)') plt.grid(True) plt.show() # Print number of coefficients print(f'Number of numerator coefficients: {len(b)}') print(f'Number of denominator coefficients: {len(a)}')
IIR filters use feedback, which helps them achieve sharp responses with fewer coefficients.
Because of feedback, IIR filters can sometimes be less stable than other filters, so design carefully.
IIR filters use past outputs and inputs to create sharp signal changes.
They need fewer coefficients than other filters to get the same sharpness.
This makes IIR filters efficient and fast for many real-world uses.