This book is a very concise introduction to recursive digital filters. The goal is to get the reader to the point where he or she can understand and use these filters as quickly as possible. To accomplish this we have kept the amount of mathematical background material to a minimum and have included many examples. But make no mistake, this is not a book for dummies or complete idiots. Some degree of mathematical sophistication is required. If you have never used complex numbers and do not know what Euler's identity is, then this book is not for you. If you have a basic physical science mathematics background, then you should have no problem with this book.

We start with a short introduction to the minimum mathematics required to describe, use, and design recursive digital filters. This includes a description of the z-transform, filter system functions, and the frequency response. This is followed by examples of the simplest possible low pass, high pass, band pass, and band stop filters. A section on band stop filter banks is also included.

The design portion of the book covers impulse invariance and bilinear transform design. We give a minimum theoretical description of these methods and plenty of examples. For the bilinear transform method we show how to turn analog low pass Butterworth filters into digital low pass, high pass, band pass, and band stop filters. Being able to convert analog filters to digital is useful because analog filter design is a more mature and well understood subject.

Next we take an in depth look at Butterworth and Chebyshev filters, showing how to design low pass, high pass, band pass, and band stop versions of these filters. The section on Chebyshev filters also shows how to create a Chebyshev Butterworth filter hybrid. This is followed by a detailed example showing how to use a Butterworth and Chebyshev band pass filter.

A rudimentary introduction to elliptic filters comes next. The final section shows how digital filters can be implemented in different ways, considering efficiency and numerical stability.

The filter software used in this book is written by the authors, and is available free here. The programs are written in the C programming language, and will have to be compiled before you can use them. You do not have to know C to use the programs or understand the contents of the book. There is a C language compiler for every major operating system. A good one that is also free is gcc. Some of these programs have also been converted to the awk scripting language.

You can buy the ebook now at Amazon as a Kindle book.

You can also get the ebook instantly as a pdf from Gumroad where you will be able to download it immediately after purchase.

**About the authors:**
Stefan Hollos
and J. Richard
Hollos are physicists by training, and enjoy anything related to
math, physics, and computing. They are the authors of
Art of Pi,
Creating Noise,
Art of the Golden Ratio,
Creating Rhythms,
Pattern
Generation for Computational Art,
Finite
Automata and Regular Expressions: Problems and Solutions,
Probability
Problems and Solutions,
Combinatorics
Problems and Solutions,
The Coin Toss: Probabilities
and Patterns,
Bet Smart: The
Kelly System for Gambling and Investing, as well as
Simple Trading Strategies That Work
and Pairs
Trading: A Bayesian Example, and are brothers and business
partners at Exstrom Laboratories LLC in Longmont, Colorado. The
websites for their work
are Exstrom.com
and QuantWolf.com.

## Table of Contents

**Preface****Introduction****Simple Low Pass****Simple High Pass****Low and High Pass Example****Simple Center Pass****Simple Band Pass****Band Pass Example****Simple Band Stop****Band Stop Example****Band Stop Filter Bank****Impulse Invariance Design****Bilinear Transform Design****Butterworth Filters****Chebyshev Filters****Band Pass Example 2****Elliptic Filters****Implementing Digital Filters****Further Reading****Acknowledgements****About the Authors**

## Software

Below are the C programs that accompany the book. You can download each as you need it, or all of them in a zip file. For other programs not listed here, see our digital signal processing page.

This software is free and distributed under the terms of the GNU General Public License. It is written in ANSI C and should compile with any C compiler. If you have questions or comments contact: Stefan (stefan at exstrom dot com) or Richard (richard at exstrom dot com).

**lpf.c**

Applies a low pass filter to x[n] read from stdin.Usage: lpf s f s = sampling frequency f = half power frequency < s/2

**hpf.c**

Applies a high pass filter to x[n] read from stdin.Usage: hpf s f s = sampling frequency f = half power frequency < s/2

**bpf.c**

Applies a band pass filter to x[n] read from stdin.Usage: bpf s f b s = sampling frequency f = center frequency b = half power bandwidth

**bsf.c**

Applies a band stop filter to x[n] read from stdin.Usage: bsf s f b s = sampling frequency f = stop frequency b = half power bandwidth

**bsfb.c**

Applies a band stop filter bank to x[n] read from stdin.Usage: bsfb s b f1 f2 ... s = sampling frequency b = half power bandwidth fi = stop frequencies

**brownrv.c**

Generates n samples of an integrated gaussian random variable.Usage: brownrv n m a seed n = number of samples m = mean of gaussian a = standard deviation of gaussian seed = optional random number seed

**sines.c**

Produces n samples of the sine waves defined in file.Usage: sines file s n s = sampling frequency

**noise.c**

Reads numbers from stdin and adds gaussian noise to them.Usage: noise m a seed m = mean of gaussian a = standard deviation of gaussian seed = optional random number seed

**fft.c**

Calculates the FFT of the first n points read from stdin.Usage: fft n n = number of points read from stdin If number of points read < n then zeros are added.

**extract.c**

Extracts information from an fft file read from stdin.Usage: extract info info = m for magnitude p for phase r for real part i for imaginary part

### Awk scripts

Below are awk scripts that have been converted from the C programs
above. They are also included in
the zip file with the C
programs. These awk scripts are executable like a shell script. They
should run as is on any Unix related operating system (Linux, BSD,
OSX), with the exception of having to possibly change the path of the awk
executable on the first line. You need to make the script executable
with a command like this:

`chmod u+x file.awk`

In Windoze, you can just delete the first line of the file (starts
with #!), then run it as a regular non-executable awk file like
this:

`awk -f file.awk ...`

**lpf.awk**

Implements

`lpf.c`as an awk script, i.e. it applies a low pass filter to x[n] read from stdin.

Example: brownrv 1000 0 0.5 13 | lpf.awk -v s=1000 -v f=10 where s = sampling frequency, f = half power frequency < s/2 This produces the same output as runninglpf.clike so: brownrv 1000 0 0.5 13 | lpf 1000 10

**hpf.awk**

Implements

`hpf.c`as an awk script, i.e. it applies a high pass filter to x[n] read from stdin.

Example: brownrv 1000 0 0.5 13 | hpf.awk -v s=1000 -v f=20 where s = sampling frequency, f = half power frequency < s/2 This produces the same output as runninghpf.clike so: brownrv 1000 0 0.5 13 | hpf 1000 20

**bpf.awk**

Implements

`bpf.c`as an awk script, i.e. it applies a band pass filter to x[n] read from stdin.

Example: brownrv 1000 0 0.5 13 | bpf.awk -v s=1000 -v f=20 -v b=10 where s = sampling frequency, f = center frequency, b = half power bandwidth This produces the same output as runningbpf.clike so: brownrv 1000 0 0.5 13 | bpf 1000 20 10

**bsf.awk**

Implements

`bsf.c`as an awk script, i.e. it applies a band stop filter to x[n] read from stdin.

Example: brownrv 1000 0 0.5 13 | bsf.awk -v s=1000 -v f=20 -v b=10 where s = sampling frequency, f = stop frequency, b = half power bandwidth This produces the same output as runningbsf.clike so: brownrv 1000 0 0.5 13 | bsf 1000 20 10

Send comments to: Richard Hollos (richard[AT]exstrom DOT com)

Copyright 2014 by Exstrom Laboratories LLC