clc, clear all

x=[0 1 3 4 6 7 9 10]';
y=[0 1.2 2.0 2.4 2.5 2.2 1.4 0.3]';
b=x-5
A=[b.^2 b ones(size(b))]
AA=A'*A
Ay=A'*y
A\y

%% b
A=[x.^2 x ones(size(x))];
c=A\y;
yanp=A*c;
r=y-yanp;

disp([x y yanp r])
xx=(0:0.1:10)';
AA=[xx.^2 xx ones(size(xx))];
yy=AA*c;
plot (x,y,'*',xx,yy, x,yanp,'o' )
