# Filter Optimization Packages for Matlab and Mathematica

Niranjan Damera-Venkata and Brian L. Evans
Embedded Signal Processing Laboratory
Department of Electrical and Computer Engineering
The University of Texas at Austin, Austin, TX 78712-1084

• Software accompanying the book Filter Design for Signal Processing (2001)
• Applets for Filter Optimization provide a Web-based interface to the filter optimization packages
• Version 1.1, June 23, 1998: simultaneously optimizing analog filter designs for any combination of magnitude, phase, and step responses, and quality factors, based on pole-zero locations
• Version 1.0, November 21, 1997: simultaneously optimizing all-pole analog filter designs for any combination of magnitude, phase, and step responses, and quality factors, based on pole locations

## Introduction

The traditional approach to infinite impulse response (IIR) filter implementation is to first design a conventional IIR filter to double-precision accuracy in the pole and zero locations and then iteratively adjust the poles and zeros in the design for the target implementation technology (breadboard components, switched capacitor, custom integrated circuit, digital signal processor, heterogeneous, and so forth). Due to the implementation technology, it is possible for a stable filter to become unstable due to the truncation of the pole and zero locations.

A key technology-independent measure of a filter's robustness under implementation is a quality factor. A quality factor is associated with each conjugate pair of poles. For analog filters, the quality factor is the radius of the pole divided by -2 times its real part. The quality factor varies from 0.5 (purely real pole; 100% damping) and infinity (imaginary pole; 100% oscillator). The approximate technology limits are 10 (low-end breadboard components and 8-bit microcontrollers), 25 (high-end breadboard components and 16-bit digital signal processor), and 40 (switched capacitor).

A recurring problem in filter implementation is that the conventional filter design formulas yield filters with quality factors in the 40-80 range, even for low filter orders. For example, using the elliptic filter design formulas, Matlab returns a 4th-order elliptic filter with quality factors 1.7 and 61 for a given magnitude specification. This filter can only be realized with expensive custom integrated circuitry or 32-bit floating-point processors (using sampling and quantization). Using the Filter Optimization Packages, we have developed Matlab code that can take this filter as the initial guess, and in less than a minute, return a 4th-order filter that meets the original specifications but with quality factors of 0.68 and 10. The optimized design can now be easily implemented in a wide variety of technologies.

## Description

We have developed Mathematica 2.2/3.0 packages to provide a framework for generating Matlab 4/5 programs to optimize multiple characteristics of existing filter designs subject to constraints on filter characteristics. The current version simultaneously optimizes analog filter designs for magnitude response, deviation from linear phase, peak overshoot, and quality factors while satisfying constraints on the same criteria. New characteristics can be easily added. The release includes the generated Matlab code in the release for fourth-, sixth-, and eight-order filters. The generated Matlab code relies on the Optimization Toolbox.

We formulate filter optimization as a Sequential Quadratic Programming (SQP) problem. SQP requires real-valued, continuous, twice differentiable cost function and constraints. Provided that the solution space is convex, SQP in theory always converges to the global optimum. In practice, one must supply closed-form expressions for the gradients of the objective function and constraints. We use Mathematica to derive analytic objective functions and constraints, compute the gradients of the objective function and constraints, and convert the algebraic formulation into correct Matlab code.

## Ownership

These packages were initially developed by Brian L. Evans during the 1993-1994 academic year while he was a post-doctoral researcher at the University of California at Berkeley with the Ptolemy project. The packages are copyright © 1993-1998 by the Regents of the University of California. The packages are released under a very liberal freely distributable copyright and licensing agreement.

## References

The packages are explained by the following papers: