EmbeddedRelated.com
Blogs
The 2026 Embedded Online Conference

The First-Order IIR Filter -- More than Meets the Eye

Neil RobertsonNovember 16, 20256 comments

While we might be inclined to disdain the simple first-order infinite impulse response (IIR) filter, it is not so simple that we can’t learn something from it.  Studying it can teach DSP math skills, and it is a very useful filter in its own right.  In this article, we’ll examine the time response of the filter, compare the first-order IIR filter to the FIR moving average filter, use it to smooth a noisy signal, compute the functional form of the impulse response, and find the frequency response.

Time Response

Figure 1 is a block diagram of a first-order IIR filter, where I have used the same notation as Lyons [1].  (An alternative structure using just one multiplier is shown later in this article).  Here, 0 < α < 1 and the filter is lowpass.  The block labeled z-1 represents a delay of one sample time.  Given sample index n, the output y(n) is related to input x(n) by the recursive formula:

$$ y(n)= \alpha x(n) + (1-\alpha)y(n-1)  \qquad          (1)  $$

We see that y(n) is a linear combination of the current input sample and the previous output sample.


Figure 1.  First-Order IIR Filter

Let’s compute the impulse response of the filter for α = 1/8.The following Matlab code implements Equation 1 for an impulse input:

    N = 64;                    % number of samples
    x = [1 zeros(1,N-1)];      % impulse input
    alpha = 1/8;
    y= zeros(1,N);
    y(1) = alpha*x(1);
    for n = 2:N;
        y(n)= alpha*x(n)+ (1- alpha)*y(n-1);    % Equation 1
    end
    stem(0:N-1,y,'markersize',5),grid

(I have not used it here, but there is a dedicated Matlab command filter for FIR or IIR filtering).  The impulse response is plotted in Figure 2.  Note that the n-axis range in the plot is 0 to N-1, while n in the Matlab code has a range of 1 to N.  Conveniently, the response is determined by the single parameter α.  The response is a decreasing exponential, as we’ll show later in this article.

Figure 2.  Impulse Response for α = 1/8.


First-Order IIR vs Moving Average FIR Filter

A moving average Finite Impulse Response (FIR) filter is simply a rectangular (boxcar) filter.  The time response of the moving averager is the true moving average of the input [2]:

$$ y(n) = \frac{1}{ntaps} \sum_{n=0}^{ntaps-1} x(n)  \qquad (2)$$

Where ntaps is the number of coefficients, and each coefficient has value 1/ntaps.  Figure 3 (top) shows the impulse responses of a 9-tap moving average filter with coefficients:

$$ b = \frac{1}{9}* [1 \, 1 \, 1 \, 1 \, 1 \, 1 \, 1 \,1 \,1]   \qquad (3)    $$

A first-order IIR filter can also be used as an averager, and is sometimes called an exponential averager.  The impulse response of a first-order IIR filter with α = 1/5 is shown in Figure 3 (bottom).  Like the moving average filter, the coefficients of the exponential moving averager sum to 1 (try summing y(n) in the above Matlab code).  The difference is in the weighting of the coefficients:  the moving average filter weights all samples of x(n) equally, while the exponential moving average over-weights the most recent samples.

The moving average filter has a finite length impulse response, while the impulse response of the exponential averager is infinite.  The moving averager’s coefficients/impulse response is symmetric with respect to its center, while the exponential averager is not.  In many cases, we don’t require symmetry, and exponential averaging is appropriate.

Figure 3.  Impulse responses of 9-tap moving average filter (top)

and exponential moving average filter with α = 1/5 (bottom).


Example – Noise Smoothing

Let x be a noisy rectangular pulse that is 4096 samples long.  We can smooth the noise by applying the pulse to a first-order IIR filter/exponential averager.  Here is Matlab code to generate the noisy pulse and filter it using α = 1/8:

    u = [zeros(1,256) ones(1,4096) zeros(1,1024)];     % rectangular pulse
    N = length(u);
    x = u + .1*randn(1,N);                             % pulse with gaussian noise
    alpha = 1/8;
    y= zeros(1,N);
    y(1) = alpha*x(1);
    for n = 2:N;
        y(n)= alpha*x(n)+ (1- alpha)*y(n-1);           % Equation 1
    end

The noisy pulse is shown in the top plot of Figure 4, and the filtered pulse is shown in the middle plot.  The filter has attenuated the noise with minimal distortion to the pulse, because the significant portion of the filter’s impulse response is less than 30 samples long (Figure 2), which is much shorter than the pulse length.  If we change α to 1/32, the noise is attenuated further, as shown in the bottom plot.  We can also see some distortion on the edges of the pulse due to the filter.

Figure 4.  Filtering a noisy signal with an exponential averager.

Top: Pulse with noise.  Middle: Filter output for α = 1/8.  Bottom: Filter output for α = 1/32.


Functional Form of the Impulse Response

Equation 1 is called a recursion relationship; it computes y(n), but does not give us its functional form.  Consider the filter’s impulse response, y(n) = h(n).  To find the functional form of h(n), let x(n) be:

$$ x(n) = 1 \; 0 \; 0 \; 0 \; ... \qquad  (4) $$

Then, evaluating Equation 1 for n = 0, 1, 2 we have:

$ h(0) = \alpha $

$ h(1) = \alpha*(1 - \alpha) $

$ h(2) = \alpha*(1 - \alpha) (1 - \alpha)  = \alpha*(1 - \alpha)^2 $

Where 0 < α < 1.  For sample n:

$$ h(n) = \alpha*(1 - \alpha)^n \qquad (5) $$

Note that h(0) is equal to α, as can be seen in Figure 2 for α = 0.125.  We can modify Equation 5 to obtain a more familiar form as follows.  Given that:

$$ u = e^{ln \,u}  \qquad (6)  $$

we can write:

$$ u^n = e^{n \,ln \,u} \qquad (7)  $$

where ln is the natural log.We can then rewrite Equation 5 as:

$$ h(n) = \alpha*e^{n \, ln(1 - \alpha)} \qquad (8) $$

Letting β = -ln(1 – α), we have:

$$ h(n) = \alpha*e^{-\beta \,n}  \qquad (9) $$

So, the impulse response is a decreasing exponential function.  Note that for α << 1, β ≈ α.


Frequency Response

Figure 5 shows a first-order IIR filter with the conventional notation [3,4] for the coefficients:  the feed-forward coefficient is b0 = α and the feed-back coefficient is -a1 = 1-α.  The transfer function in z is given by:


$$ H(z) = \frac{Y(z)}{X(z)} = \frac{b_0}{1 + a_1 z^{-1}} \qquad (10) $$


Letting z = ejω, the frequency response is:


$$ H(\omega) = \frac{b_0}{1 + a_1 e^{-j \omega}} \qquad (11) $$

where ω = 2πf/fs is normalized radian frequency and fs is the sample frequency in Hz.



Figure 5.  First-Order IIR Filter, with conventional notation for coefficients.


We can compute the magnitude response for α = 1/8 and fs = 1 using the Matlab freqz function:

    fs = 1;                         % Hz sample frequency
    alpha = 1/8;
    b0 = alpha;                     % numerator coefficient
    a1 = -(1 - alpha);
    a = [1 a1];                     % denominator coefficients
    [H,f]= freqz(b0,a,256,fs);      % H = freq resp, f = freq vector
    HdB = 20*log10(abs(H));         % dB magnitude response

The magnitude response is shown in Figure 6, along with the magnitude response for α = 1/32.  Note that the gain at dc is 1.0, as we can see by setting ω = 0 in Equation 11.  We used the same values of α in our noise-smoothing example (Figure 4).  From the magnitude responses, we see that the smaller value of α gives a lower -3 dB frequency and thus more attenuation of Gaussian noise.

As shown in the Appendix, we can approximate the filter’s -3 dB frequency fc for α << 1 as follows:

$$ f_c \approx \frac{\alpha}{1 - \alpha}*\frac{f_s}{2\pi} \quad , \alpha << 1  \qquad (12) $$

For example, if α = 1/32, we have:

$$ f_c \approx \frac{1/32}{31/32}*\frac{f_s}{2\pi} = .00513*f_s  \qquad (13) $$

Solving Equation 12 for α as a function of the desired fc yields:

$$ \alpha \approx \frac{1}{1+ \frac{f_s}{2\pi f_c} } \quad , 2\pi f_c << f_s \qquad(14) $$

Figure 6.  Magnitude responses of first-order IIR filters.


First-Order IIR Filter Implementation Using One Multiplier

We can regroup terms in Equation 1 to obtain the following recursive formula for the first-order IIR time response:

$$ y(n) = \alpha [x(n) - y(n-1)] + y(n-1)  \qquad (15) $$

This results in the block diagram with only one multiplier shown in Figure 7.  Also, if we choose α to be a negative power of 2 (e.g. 1/8 or 1/32), we can replace the multiply-by-α block with a simple bit shift.


Figure 7.  First-order IIR filter using one multiplier.


Conclusion

The simplicity of the first-order IIR filter has allowed us to develop equations to compute its impulse response (Equations 5 and 9), as well as equations for the -3 dB frequency (Equation 12) and for α, given the desired -3 dB frequency (Equation 14).

There are many applications of the first-order IIR filter.  We have seen an application as a noise smoother.  Under the name exponential moving averager, it is often used to smooth graphs of stock prices.  The filter is used for FFT averaging (spectrum averaging) [5], and it can be used to model a continuous-time RC lowpass filter, as I explained in an earlier post [6].


For the Appendix, see the PDF version of this article.


References

1.  Lyons, Richard G., Understanding Digital Signal Processing, 3rd Ed., Pearson, 2011, section 11.6.

2.  Lyons, section 5.1.

3.  “filter,” Matlab Website, https://www.mathworks.com/help/matlab/ref/filter.html see More About/Rational Transfer Function.

4.  Mitra, Sanjit K., Digital Signal Processing, a Computer-Based Approach, 2nd Ed., McGraw-Hill, 2001, section 6.4.

5.  Lyons, section 11.6.3

6.  Robertson, Neil, “Model a Sigma-Delta DAC Plus RC Filter,” DSPRelated.com, March, 2024, https://www.dsprelated.com/showarticle/1642.php , see Appendix A of PDF version.


                                       Neil Robertson     November 2025



The 2026 Embedded Online Conference
[ - ]
Comment by aharmonNovember 18, 2025

Neil, excellent article!

I wanted to add a complementary perspective that I've found useful in practice.

When using single-pole IIR filters for signal smoothing, I often tune them in the time domain rather than the frequency domain. Instead of specifying a cutoff frequency, I like to specify the desired settling time of the exponential response directly.

Time Domain Tuning via Exponential Time Constants

Consider a continuous-time first-order lowpass filter with transfer function:

H(s) = 1/(tau*s + 1)

where τ is the time constant. This system has a pole at s = -1/tau, and its step response settles to within 1% of its final value in approximately 5-tau.

N-tauValue
10.63212
20.86466
30.95021
40.98168
50.99323

To discretize this filter using pole matching, z = e^(sT), the continuous pole at s = -1/tau maps directly to the discrete pole:

z = e^(-T/tau)

Preserving DC gain, the discrete transfer function becomes:

H(z) = (1 - e^(-T/tau)) / (1 - e^(-T/tau) z^(-1))

This yields the first-order difference equation matching your Equation (1) with

α = 1 - e^(-T/tau).

This is, of course, equivalent to filter design by converting a time constant to a corner frequency. The discretization via pole matching is nearly identical to the Bilinear Transformation for (T/tau) << 1. But I prefer pole matching to preserve desired time constants as the corner approaches Nyquist:

  • Pole matching: α = 1 - e^(-T/τ) ≈ T/τ - T²/(2τ²) + ...
  • Bilinear: α = 2T/(2τ + T) = (T/τ)/(1 + T/(2τ)) ≈ T/τ - T²/(2τ²) + ...

These agree to second order, but the pole matching method preserves the envelope of the specified exponential response exactly, which is usually the characteristic I care about.

[ - ]
Comment by neiroberNovember 18, 2025

Thanks!  You can derive your equation for alpha from my equation 9, with 

beta = -ln(1 - alpha):

h(n) = alpha e^-(beta*n)   (9)

e^(-nT/tau) is equivalent to e^-(beta*n)     (tau is in seconds)

so T/tau = beta = -ln(1-alpha)

and e^-(T/tau) = 1 - alpha

alpha = 1 - e^(-T/tau)


[ - ]
Comment by DanBoschenDecember 29, 2025

Nice article and great presentation Neil. Such a simple but enormously useful filter. I'm predicting (hoping) your next article will be the DC Nulling Filter. 

[ - ]
Comment by neiroberDecember 29, 2025

Thanks Dan!

As you may know, dc removal filtering is discussed in section 13.23 of Rick Lyons' book, Understanding Digital Signal Processing, 3rd Ed., Pearson, 2011.

[ - ]
Comment by jpriskinFebruary 15, 2026

Hello Neil,

Thank you for your inspiring article.

Could you please explain,why the real and imag part of the denominator in (A-3) equation should be equal for the case where magnitude of H is -3dB?  Likely, I'm missing something elementary. Thank you.

Best regards,

Juraj

[ - ]
Comment by neiroberFebruary 15, 2026

Hi Juraj,

When the real and imaginary parts are equal, we can write A-3 as:

Hc(wc) = alpha/(alpha + j*alpha)

       = 1/(1 + j)

then

|Hc(wc)| = 1/(sqrt(1^2 + 1^2)) = 1/sqrt(2) = 0.7071


regards,

Neil

To post reply to a comment, click on the 'reply' button attached to each comment. To post a new comment (not a reply to a comment) check out the 'Write a Comment' tab at the top of the comments.

Please login (on the right) if you already have an account on this platform.

Otherwise, please use this form to register (free) an join one of the largest online community for Electrical/Embedded/DSP/FPGA/ML engineers: