function w = moments_legendre ( m, a, b )

%*****************************************************************************80
%
%% moments_legendre() returns moments of the Legendre weight on [A,B].
%
%  Discussion:
%
%    mu(k) = integral ( a <= x <= b ) x^k dx
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 September 2013
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the number of moments desired.
%
%    real A, B, the left and right endpoints of the interval.
%
%  Output:
%
%    real W(M), the weighted integrals of X^0 through X^(M-1).
%
  w = zeros ( m, 1 );

  bk = 1.0;
  ak = 1.0;
  for k = 1 : m
    bk = bk * b;
    ak = ak * a;
    w(k) = ( bk - ak ) / double ( k );
  end

  return
end

