I want to fit the polynomial function
$f(x) = \alpha_0 +\alpha_1 x +\alpha_2 x^2 $
using given data such that the errors $y_c-f(x_c)$ are minimized (least squares).
Obtained is the experimental data shown below.
$c $|-2 -1 0 1 2
$x_c|$-2 -1 0 1 2
$y_c|$ 0 0 1 0 0
I want to find $\alpha_0$ , $\alpha_1$ and $ \alpha_2 $.
The least squares solution is formulated as $x^* = (A^TA)^{-1}A^Tb $
I have used
$A = \begin{bmatrix} 1&-2&(-2)^2\\1&-1&(-1)^2\\1&0&0\\1&1&1\\1&2&(2)^2 \end{bmatrix}$, $b = \begin{bmatrix} 0\\0\\1\\0\\0 \end{bmatrix}$
and I get as answer
$\begin{bmatrix} \alpha_0\\\alpha_1\\\alpha_2 \end{bmatrix} = \begin{bmatrix} 0.4857\\0\\-0.1429 \end{bmatrix}$
which is wrong (I've plotted it).
I really hope someone can help me out.