Free Books

Finding the Frequency Response

Think of the filter expressed by Eq.$ \,$(1.1) as a ``black box'' as depicted in Fig.1.5. We want to know the effect of this black box on the spectrum of $ x(\cdot)$, where $ x(\cdot)$ represents the entire input signal (see §A.1).

Figure 1.5: ``Black box'' representation of an arbitrary filter
\begin{figure}\input fig/kfig2p3.pstex_t

Sine-Wave Analysis

Suppose we test the filter at each frequency separately. This is called sine-wave analysis.2.1Fig.1.6 shows an example of an input-output pair, for the filter of Eq.$ \,$(1.1), at the frequency $ f=f_s/4$ Hz, where $ f_s$ denotes the sampling rate. (The continuous-time waveform has been drawn through the samples for clarity.) Figure 1.6a shows the input signal, and Fig.1.6b shows the output signal.

Figure 1.6: Input and output signals for the filter $ y(n) = x(n) + x(n - 1)$. (a) Input sinusoid $ x(n) = A_1 \sin(2\pi f n T +
\phi_1)$ at amplitude $ A_1=1$, frequency $ f=f_s/4$, and phase $ \phi _1=0$. (b) Output sinusoid $ y(n) = A_2 \sin(2\pi f nT + \phi_2)$ at amplitude $ A_2=1.414$, frequency $ f=f_s/4$, and phase $ \phi _2 = - \pi /4$.
\begin{figure}\input fig/kfig2p4.pstex_t

The ratio of the peak output amplitude to the peak input amplitude is the filter gain at this frequency. From Fig.1.6 we find that the gain is about 1.414 at the frequency $ f_s/4$. We may also say the amplitude response is 1.414 at $ f_s/4$.

The phase of the output signal minus the phase of the input signal is the phase response of the filter at this frequency. Figure 1.6 shows that the filter of Eq.$ \,$(1.1) has a phase response equal to $ -2\pi/8$ (minus one-eighth of a cycle) at the frequency $ f=f_s/4$.

Continuing in this way, we can input a sinusoid at each frequency (from 0 to $ f_s/2$ Hz), examine the input and output waveforms as in Fig.1.6, and record on a graph the peak-amplitude ratio (gain) and phase shift for each frequency. The resultant pair of plots, shown in Fig.1.7, is called the frequency response. Note that Fig.1.6 specifies the middle point of each graph in Fig.1.7.

Not every black box has a frequency response, however. What good is a pair of graphs such as shown in Fig.1.7 if, for all input sinusoids, the output is 60 Hz hum? What if the output is not even a sinusoid? We will learn in Chapter 4 that the sine-wave analysis procedure for measuring frequency response is meaningful only if the filter is linear and time-invariant (LTI). Linearity means that the output due to a sum of input signals equals the sum of outputs due to each signal alone. Time-invariance means that the filter does not change over time. We will elaborate on these technical terms and their implications later. For now, just remember that LTI filters are guaranteed to produce a sinusoid in response to a sinusoid--and at the same frequency.

Figure 1.7: Frequency response for the filter $ y(n) = x(n) + x(n - 1)$. (a) Amplitude response. (b) Phase response.
\begin{figure}\input fig/kfig2p5.pstex_t

Mathematical Sine-Wave Analysis

The above method of finding the frequency response involves physically measuring the amplitude and phase response for input sinusoids of every frequency. While this basic idea may be practical for a real black box at a selected set of frequencies, it is hardly useful for filter design. Ideally, we wish to arrive at a mathematical formula for the frequency response of the filter given by Eq.$ \,$(1.1). There are several ways of doing this. The first we consider is exactly analogous to the sine-wave analysis procedure given above.

Assuming Eq.$ \,$(1.1) to be a linear time-invariant filter specification (which it is), let's take a few points in the frequency response by analytically ``plugging in'' sinusoids at a few different frequencies. Two graphs are required to fully represent the frequency response: the amplitude response (gain versus frequency) and phase response (phase shift versus frequency).

The frequency 0 Hz (often called dc, for direct current) is always comparatively easy to handle when we analyze a filter. Since plugging in a sinusoid means setting $ x(n) = A \cos(2\pi fnT + \phi )$, by setting $ f = 0$, we obtain $ x(n) = A \cos[2\pi(0)T + \phi] = A
\cos(\phi)$ for all $ n$. The input signal, then, is the same number $ (A
\cos(\phi))$ over and over again for each sample. It should be clear that the filter output will be $ y(n) = x(n) + x(n - 1) = A \cos(\phi) + A
\cos(\phi) = 2A \cos(\phi)$ for all $ n$. Thus, the gain at frequency $ f = 0$ is 2, which we get by dividing $ 2A$, the output amplitude, by $ A$, the input amplitude.

Phase has no effect at $ f = 0$ Hz because it merely shifts a constant function to the left or right. In cases such as this, where the phase response may be arbitrarily defined, we choose a value which preserves continuity. This means we must analyze at frequencies in a neighborhood of the arbitrary point and take a limit. We will compute the phase response at dc later, using different techniques. It is worth noting, however, that at 0 Hz, the phase of every real2.2 linear time-invariant system is either 0 or $ \pi $, with the phase $ \pi $ corresponding to a sign change. The phase of a complex filter at dc may of course take on any value in $ [-\pi ,\pi )$.

The next easiest frequency to look at is half the sampling rate, $ f=
f_s/2 = 1/(2T)$. In this case, using basic trigonometry (see §A.2), we can simplify the input $ x$ as follows:

$\displaystyle x(n)$ $\displaystyle =$ $\displaystyle A \cos\left(2\pi\frac{f_s}{2} n T + \phi\right),
\qquad n = 0, 1, 2,\ldots$  
  $\displaystyle =$ $\displaystyle A \cos\left(2\pi\frac{1}{2T} n T + \phi\right)$  
  $\displaystyle =$ $\displaystyle A \cos(\pi n + \phi)$  
  $\displaystyle =$ $\displaystyle A \cos(\pi n)\cos(\phi) - A\sin(\pi n)\sin(\phi)$  
  $\displaystyle =$ $\displaystyle A \cos(\pi n)\cos(\phi)$  
  $\displaystyle =$ $\displaystyle A (-1)^n\cos(\phi),
\qquad n = 0, 1, 2,\ldots$  
  $\displaystyle =$ $\displaystyle [A\cos(\phi), -A\cos(\phi), A\cos(\phi), -A\cos(\phi), \ldots],$ (2.2)

where the beginning of time was arbitrarily set at $ n = 0$. Now with this input, the output of Eq.$ \,$(1.1) is
$\displaystyle y(n)$ $\displaystyle =$ $\displaystyle x(n) + x(n - 1)$  
  $\displaystyle =$ $\displaystyle (-1)^n A \cos(\phi) + (-1)^{n-1} A \cos(\phi)$  
  $\displaystyle =$ $\displaystyle (-1)^n A \cos(\phi) - (-1)^n A \cos(\phi)$  
  $\displaystyle =$ $\displaystyle 0.$ (2.3)

The filter of Eq.$ \,$(1.1) thus has a gain of 0 at $ f=f_s/2$. Again the phase is not measurable, since the output signal is identically zero. We will again need to extrapolate the phase response from surrounding frequencies (which will be done in §7.6.1).

If we back off a bit, the above results for the amplitude response are obvious without any calculations. The filter $ y(n) = x(n) + x(n - 1)$ is equivalent (except for a factor of 2) to a simple two-point average, $ y(n) = [x(n) + x(n - 1)]/ 2$. Averaging adjacent samples in a signal is intuitively a low-pass filter because at low frequencies the sample amplitudes change slowly, so that the average of two neighboring samples is very close to either sample, while at high frequencies the adjacent samples tend to have opposite sign and to cancel out when added. The two extremes are frequency 0 Hz, at which the averaging has no effect, and half the sampling rate $ f_s/2$ where the samples alternate in sign and exactly add to 0.

We are beginning to see that Eq.$ \,$(1.1) may be a low-pass filter after all, since we found a boost of about 6 dB at the lowest frequency and a null at the highest frequency. (A gain of 2 may be expressed in decibels as $ 20\log_{10}(2) \approx 6.02$ dB, and a null or notch is another term for a gain of 0 at a single frequency.) Of course, we tried only two out of an infinite number of possible frequencies.

Let's go for broke and plug the general sinusoid into Eq.$ \,$(1.1), confident that a table of trigonometry identities will see us through (after all, this is the simplest filter there is, right?). To set the input signal to a completely arbitrary sinusoid at amplitude $ A$, phase $ \phi$, and frequency $ f$ Hz, we let $ x(n) = A \cos(2\pi fnT + \phi )$. The output is then given by

$\displaystyle y(n) = A \cos(2\pi f n T + \phi ) + A \cos[2\pi f(n - 1)T + \phi].

This input can be simplified as follows: Recall from the discussion surrounding Fig.1.6 that only the peak-amplitude ratio and the phase difference between input and output sinusoids are needed to measure the frequency response. The filter phase response does not depend on $ \phi$ above (due to time-invariance), and so we can set $ \phi$ to 0. Also, the filter amplitude response does not depend on $ A$ (due to linearity), so we let $ A = 1$. With these simplifications of $ x(n)$, the gain and phase response of the filter will appear directly as the amplitude and phase of the output $ y(n)$. Thus, we input the signal

$\displaystyle x(n) = \cos(2\pi f n T) = \cos(\omega nT),

where $ \omega \isdef 2\pi f$, as discussed in §A.1. (The symbol $ \isdef $ means ``is defined as''.) With this input, the output of the simple low-pass filter is given by

$\displaystyle y(n) = \cos(\omega nT) + \cos[\omega(n - 1)T].

All that remains is to reduce the above expression to a single sinusoid with some frequency-dependent amplitude and phase. We do this first by using standard trigonometric identities [2] in order to avoid introducing complex numbers. Next, a much ``easier'' derivation using complex numbers will be given.

Note that a sum of sinusoids at the same frequency, but possibly different phase and amplitude, can always be expressed as a single sinusoid at that frequency with some resultant phase and amplitude. While we find this result by direct derivation in working out our simple example, the general case is derived in §A.3 for completeness.

We have

$\displaystyle y(n)$ $\displaystyle =$ $\displaystyle \cos(\omega nT) + \cos[\omega(n - 1)T]$  
  $\displaystyle =$ $\displaystyle \cos(\omega nT) + \cos(\omega nT) \cos(-\omega T) - \sin(\omega nT) \sin(-\omega T)$  
  $\displaystyle =$ $\displaystyle \cos(\omega nT) + \cos(\omega nT) \cos(\omega T) + \sin(\omega nT) \sin(\omega T)$  
  $\displaystyle =$ $\displaystyle \left[1 + \cos(\omega T)\right] \cos(\omega nT) + \sin(\omega T) \sin(\omega n T)$  
  $\displaystyle =$ $\displaystyle a(\omega) \cos(\omega nT) + b(\omega) \sin(\omega nT)$ (2.4)

where $ a(\omega)\isdef [1 + \cos(\omega T)]$ and $ b(\omega) \isdef
\sin(\omega T)$. We are looking for an answer of the form

$\displaystyle y(n) = G(\omega) \cos\left[\omega nT + \Theta(\omega)\right],

where $ G(\omega)$ is the filter amplitude response and $ \Theta(\omega)$ is the phase response. This may be expanded as

$\displaystyle y(n) = G(\omega) \cos\left[\Theta(\omega)\right] \cos(\omega nT)
- G(\omega) \sin[\Theta(\omega)] \sin(\omega n T).

$\displaystyle a(\omega)$ $\displaystyle =$ $\displaystyle \quad\! G(\omega) \cos\left[\Theta(\omega)\right]$  
$\displaystyle b(\omega)$ $\displaystyle =$ $\displaystyle - G(\omega) \sin\left[\Theta(\omega)\right].
\protect$ (2.5)

Amplitude Response

We can isolate the filter amplitude response $ G(\omega)$ by squaring and adding the above two equations:

a^2(\omega) + b^2(\omega) &=& G^2(\omega)\cos^2[\Theta(\omega)...
...ta(\omega)] + \sin^2[\Theta(\omega)]\right\}\\
&=& G^2(\omega).

This can then be simplified as follows:

G^2(\omega) &=& a^2(\omega) + b^2(\omega)\\
&=& [1 + \cos(\...
... \cos(\omega T) \\
&=&4 \cos^2\left(\frac{\omega T}{2}\right).

So we have made it to the amplitude response of the simple lowpass filter $ y(n) = x(n) + x(n - 1)$:

$\displaystyle G(\omega) = 2 \left\vert\cos\left(\frac{\omega T}{2}\right)\right\vert

Since $ \cos(\pi fT)$ is nonnegative for $ -f_s/2 \leq f \leq f_s/2$, it is unnecessary to take the absolute value as long as $ f$ is understood to lie in this range:

$\displaystyle \zbox {G(\omega) = 2 \cos(\pi f T)} \qquad \left\vert f\right\vert \leq \frac{f_s}{2} \protect$ (2.6)

Phase Response

Now we may isolate the filter phase response $ \Theta(\omega)$ by taking a ratio of the $ a(\omega)$ and $ b(\omega)$ in Eq.$ \,$(1.5):

&=& -\frac{G(\omega) \sin\left[\...
&\isdef & - \tan[\Theta(\omega)]

Substituting the expansions of $ a(\omega)$ and $ b(\omega)$ yields

\tan[\Theta(\omega)] &=& - \frac{b(\omega)}{a(\omega)} \\
...n(\omega T/2)}{\cos(\omega T/2)}
= \tan\left(-\omega T/2\right).

Thus, the phase response of the simple lowpass filter $ y(n) = x(n) + x(n - 1)$ is

$\displaystyle \zbox {\Theta(\omega) = -\omega T/2.} \protect$ (2.7)

We have completely solved for the frequency response of the simplest low-pass filter given in Eq.$ \,$(1.1) using only trigonometric identities. We found that an input sinusoid of the form

$\displaystyle x(n) = A \cos(2\pi fnT + \phi)

produces the output

$\displaystyle y(n) = 2A \cos(\pi f T) \cos(2\pi fnT + \phi - \pi fT).

Thus, the gain versus frequency is $ 2\cos(\pi fT)$ and the change in phase at each frequency is given by $ -\pi fT$ radians. These functions are shown in Fig.1.7. With these functions at our disposal, we can predict the filter output for any sinusoidal input. Since, by Fourier theory [84], every signal can be represented as a sum of sinusoids, we've also solved the more general problem of predicting the output given any input signal.

Next Section:
An Easier Way
Previous Section:
The Simplest Lowpass Filter