```python
%matplotlib inline
from sympy import *
init_session()
```

    IPython console for SymPy 1.8 (Python 3.9.7-64-bit) (ground types: python)
    
    These commands were executed:
    >>> from __future__ import division
    >>> from sympy import *
    >>> x, y, z, t = symbols('x y z t')
    >>> k, m, n = symbols('k m n', integer=True)
    >>> f, g, h = symbols('f g h', cls=Function)
    >>> init_printing()
    
    Documentation can be found at https://docs.sympy.org/1.8/
    


# Quadratic finite impulse response predictor


```python
var("a, b, c, x", real=True)
```

Samples -- from $s(0)$ to $s(n - 1)$ these are stored in the history buffer, $s(n)$ is the new predicted sample


```python
s = Function("s", real=True)(x)
s
```

Function that we use for predicting


```python
eq = Equality(s, a * x**2 + b * x + c)
eq
```

## Least squares
Number of samples in the history buffer:


```python
n = 4
```


```python
i = symbols("i")
error_eqs = Sum((eq.rhs - eq.lhs).subs(x, i)**2, (i, 0, n - 1))
error_eqs
```


```python
params = solve([error_eqs.diff(sym).doit().simplify() for sym in (a, b, c)], (a, b, c))
params
```


```python
prediction_lstsq = eq.subs(params).simplify()
prediction_lstsq
```


```python
prediction_lstsq.subs(x, n)
```


```python

```


```python

```

3181f7d2d43846a27beaafd3753759153f627d51
ipynb
Jupyter Notebook
jupyter/predictors.ipynb
bluecube/tablog
6372234bcceff55a26e43e85302ea01420b311c9
MIT
jupyter/predictors.ipynb
bluecube/tablog
6372234bcceff55a26e43e85302ea01420b311c9
MIT
jupyter/predictors.ipynb
bluecube/tablog
6372234bcceff55a26e43e85302ea01420b311c9
MIT
Qwen/Qwen-72B
1. YES
2. YES