# Short lowpass filter that also extrapolates lines

I'm looking for a short lowpass filter that also extrapolates lines, [0 1 2 3] --> 4,
so I need (correct me) $H([\ 0\ \ 0.25\ \ 0.5\ ]) \approx [ 1\ \ 2\ \ 0 ]$ .
How close can one get to this with 2 to 4 FIR and 1 IIR coefficient ?

Added: for a 3-term FIR, I want

Input     -> output
1  1  1  -> 1  # const -> const
-1  0  1  -> 2  # extrapolate lines
1 -1  1  -> 0  # low-pass


Solving these 3 equations gives the FIR [1.25 .5 -.75] . I can do longer FIRs by least squares + fiddling. But how do I do FIR x 1-term IIR ? Is there a general approach to filters that extrapolate lines ?

• Do you care about causal filters? Why do you want to have both line extrapolation and low-pass behavior? While not contradictory, knowing the most important features of these two can help answering – Laurent Duval Dec 30 '16 at 10:21
• @Laurent Duval, what I really want to do is smooth-gradient-estimates-for-steepest-descent-optimization, this question. Extrapolating linear motion is clear; is "anti zig-zag" low-pass ? – denis Dec 30 '16 at 17:55

The most straight-forward solution is a length $N$ FIR filter with impulse response
$$h[n]=\begin{cases}\frac{N}{N-1},&\quad n=0\\ -\frac{1}{N-1},&\quad n=N-1\\0,&\quad\text{otherwise}\end{cases}$$
For $N=3$, the output sample computed from three input samples x = [1 3 5] is $\frac32\cdot 5 - \frac12\cdot 1 =7$, as it should be. Note that this filter is very cheap, it has only two non-zero taps regardless of the value $N$.