Finding the Frequency Response Analytically

Given an LTI difference equation describing a filter, it is easy to analytically find an expression for the frequency response. Recall that if the input x is a complex exponential, then the output y will be the same complex exponential scaled by the frequency response evaluated at the frequency of the complex exponential.

Consider a filter given by

a1 y(n) + a2 y(n-1) + a3 y(n-2) = b1 x(n) + b2 x(n-1) + b3 x(n-2).

Let the input x be given by, for all integers n,

x(n) = e jwn.

Then the output y must be given by, for all integers n,

y(n) = H(w) e jwn.

where H(w) is the frequency response evaluated at the frequency w. Plugging the form of the input and output into the difference equation we get

a1 H(w) e jwn + a2 H(w) e jw(n-1) + a3 H(w) e jw(n-2)
= b1 e jwn + b2 e jw(n-1) + b3 e jw(n-2).

This can be factored as follows,

H(w) e jwn (a1 + a2 e -jw + a3 e -2jw)
= e jwn (b1 + b2 e -jw + b3 e -2jw).

This can be solved for the frequency response,

H(w) = e jwn (b1 + b2 e -jw + b3 e -2jw)/ e jwn (a1 + a2 e -jw + a3 e -2jw).

This form of the frequency response can be generalized to LTI difference equations with an arbitrary number of terms.