x = [0; 1; 2; 3; 4; 5]
y = [2; 3; 2.5; 2.2; 0.4; 1.7]

A = [
      1.0   0.0   0.0   0.0
      1.0   1.0   1.0   1.0
      1.0   2.0   4.0   8.0
      1.0   3.0   9.0  27.0
      1.0   4.0  16.0  64.0
      1.0   5.0  25.0 125.0
    ]

ATA = transpose(A) * A

cond(ATA)

alpha = ATA \ transpose(A)*y

p = fliplr(transpose(alpha))

xplot = [0.0 : .05 : 5.0];
yplot1 = polyval(p, xplot);

A = [
      1.0 0.0 0.0 0.0
      0.5 0.5 0.0 0.0
      0.0 1.0 0.0 0.0
      0.0 0.5 0.5 0.0
      0.0 0.0 1.0 0.0
      0.0 0.0 0.5 0.5
    ]

ATA = transpose(A) * A

cond(ATA)

alpha = ATA \ transpose(A)*y

for i = 1:101
  yplot2(i) = sp1(xplot(i), alpha);
end
plot(x, y, 'o', xplot, yplot1, '-', xplot, yplot2, '-')
