// The data points need to be stored in two vectors x and y
// in column format.  If not equal length, then exit program
n = max(size(x));
m = max(size(y));
if n<>m
  display('x and y are not of the same dimension')
else
//  Vectors need to be in columns

  [r c ] = size(x);
  if r < c
     x = x';
  end
  [r c ] = size(y);
  if r < c
     y = y';
  end

//  will need to check that all x's are distinct

  for i=1:n
    for j=1:n
      a(i,j)=x(i)^(j-1);
    end
  end
  c = inv(a)*y;  
  u = min(x)-0.1:0.01:max(x)+0.1;
  v = c(n);
  for k=n-1:-1:1
    v = v.*u + c(k);
  end
  plot(u,v)
  plot(x,y,'+')
end
