function [p] = hw4afn(x,y,n,z)

   p = 0;
   for i = 1:n
      theprod = 1;
      for j = 1:n
         if j ~= i
            theprod = theprod*(z-x(j))/(x(i)-x(j));
         end
      end
      p = p+y(i)*theprod;
   end

end
