FIR Filter Theory

A comprehensive guide to Finite Impulse Response filters — from mathematical foundations to practical design

What is a FIR Filter?

A Finite Impulse Response (FIR) filter is a type of digital filter whose impulse response settles to zero in a finite number of sample periods. Unlike IIR filters, FIR filters use only the current and past input samples (no feedback), making them inherently stable.

The output y[n] of a causal FIR filter of order M is computed as a weighted sum (linear convolution) of the current and past N = M + 1 input samples:

y[n] = Ī£k=0M h[k] Ā· x[nāˆ’k]

where h[k] are the filter coefficients (impulse response), x[n] is the input, and M is the filter order.

✦

Always Stable

No feedback means the filter output is bounded for any bounded input (BIBO stable).

ā‰ˆ

Linear Phase

Symmetric FIR filters have a linear phase response — all frequency components experience the same time delay.

āˆž

Flexible Design

Any frequency response can be approximated with sufficient filter order using windowing or optimization methods.

Transfer Function

In the Z-domain, the transfer function of an FIR filter is a polynomial in zāˆ’1:

H(z) = Ī£k=0M h[k] Ā· zāˆ’k

All poles of H(z) lie at the origin (z = 0), confirming unconditional stability.

Discrete-Time Convolution

FIR filtering is fundamentally a linear convolution operation. Given an input signal x[n] and a filter impulse response h[n], the output y[n] is:

y[n] = x[n] * h[n] = Ī£k=āˆ’āˆžāˆž x[k] Ā· h[nāˆ’k]

For a causal FIR filter of order M, this simplifies to:

y[n] = Ī£k=0M h[k] Ā· x[nāˆ’k]

This is a dot product of the reversed coefficient vector h with a sliding window of M+1 input samples.

Algorithm Direct Form FIR Convolution
function applyFilter(x, h):
    N = length(x)
    M = length(h)
    y = zeros(N)
    for n = 0 to N-1:
        for k = 0 to M-1:
            if (n - k) >= 0:
                y[n] += h[k] * x[n - k]
    return y

Convolution in Frequency Domain

By the Convolution Theorem, convolution in the time domain corresponds to multiplication in the frequency domain:

Y(ejω) = H(ejω) Ā· X(ejω)

This means the filter shapes the spectrum of the input signal by multiplying it element-wise with the filter's frequency response H(ejω).

Windowing Method

The most common approach to FIR filter design is the windowing method:

01

Specify Ideal Response

Define the ideal frequency response Hd(ejω) — a brick-wall response for LPF or HPF.

02

Compute Ideal Impulse Response

Take the Inverse DTFT of Hd to get hd[n], which is infinite and non-causal (sinc function).

03

Apply Window Function

Multiply hd[n] by a window w[n] of finite length to obtain a realizable filter.

04

Make Causal

Shift h[n] to make it causal: hcausal[n] = hd[n āˆ’ M/2] Ā· w[n], 0 ≤ n ≤ M.

FIR Low Pass Filter

An ideal Low Pass Filter (LPF) passes all frequencies below the cutoff ωc with unity gain and completely blocks frequencies above ωc.

Ideal Frequency Response

HLPF(ejω) = { 1, |ω| ≤ ωc
0, ωc < |ω| ≤ Ļ€ }

Ideal Impulse Response (IDTFT)

hd[n] = (ωc/Ļ€) Ā· sinc(ωc Ā· n / Ļ€)

where sinc(x) = sin(Ļ€x)/(Ļ€x) is the normalized sinc function.

Windowed (Realizable) Impulse Response

h[n] = hd[n āˆ’ M/2] Ā· w[n],   0 ≤ n ≤ M
ParameterSymbolDescription
Filter OrderMNumber of coefficients minus one (N = M + 1)
Cutoff FrequencyωcRadians per sample (0 to Ļ€); normalized: 0 to 1
Center TapM/2Zero-phase reference point
Windoww[n]Reduces Gibbs phenomenon at transitions
šŸ’” Key Insight: Increasing the filter order M sharpens the transition band but increases computational cost (more multiply-accumulate operations per sample).

FIR High Pass Filter

A High Pass Filter (HPF) passes frequencies above the cutoff ωc while attenuating lower frequencies.

Spectral Inversion Method

The simplest approach derives the HPF from an LPF using spectral inversion:

hHP[n] = Ī“[n āˆ’ M/2] āˆ’ hLP[n]

where Ī“[n] is the unit impulse (Kronecker delta) and hLP[n] is the LPF impulse response.

Ideal Frequency Response

HHPF(ejω) = 1 āˆ’ HLPF(ejω)

Direct Ideal Impulse Response

hd,HP[n] = Ī“[n] āˆ’ (ωc/Ļ€) Ā· sinc(ωc Ā· n / Ļ€)
āš ļø Note: For spectral inversion to work correctly, M must be even (even-order filter). Odd-order HPF requires special handling at ω = Ļ€.

Design Example

HPF with ωc = 0.5Ļ€ (normalized cutoff fc = 0.5), order M = 20, Hamming window:

JavaScript
const order = 20;   // M
const wc = 0.5;     // normalized cutoff (0-1 maps to 0-Ļ€)

// 1. Design LPF
const hLPF = firLowPass(order, wc, 'hamming');

// 2. Spectral inversion → HPF
const hHPF = hLPF.map((v, n) => {
  const mid = Math.round(order / 2);
  return (n === mid ? 1 : 0) - v;
});

Windowing Functions

Windowing mitigates the Gibbs phenomenon — the oscillatory ringing that occurs when you abruptly truncate an infinite impulse response. Different windows trade off transition bandwidth against stopband attenuation.

Rectangular
w[n] = 1,   0 ≤ n ≤ M
  • Peak Sidelobe: āˆ’13 dB
  • Min Stopband Atten.: 21 dB
  • Main Lobe Width: 4Ļ€/N

Sharpest transition but highest sidelobe levels. Rarely used in practice.

Hamming
w[n] = 0.54 āˆ’ 0.46cos(2Ļ€n/M)
  • Peak Sidelobe: āˆ’43 dB
  • Min Stopband Atten.: 53 dB
  • Main Lobe Width: 8Ļ€/N

Good all-around window — wide use in audio and communications.

Blackman
w[n] = 0.42 āˆ’ 0.5cos(2Ļ€n/M) + 0.08cos(4Ļ€n/M)
  • Peak Sidelobe: āˆ’57 dB
  • Min Stopband Atten.: 74 dB
  • Main Lobe Width: 12Ļ€/N

High attenuation. Used where stopband ripple must be very small.

Hann (Hanning)
w[n] = 0.5 āˆ’ 0.5cos(2Ļ€n/M)
  • Peak Sidelobe: āˆ’31 dB
  • Min Stopband Atten.: 44 dB
  • Main Lobe Width: 8Ļ€/N

Smooth tapering, commonly used in spectral analysis.

FIR vs IIR Filters

Property FIR Filter IIR Filter
Stability Always stable āœ“ May be unstable āœ—
Phase Response Linear phase (symmetric) āœ“ Nonlinear phase āœ—
Computational Cost High (more coefficients) āœ— Lower (fewer coefficients) āœ“
Feedback None (feedforward only) āœ“ Uses past outputs (recursion)
Implementation Simple direct-form convolution Difference equation with recursion
Design Windowing method, easy āœ“ Bilinear transform, more complex

Real-World Applications

šŸŽµ

Audio Processing

Bass/treble controls, equalizers, noise reduction in music production and hearing aids.

šŸ“”

Communications

Anti-aliasing before ADC, matched filters in CDMA, channel shaping in modems.

šŸ„

Biomedical

ECG noise removal, EEG band-pass analysis, removing powerline interference (50/60 Hz).

šŸ“·

Image Processing

2D FIR filters for edge detection, sharpening, blurring, and anti-aliasing in cameras.

šŸŽ›ļø

Control Systems

Sensor data filtering in robotics, vibration analysis, and feedback control loops.

šŸ”­

Scientific

Seismology signal analysis, radar/sonar pulse shaping, and radio astronomy.

Ready to see FIR filters in action?

Head over to the interactive simulation to experiment with all filter parameters in real time.

Open Simulation →