function x = normalize ( n, x )

%*****************************************************************************80
%
%% normalize() scales a vector X so its entries sum to 1.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    21 February 2016
%
%  Author:
%
%    Original C version by Warren Smith.
%    This version by John Burkardt.
%
%  Input:
%
%    integer N, indicates the size of X.
%
%    real X(1:N+1), the vector to be normalized.
%    Entries X(2) through X(N+1) will sum to 1 on output.
%
%  Output:
%
%    real X(1:N+1), the normalized vectort.
%
  s = sum ( abs ( x(2:n+1) ) );
  x(2:n+1) = x(2:n+1) / s;

  return
end

