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$.

• Isn't [1.25 .5 -.75] better, [1 -1 1] -> 0 ? I was hoping that one IIR term would be better yet. Thanks – denis Feb 2 '16 at 17:48
• @denis: Maybe yes, it depends on your expected input data. If they're very noisy you probably should use a better filter. If you add more details to your question it might be easier to find something appropriate. The solution in my answer has admittedly no low pass characteristic, it's just extremely simple and may work well for well-behaved (i.e., almost noise-less) data. – Matt L. Feb 2 '16 at 18:01