Web Simulation 

 

 

 

 

Infinite Impulse Response (IIR) Filter Tutorial 

This interactive tutorial demonstrates Infinite Impulse Response (IIR) Filters, a powerful and efficient class of digital filters used throughout signal processing. Unlike FIR filters, IIR filters use feedback (recursion)—the output depends not only on past inputs but also on past outputs. This recursion creates an infinitely long impulse response from just a few coefficients.

The simulation visualizes the core concept of Recursive Filtering—showing both the feedforward path (input processing) and the feedback path (output recursion). You can observe how poles and zeros in the Z-plane determine filter behavior, and critically, how pole locations determine stability. IIR filters can become unstable if poles move outside the unit circle!

How IIR Filters Work

An IIR filter processes a signal using both current/past inputs AND past outputs:

y[n] = b[0]·x[n] + b[1]·x[n-1] + ... - a[1]·y[n-1] - a[2]·y[n-2] - ...

Or more compactly:

y[n] = Σk=0M b[k]·x[n-k] − Σk=1N a[k]·y[n-k]

where:

  • y[n] is the output sample at time n
  • x[n] is the input sample at time n
  • b[k] are the feedforward coefficients (numerator) - multiply past inputs
  • a[k] are the feedback coefficients (denominator) - multiply past outputs
  • a[0] is always normalized to 1

Mathematical Foundation

Transfer Function: In the Z-domain, the IIR filter is a ratio of polynomials:

H(z) = B(z)/A(z) = (b[0] + b[1]z-1 + b[2]z-2 + ...) / (1 + a[1]z-1 + a[2]z-2 + ...)

The zeros of H(z) are the roots of B(z) - they create nulls in the frequency response. The poles are the roots of A(z) - they create peaks and determine stability.

Stability Criterion: An IIR filter is stable if and only if:

All poles |pk| < 1 (inside the unit circle)

If any pole has magnitude ≥ 1, the filter becomes unstable—the output grows without bound!

Bilinear Transform: IIR filters are typically designed in the analog (s-domain) and converted to digital using the bilinear transform:

s = (2/T) · (z-1)/(z+1)

This maps the entire left half of the s-plane (stable analog filters) to inside the unit circle (stable digital filters).

 

0.15π
1x 35%

IIR Filter Structure

LIVE CALCULATION: y[n]
FEEDFORWARD:
RESULT:
Input x[n]
Feedforward b[k]
Feedback a[k]
Output y[n]
TIME DOMAIN: Input Signal x[n]
TIME DOMAIN: Filtered Output y[n] (with feedback)
FREQUENCY DOMAIN: Magnitude Response |H(ω)|
Z-PLANE: Poles (×) & Zeros (○)

Filter Information

Filter Type: Low Pass (Butterworth)
Filter Order: 2
Stability: STABLE
DC Gain: 1.0000

 

Usage Example

Follow these steps to explore the IIR Filter visualization:

  1. Initial View: When you first load the simulation, you'll see:
    • Three dropdown menus for Filter Type, Design Method, and Signal Type
    • A coefficient display showing both b[k] (feedforward) and a[k] (feedback) coefficients
    • An input signal canvas with the feedforward window highlighted
    • An output signal canvas with the feedback window highlighted
    • A frequency response plot (dB scale by default)
    • A Z-plane plot showing poles (×) and zeros (○) with stability indicator
  2. Observe the Recursion: Unlike FIR filters, IIR filters feed the output back into the calculation. The orange "FEEDFORWARD" box shows input samples being processed, while the red "FEEDBACK" box shows output samples being used recursively.
  3. Select Filter Type and Design Method: Use the dropdowns to experiment:
    • Filter Types: Low Pass, High Pass, Band Pass, Band Stop
    • Design Methods: Butterworth, Chebyshev I/II, Elliptic, Bessel
    • Signal Types: Sine, Square, Multi-tone, Chirp, Impulse, Step, White Noise
    Watch how different methods produce different pole-zero patterns!
  4. Watch the Z-Plane: The pole locations are CRITICAL for IIR filters:
    • Poles inside the unit circle → STABLE filter
    • Poles on or outside the unit circle → UNSTABLE filter
    • Poles near the unit circle → sharper frequency response but closer to instability
  5. Use Impulse Response: Select "Impulse" signal to see the filter's impulse response. Unlike FIR filters (finite duration), IIR impulse responses decay exponentially but theoretically last forever—hence "Infinite Impulse Response"!
  6. Use Step Response: Select "Step" signal to observe transient behavior. IIR filters may exhibit overshoot and ringing, especially with higher Q factors.

Key Insight: IIR filters achieve sharper frequency cutoffs with fewer coefficients than FIR filters because the feedback creates resonance. However, this efficiency comes at the cost of potential instability and non-linear phase response.

Filter Types

The Filter Type dropdown selects what frequency bands to pass or reject:

  • Low Pass: Passes low frequencies, attenuates high frequencies. The classic "smoothing" filter.
  • High Pass: Passes high frequencies, attenuates low frequencies. Removes DC offset and slow variations.
  • Band Pass: Passes frequencies within a specific band. Creates a resonant "peak" in the response.
  • Band Stop (Notch): Rejects a specific frequency band. Creates a "notch" or null in the response.

Signal Types

The Signal dropdown selects the input test signal. The Noise slider adds controllable noise to all signals (except White Noise):

  • Sine: Pure sine wave. Add noise with the Noise slider to see noise rejection.
  • Square: Simple square wave. Great for seeing harmonic filtering and overshoot.
  • Multi-tone: Three sine waves at different frequencies. Shows frequency selectivity.
  • Square+Multi: Square wave combined with sine tones. Shows harmonic filtering.
  • Chirp: Frequency sweep signal. Shows filter response across all frequencies.
  • Impulse: Periodic impulses. Shows the impulse response—the "fingerprint" of the filter. IIR impulse responses decay but never truly end.
  • Step: Step function. Shows transient response, overshoot, and settling time.
  • White Noise: Pure random signal. Shows overall frequency shaping.

Design Methods

The Design Method dropdown selects the IIR filter design approach. Each method represents a different tradeoff:

  • Butterworth: "Maximally flat" magnitude response in the passband. No ripples, but gradual rolloff. Poles are evenly spaced on a circle. Best general-purpose choice when you want smooth response.
  • Chebyshev Type I: Allows controlled ripples in the passband to achieve steeper rolloff than Butterworth. Poles lie on an ellipse. Use when you need sharper cutoff and can tolerate passband variations.
  • Chebyshev Type II: Flat passband (like Butterworth) but with ripples in the stopband. Provides steeper rolloff than Butterworth while keeping the passband smooth.
  • Elliptic (Cauer): Ripples in BOTH passband and stopband. Achieves the steepest possible rolloff for a given order. Use when transition width must be minimized at all costs.
  • Bessel: Maximally flat GROUP DELAY (not magnitude). Preserves the shape of signals passing through—no overshoot or ringing on step response. Sacrifices sharp cutoff for linear phase approximation.

Parameters

Descriptions of each parameter:

  • Feedforward Coefficients b[k]: These multiply the current and past INPUT samples. They define the filter's zeros (roots of the numerator polynomial). Zeros create nulls in the frequency response.
  • Feedback Coefficients a[k]: These multiply past OUTPUT samples and create the recursive behavior. They define the filter's poles (roots of the denominator polynomial). a[0] is always 1 (normalized). Poles create peaks in the response and determine stability.
  • Filter Order: The number of poles (and zeros). Higher order = sharper cutoff but more computation and closer to instability. A 2nd-order IIR can match a ~20th-order FIR in sharpness!
  • Cutoff Frequency (ω): The -3dB point where the filter begins significant attenuation. Expressed as normalized frequency (0 to π, where π = Nyquist).
  • DC Gain: The gain at zero frequency. Calculated as H(1) = B(1)/A(1) = Σb[k]/Σa[k]. Should be 1.0 for a properly normalized low-pass filter.

Controls

  • Type Dropdown: Select Low Pass, High Pass, Band Pass, or Band Stop.
  • Method Dropdown: Select Butterworth, Chebyshev I/II, Elliptic, or Bessel.
  • Signal Dropdown: Select the test signal (Impulse and Step are especially useful for IIR analysis).
  • Cutoff (ω): Adjust cutoff frequency from 0.01π to 0.45π.
  • Order: Set filter order from 1 to 4 using the spinbox. Higher = sharper but riskier.
  • Pause/Run: Freeze or resume animation.
  • ◀ Step / Step ▶: Advance one sample at a time (auto-pauses animation).
  • Reset: Return to default settings.
  • Show Recursion: Toggle the feedforward/feedback visualization boxes.
  • Speed: Adjust animation speed from 1x to 5x.
  • Noise: Add noise to all signal types (0% to 80%). Does not affect White Noise.
  • Linear/dB Toggle: Switch frequency response between linear and dB scale.

Key Concepts

  • Infinite Impulse Response: The feedback creates an impulse response that theoretically lasts forever (though it decays exponentially for stable filters). This is why they're called "IIR"—even a single impulse input produces infinite output samples.
  • Efficiency: IIR filters need far fewer coefficients than FIR filters for the same sharpness. A 2nd-order IIR biquad (5 coefficients) can match a 20+ tap FIR. This makes IIR filters computationally attractive.
  • Stability: The critical difference from FIR! IIR filters CAN become unstable if poles move outside the unit circle. The feedback amplifies the signal without bound. Always check pole locations!
  • Phase Response: IIR filters generally have NON-LINEAR phase response. Different frequencies are delayed by different amounts, which can distort signal shape. Use Bessel design if phase linearity matters.
  • Cascade vs. Direct Form: Higher-order IIR filters are usually implemented as cascaded 2nd-order "biquad" sections for numerical stability, not as one high-order difference equation.

Z-Plane Analysis: Poles and Zeros

The Z-plane is the key to understanding IIR filter behavior:

Poles (× marks)

Poles are roots of the denominator A(z). They determine:

  • Stability: ALL poles must be inside the unit circle (|p| < 1)
  • Frequency peaks: A pole near the unit circle creates a peak at that frequency
  • Resonance: Poles closer to the circle = sharper resonance but closer to instability
  • Impulse response: Pole magnitude determines decay rate; pole angle determines oscillation frequency

Zeros (○ marks)

Zeros are roots of the numerator B(z). They determine:

  • Frequency nulls: A zero ON the unit circle completely blocks that frequency
  • Notch filters: Created by placing zeros exactly on the unit circle
  • Response shaping: Zeros "pull down" the response near their locations
Pole Location Effect Stability
|p| < 1 (inside circle) Exponentially decaying impulse response STABLE
|p| = 1 (on circle) Sustained oscillation (marginally stable) MARGINAL
|p| > 1 (outside circle) Exponentially GROWING output! UNSTABLE

Comparing Design Methods

Method Passband Stopband Rolloff Phase Best For
Butterworth Maximally flat Monotonic Gradual Non-linear General purpose
Chebyshev I Equiripple Monotonic Steep Non-linear Sharp cutoff needed
Chebyshev II Monotonic Equiripple Steep Non-linear Flat passband + sharp cutoff
Elliptic Equiripple Equiripple Steepest Non-linear Minimum order for specs
Bessel Flat Gentle Gradual ~Linear Waveform preservation

IIR vs. FIR: When to Use Each

Aspect IIR FIR
Efficiency Fewer coefficients for same sharpness More coefficients needed
Stability Can be unstable! Always stable
Phase Non-linear (distorts waveforms) Can be perfectly linear
Design Based on analog prototypes Direct digital design
Best For Real-time, resource-constrained, audio Data analysis, imaging, linear phase needed