Fit polynomial function using experimental data (least squares) 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.
 A: I have tested your answer by matlab and plotted the points and the 2-d polynomial on a figure in matlab and got the answer:

it seems to be right. The best 2-d polynomial fitting five points will be your answer. why do you think it's wrong?
here's the code I used in matlab:  
A=[1 -2 4;1 -1 1;1 0 0;1 1 1;1 2 4]
B=[0;0;1;0;0]
C=((A'*A)^(-1))*A'*B
syms x
f=[1 x x^2]*C
ezplot(f)
hold on
d=[-2;-1;0;1;2]
e=[0;0;1;0;0]
plot(d,e,'r*')

A: Your method is correct and your numerical answer is correct.  Apparently your only mistake is to think you made a mistake.  Your $x$ values are in an arithmetic progression: $-2,-1,0,1,2$.  Your $y$ values are symmetic about the middle: $0,0,1,0,0$. The largest $y$ value is the one in the middle. Therefore one expects a parabola opening downward, symmetric about the $y$-axis. So you want $\alpha_1=0$ and $\alpha_2<0$, and since the average $y$ value is positive you should see $\alpha_0>0$.  And that's just what you've got.  The least-squares fit is
$$
y = \frac{17}{35} - \frac 1 7 x^2.
$$
