# A Differentiator With a Difference

Some time ago I was studying various digital differentiating networks, i.e., networks that approximate the process of taking the derivative of a discrete time-domain sequence. By "studying" I mean that I was experimenting with various differentiating filter coefficients, and I discovered a computationally-efficient digital differentiator. A differentiator that, for low fequency signals, has the power of George Foreman's right hand! Before I describe this differentiator, let's review a few fundamentals of simple digital differentiators.

# Digital Differentiation

While the idea of differentiation is well-defined in the world of continuous signals, the notion of differentiation is not well defined for discrete signals. However, fortunately we can approximate the calculus of a derivative operation in the domain of discrete signals. (While DSP purists prefer to use the terminology *digital differencer*, here I'll use the phrase *differentiator*.) To briefly review the notion of differentiation, think about a continuous sinewave, whose frequency is ω radians/second, represented by

* *

(1) |

The derivative of that sinewave is

| (2) |

So the derivative of a sinewave is a cosine wave whose amplitude is proportional to the original *x*(*t*) sinewave's frequency. Equation (2) tells us that an ideal differentiator's frequency magnitude response is a straight line increasing with frequency ω. With that thought in mind, I'll now mention two common discrete-time FIR (nonrecursive) differentiators: a *first-difference *and a *central-difference *differentiator. They are computationally simple schemes for estimating the derivative of a digital *x*(*n*) time-domain signal sequence with respect to time.

The *first-difference* differentiator, the simple process of computing the difference between successive *x*(*n*) signal samples, is defined in the time domain by

| (3) |

The frequency magnitude response of that differentiator is the dashed |*H*_{fd}(ω)| curve in Figure 1(a). (For comparison reasons, I also show an ideal differentiator's straight-line |*H*_{ideal}(ω)| = ωmagnitude response in Figure 1(a). The frequency axis in that figure covers the positive frequency range 0 ≤ω≤ π samples/radian, corresponding to a cyclic frequency range of 0 to *f*_{s}/2, where *f*_{s} is the *x*(*n*) sample rate in Hz.) Equation (3) is sweet in its simplicity but unfortunately its |*H*_{fd}(ω)| tends to amplify high-frequency noise that often contaminates real-world signals. For that reason the *central-difference* differentiator is often used in practice.

The time-domain expression of the central-difference differentiator is

(4) |

The central-difference differentiator's frequency magnitude response is the dotted |*H*_{cd}(ω)| curve in Figure 1(a). The price we pay for |*H*_{cd}(ω)|'s desirable high-frequency (noise) attenuation is that its frequency range of linear operation is only from zero to roughly ω = 0.16π samples/radian (0.08*f** _{s}* Hz) which is, unfortunately, less than the frequency range of linear operation of the first-difference differentiator.

# Here's the Beef

Now, ... for the computationally-efficient differentiator that maintains the central-difference differentiator's beneficial high-frequency attenuation behavior, but extends its frequency range of linear operation. The differentiator that I'm promoting is defined by

| (5) |

This novel differentiator's normalized magnitude response is the solid |*H*_{dif}(ω)| curve in Figure 1(a), where we see that its frequency range of linear operation extends from zero to approximately ω= 0.34π samples/radian (0.17*f** _{s}* Hz). The

*y*

_{dif}(

*n*) differentiator is twice the usable frequency range of the central-difference differentiator.

The implementation of the *y*_{dif}(*n*) differentiator is shown in Figure 1(b) where a delay block comprises two unit delays. The *folded-FIR* block diagram for this differentiator is presented in Figure 1(c) where only a single multiply need be performed per *y*_{dif}(*n*) output sample. The really slick aspect of the *y*_{dif}(*n*) differentiator is that its non-unity coefficients (±1/16) are integer powers of two. This means that a multiplication in Figure 1 can be implemented with an arithmetic right shift by four bits. Happily, such a binary right-shift implementation is a linear-phase multiplierless differentiator!

**Figure 1:** Efficient differentiator: (a) performance; (b) standard block diagram; (c) folded block diagram.

Another valuable feature of the Equation (5) *y*_{dif}(*n*) differentiator is that its time delay (group delay) is exactly three sample periods (3/*f*_{s}). Having a delay that's an integer number of samples makes this differentiator convenient when the differentiator's output must be synchronized with other time-domain sequences, such as for use with popular FM demodulation methods.

[Sept. 2015 Note: I've written a more recent blog regarding another interesting differentiator. That blog is at:

http://www.dsprelated.com/showarticle/814.php ]

Copyright © 2007, Richard Lyons, All Rights Reserved

**Next post by Rick Lyons:**

Spectral Flipping Around Signal Center Frequency

## Comments:

I have no mathematical derivation for the simple digital differentiator described in this blog. Years ago I was looking at DSP pioneer Richard Hamming’s 1998 book titled: “Digital Filters.” I looked at his simple differentiators, one of which had the coefficients: -1/6,8/6,0,-8/6, and 1/6. I thought, “Gee. It would be nice if the denominator was an 8 instead of a 6 -- then the division be could be replaced by a binary right shift of three bits.” After that, like Thomas Edison trying to find the right material for his light bulb’s filament, I merely started experimenting with various simple differentiator coefficients (having alternating +/- signs) whose denominators were an integer power of two. I finally “stumbled” upon the coefficients described in this blog. Joseph, beware. If I recall correctly, the differentiator described in this blog has a linear gain of 1.68 rather than an ideal differentiator’s gain of one.

[-Rick-]