# From Analog to Digital

Because analog filters are well-studied, a common way of designing a digital filter is to start with an analog filter, then transform it to a digital filter. To achieve this, we must find a function that maps the imaginary axis onto the unit circle, as we must have the frequency response of the analog filter be similar to the frequency response of its digital incarnation.

One such function is the *bilinear transform*. We substitute
\(s\) in the transfer function of the analog filter \(H(s)\) with

Rearranging gives

Let us call this map \(B\). By inspection, if \(s\) is the point at infinity, then \(z = -1\). Also, \(0\) maps to \(1\), \(i\) to \(i\) and \(-i\) to \(-i\), which suggests it does map the imaginary axis to the unit circle. More generally,

which makes it clear that it does map the imaginary axis to the unit circle. (Since \(|B(i\omega)| = 1\).)

Applying the bilinear transform to the transfer function \(H_a(s)\) of some analog filter gives the transfer function \(H_d(z)\) of some digital filter. If \(H_d(z)\) is of the correct form we can read the coefficients off and implement the digital filter. However, even though the frequency response of the digital filter is based on that of the analog filter, the relationship is not straightforward. As \(\omega\) increases from 0 to infinity, \(B(i\omega)\) rotates counterclockwise around the unit circle starting from 1 and approaching -1, but the imaginary axis gets more and more "compressed" as it approaches infinity.

To gain more control over the conversion, we examine how the distance of a point \(i\omega\) from the origin, namely \(|\omega|\), relates to the angle of the point to which it maps, namely \(\angle B(i\omega)\). (Recall \(H_a(i\omega)\) determines the frequency response of an analog filter, while \(H_d(e^{i\theta})\) determines the frequency response of a digital filter.)

Let \(a = \angle B(i\omega)\). Then \(tan a = \frac{2\omega}{1 - \omega^2}\), and hence

(So \(a = 2 \arctan(\omega)\).)

Now consider how the sampling rate is involved in a discrete system. As an example, let the sampling frequency be \(f_s = 44100\). Let \(a = 2 \pi / f_s\). Then \(x[n] = cos(a n)\) represents a sinusoid of frequency 1Hz; after 44100 samples, exactly one cycle has completed.

In general, for a digital system, we have that a sinusoid of frequency \(f\) is represented by \(\cos(a n + b)\) where

From above, \(H_d(e^{i a}) = H_a(i \tan(a/2)) = H_a(i \tan(\pi f / f_s))\)

Suppose we wish to construct a digital filter that amplifies a particular frequency \(f\) by a particular amount \(G\), that is, we want \(H_d(e^{ia}) = G\), where \(a = 2 \pi f / f_s\). Then the analog filter we transform from must have its transfer function satisfying \(H_a(i \tan(a/2)) = G\).

In the next section we design analog filters with particular gains at particular frequencies.

*blynn@cs.stanford.edu*💡