# What is the name of a low-pass filter that tracks rate of change?

When applying a low-pass filter to a constantly changing signal, there will be a lag between the actual value and the filtered value. For example, if f(x) = x, the regular low-pass filter output will always be less than f(x).

I remember coming across a filter that also tracked the rate of change, thus eliminating the lag when the rate of change is constant. At the time I didn't have any use for it, but it struck me as a clever solution to the problem.

This seems rather straightforward, but instead of trying to reinvent it myself I would like to read what has already been written. But I can't seem to find the name for it.

Is there a name for some common low-pass filter algorithm that accurately tracks a signal that has constant rate of change?

I was able to remember how the filter works. The idea is very simple, a second low-pass filter tracks the steady-state error in the result of the first one, and it is then added to the output: Based on some testing it will work well for my purpose, which is in motor control where rotation rate is usually constant: Best term I've found so far for this is 'linear prediction filter', as hinted by Marcus Müller in the comments.

• That looks like a linear predictor ;) Sep 16 at 14:04
• @MarcusMüller Wow, thanks! "Linear prediction" gives very useful results.
– jpa
Sep 16 at 16:44
• But it can be reduced/transformed to some well-known type of filter, right? Sep 18 at 23:13
• @PeterMortensen If the low-pass filters are FIR, the combination can be reduced to a single FIR filter, but AFAIK not to any of the common types with simple formulas for the coefficients. And similarly for IIR.
– jpa
Sep 19 at 5:08

I do not think that there's a specific name for this type of lowpass filter. There are indeed similarities between the cascade of two lowpass filters as suggested in the OP's answer, and a combination of a lowpass filter with a linear predictor for a ramp signal. It's interesting to compare the behavior of these two systems when tracking a ramp at the input. The two approaches are not identical, but they do have some similarities.

A linear predictor predicting a ramp $$M$$ samples in the future is given by

$$y[n] = x[n] + M\big(x[n]-x[n-1]\big)\tag{1}$$

The prediction length $$M$$ must be chosen to equal the delay of the lowpass filter. In case of a linear phase FIR filter we have a constant delay of $$M=(N-1)/2$$, where $$N$$ is the number of filter taps. For (minimum phase) IIR filters we can use the group delay at DC.

I used a simple $$21$$-tap FIR lowpass filter (cut-off at Nyquist$$/2$$) designed by windowing, and cascaded it with the predictor $$(1)$$. The figure below shows the time domain signals and the frequency domain responses of this cascade, and of the cascaded lowpass filters as described in the OP's answer. It can be seen that the system with the predictor recovers faster after a change in the input signal. This comes at the price of a higher overshoot in the frequency domain. The latter problem could be alleviated by choosing a lower cut-off frequency of the lowpass filter. I did exactly the same comparison with a Butterworth IIR lowpass filter (order $$10$$). The figure below shows that the differences between the two methods are less pronounced in the time domain. Yet, there's still a significant difference in the frequency domain. Note that for both filter types (FIR and IIR), I've used identical filters for implementing the cascade of lowpass filters. In this case, the complexity of the solution using cascaded lowpass filters is approximately twice the complexity of the solution with the linear predictor.

The reason why both systems can track a ramp at the input without delay is the fact that both systems have zero group delay at DC. Furthermore, the group delay is flat at DC, which means that a number of derivatives also vanish. The figure below shows the phase and group delay responses of the cascade of two lowpass filters and of the lowpass filter combined with the linear predictor. In both cases, the lowpass filter is the same tenth order Butterworth filter shown above. Clearly, for both systems the phase as well the group delay are flat at DC, and the group delay vanishes at DC. • Interesting Matt! Thanks for pointing out the impact the the filter's frequency response. I see how x[n]-x[n-1] is just a slope predictor (differencer) and that M * the slope would be the ideal correction; this then made me start thinking of how alternate differencing implementations that are less sensitive to higher frequency noise (such as the central difference 0.5(x[n]-x[n-2]) and others that are not as simple) could perform in comparison. I didn't try but suspect it would have similar time performance with some reduction in the frequency peaking. Sep 18 at 10:54
• @DanBoschen: Yes, you're right I guess. But I think a very similar thing can be achieved by just lowering the cut-off frequency of the lowpass filter. This is all very similar to lowpass differentiators, which I've discussed a bit in this answer. Sep 18 at 11:06