Wave Walker DSP

Trending

DSP for Beginners: Simple Explanations for Complex Numbers! The second edition includes a new chapter on complex sinusoids.

Derivative Filter Impulse Response Derivation
November 24, 2021

Introduction

Sooner or later you’re going to have to apply a derivative to a discrete-time signal. An example would be building a derivative matched filter (DMF) for timing recovery [harris2021, p.490]. This brings us to our first piece of DSP Wisdom: If you need to do something in DSP it’s best to do it with a filter. So how do you build a derivative filter?

We’ll start with the derivation in continuous-time to make the math tractable then transform it into discrete-time. A follow-up post will discuss methods and alternatives for designing the derivative filter weights. Richard Lyons has a really great section on derivative filters in his textbook that is totally worth your time if you’re interested in more information on the topic [lyons2011, p.361].

Check out these other posts on filter design:

Continuous-Time Derivative Filter

The time-derivative of signal can be written as the derivative of the inverse Fourier transform,

(1)

Pulling the derivative through the integral in (1) results in

(2)

The derivative of the complex sinusoid can be written as

(3)

Substituting the derivative (3) into (2) can be written as

(4)

The signal derivative (4) can be rewritten using the inverse Fourier transform operator such that

(5)

A frequency-domain derivative filter is defined as

(6)

such that (5) is

(7)

The product of two frequency-responses A(f) and B(f) are related through the Fourier transform to the convolution of their impulse-responses a(t) and b(t)

(8)

The signal derivative (7) can therefore be written as the convolution of two impulse-responses, the signal x(t) and the derivative filter h(t),

(9)

The impulse response of the derivative filter is defined through the inverse Fourier transform

(10)

Figure 1 is a 3D plot of the frequency-response H(f) for some values of f where

(11)

(12)

The magnitude and phase of the derivative filter are given in Figure 2.

Transforming into a Discrete-Time Frequency Response

A discrete-time implementation of from (6) is created by truncating the frequency response. Where H(f) is defined over the discrete-time Fourier transform (DTFT) is defined by

(13)

where

(14)

The sampling rate defines the amount of truncation such that is defined over or equivalently .

Figure 3 gives the frequency-response for the discrete-time derivative filter. The frequency-response is periodic in and three repetitions are shown, denoted as Nyquist zones -1, 0 and 1. Figure 4 is the magnitude and phase which also shows three Nyquist zones.

Discrete-Time Derivative Filter

The continuous-time frequency-response H(f) in (6) was mapped into discrete-time in (13). The inverse DTFT is used to transform into the impulse-response h[n] where the inverse DTFT is given by [oppenheim1999, p.48]

(15)

Substituting from (13) into (15) results in

(16)

The inverse DTFT integral (16) can be solved through the use of integration by parts. Define u and v according to

(17)

Integration by parts of the inverse DTFT integral (16) is defined as

(18)

and substituting (17) into (18) results in

(19)

Evaluating the Integral (Part 1)

The first part of (19) can be simplified as

(20)

Equation (20) can be simplified to

(21)

The term can be written as

(22)

for all n, however evaluating (21) at n=0 must be done through L’Hopital’s rule,

(23)

Using (23) and (22), equation (21) is written as

(24)

Evaluating The Integral (Part 2)

The second part of (19) is

(25)

which can be simplified by a trigonometric identity to

(26)

The term can be reduced to

(27)

for all n, however evaluating (26) at n=0 must be done through L’Hopital’s rule. Applying L’Hopital’s Rule on (26) is

(28)

which still cannot be evaluated at n=0 and therefore the rule is applied once more,

(29)

Derivative Filter Impulse Response

The impulse-response of the derivative filter h[n] (19) is the summation of the two terms (24) and (29)

(30)

which is an infinitely long filter. A truncated impulse response from (30) is given in Figure 5 and the magnitude and phase of the frequency response in Figure 6.

Conclusion

A derivative filter is a useful tool to have in your DSP kit. The derivation starts with a time-derivative of the frequency-response which results in the product of two frequency responses, or equivalently the convolution of two impulse-responses. Applying the inverse DTFT results in an infinitely long impulse response for the derivative filter.

Figure 6 shows a different magnitude and phase than the ideal plots in Figure 2. Be on the look out for part 2 in which the differences will be discussed in detail and methods will be given for designing derivative filter weights.

Check out these other posts on filter design:

2 Responses

1. Oh no! My entire career in DSP contradicts your Wisdom: “If you need to do something in DSP it’s best to do it with a filter.” Here “filter” means “linear time-invariant system,” which means the input and output of the “something” is a convolution, and convolutions are linear. But cyclostationary signal processing, spectrum estimation, frequency translation, and many signal-parameter estimators involve nonlinear operations. We need some more Wisdom to cover those of us working on the fringes of DSP–I agree that linear time-invariant systems are foundational, but what about us poor nonlinear signal processors?? 🙂

1. Good catch! I’m trying to move people away from just throwing NumPy at a DSP problem without thinking about how it would impact the impulse and frequency responses. I agree that non-linearities are useful in DSP but they need to come with a safety warning.

There’s a lot of goodness to be had just by averaging through filtering, and I put things like CSP and spectral estimation into that general bucket. I’m using “filter” loosely, broader than just LTI systems. Correlation, convolution and FIR filters all feel like they are siblings and that’s what I’m trying to get at when I say “use a filter”.

For everything there is a season, and a time for every matter under heaven. A time to cast away stones, and a time to gather stones together. A time to embrace, and a time to refrain from embracing. Ecclesiastes 3:1,5
The earth was without form and void, and darkness was over the face of the deep. And the Spirit of God was hovering over the face of the waters. Genesis 1:2
Behold, I am toward God as you are; I too was pinched off from a piece of clay. Job 33:6
Enter His gates with thanksgiving, and His courts with praise! Give thanks to Him; bless His name! Psalm 100:4
Lift up your hands to the holy place and bless the Lord! Psalm 134:2
Blessed is the man who trusts in the Lord, whose trust is the Lord. He is like a tree planted by water, that sends out its roots by the stream, and does not fear when heat comes, for its leaves remain green, and is not anxious in the year of drought, for it does not cease to bear fruit. Jeremiah 17:7-8
He said to him, “You shall love the Lord your God with all your heart and with all your soul and with all your mind. This is the great and first commandment. And a second is like it: You shall love your neighbor as yourself. On these two commandments depend all the Law and the Prophets.” Matthew 22:37-39
Then He said to me, “Prophesy over these bones, and say to them, O dry bones, hear the word of the Lord. Thus says the Lord God to these bones: Behold, I will cause breath to enter you, and you shall live." Ezekiel 37:4-5
Riches do not profit in the day of wrath, but righteousness delivers from death. Proverbs 11:4
The angel of the Lord appeared to him in a flame of fire out of the midst of a bush. He looked, and behold, the bush was burning, yet it was not consumed. And Moses said, “I will turn aside to see this great sight, why the bush is not burned.” When the Lord saw that he turned aside to see, God called to him out of the bush, “Moses, Moses!” And he said, “Here I am.” Exodus 3:2-3
Daniel answered and said: “Blessed be the name of God forever and ever, to whom belong wisdom and might. He changes times and seasons; He removes kings and sets up kings; He gives wisdom to the wise and knowledge to those who have understanding." Daniel 2:20-21
Now the Lord is the Spirit, and where the Spirit of the Lord is, there is freedom. 2 Corinthians 3:17

This website participates in the Amazon Associates program. As an Amazon Associate I earn from qualifying purchases.