We need to find a linear function $f(x)=a_1x+a_0$ such that $\sum_{i=1}^4(f(x_i)-y_i)^2$ is minimal. $x_1=-2,x_2=-1,x_3=0,x_4=1,$ and $y_1=1,y_2=2,y_3=0,y_4=1$.
So, if I am right, I need to solve the least-squares problem for $$A=\begin{bmatrix}1 & -2\\1 & -1\\ 1&0\\1&1\end{bmatrix},b=\begin{bmatrix}1\\2\\0\\1\end{bmatrix}$$ and our "$x$"$=\begin{bmatrix}a_0\\a_1\end{bmatrix}$.
Is it correct so far?
I'm asking because the results I get on paper are questionable.