function value = ell ( i, x_data, x )
% ell evaluates the i-th Lagrange basis function.
  value = ones ( size ( x ) );
  n = length ( x_data );
  
  for j = 1 : n
    if ( i ~= j )
      value = value .* ( x - x_data(j) ) ./ ( x_data(i) - x_data(j) );
    end
  end
  
  return
end

