function a = MyInterpV(x,y,u,v)

%

%   x is a column n-vector with distinct components.

%   y is a column n-vector.

%   u is a scalar (optional).

%   v is a scalar (optional).

%

%   a is a column n-vector with the property that

%   if p(x) = a(1) + a(2)xbar + ... a(n)xbar^(n-1) with

%       xbar = (x-u)/v then p(x(i)) = y(i), i=1:n.

%

%   A call of the form MyInterpV(x,y,u) assumes v=1.

%   A reference of the form MyInterpV(x,y) assumes u=0 and v=1.



n = length(x);

V1 = ones(n,n);

if nargin <= 3

   v = 1;

end



if nargin == 2

   u = 0;

end





xbar = (x-u)/v;

for j=2:n

   % Set up column j.

   V1(:,j) = xbar.*V1(:,j-1);

end

a = V1\y;

