function wval = r8poly_lagrange_0 ( npol, xpol, xval )

%*****************************************************************************80
%
%% r8poly_lagrange_0() evaluates the Lagrange factor at a point.
%
%  Discussion:
%
%    The power sum form of a polynomial is:
%
%      p(x) = c(0) + c(1) * x + ... + c(n-1) * x^(n-1) + c(n) * x^(n)
%
%    Because MATLAB doesn't allow 0 indexing, we use an adjusted formula:
%
%      p(x) = c(1) + c(2) * x + ... + c(n) * x^(n-1) + c(n+1) * x^(n)
%
%
%    W(X) = Product ( 1 <= I <= NPOL ) ( X - XPOL(I) )
%
%    For a set of points XPOL(I), 1 <= I <= NPOL, the IPOL-th Lagrange basis
%    polynomial L(IPOL)(X), has the property:
%
%      L(IPOL)( XPOL(J) ) = delta ( IPOL, J )
%
%    and may be expressed as:
%
%      L(IPOL)(X) = W(X) / ( ( X - XPOL(IPOL) ) * W'(XPOL(IPOL)) )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 January 2004
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer NPOL, the number of abscissas.
%    NPOL must be at least 1.
%
%    real XPOL(NPOL), the abscissas, which should be distinct.
%
%    real XVAL, the evaluation point.
%
%  Output:
%
%    real WVAL, the value of the Lagrange factor at XVAL.
%
  wval = prod ( xval - xpol(1:npol) );

  return
end
