Short lowpass filter that also extrapolates lines
The most straight-forward solution is a length $N$ FIR filter with impulse response

$$h[n]=\begin{cases}\frac{N}{N-1},&amp;\quad n=0\\
-\frac{1}{N-1},&amp;\quad n=N-1\\0,&amp;\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$.