function [ x, w ] = legendre_set_x2 ( n )

%*****************************************************************************80
%
%% LEGENDRE_SET_X2 sets a Gauss-Legendre rule for ( 1 + X )**2 * F(X) on [-1,1].
%
%  Discussion:
%
%    The integral:
%
%      Integral ( -1 <= X <= 1 ) ( 1 + X )**2 * F(X) dX
%
%    The quadrature rule:
%
%      Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    13 October 2005
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Arthur Stroud, Don Secrest,
%    Gaussian Quadrature Formulas,
%    Prentice Hall, 1966,
%    LC: QA299.4G3S7.
%
%  Parameters:
%
%    Input, integer N, the order.
%    N must be between 1 and 9.
%
%    Output, real X(N), the abscissas.
%
%    Output, real W(N), the weights.
%
  x = zeros ( n, 1 );
  w = zeros ( n, 1 );

  if ( n == 1 )

    x(1) =  0.5;

    w(1) =  2.66666666666666666666666666666;

  elseif ( n == 2 )

    x(1) = -0.0883036880224505775998524725910;
    x(2) =  0.754970354689117244266519139258;

    w(1) =  0.806287056638603444666851075928;
    w(2) =  1.86037961002806322199981559074;

  elseif ( n == 3 )

    x(1) = -0.410004419776996766244796955168;
    x(2) =  0.305992467923296230556472913192;
    x(3) =  0.854011951853700535688324041976;

    w(1) =  0.239605624068645584091811926047;
    w(2) =  1.16997015407892817602809616291;
    w(3) =  1.25709088851909290654675857771;

  elseif ( n == 4 )

    x(1) = -0.591702835793545726606755921586;
    x(2) = -0.0340945902087350046811467387661;
    x(3) =  0.522798524896275389882037174551;
    x(4) =  0.902998901106005341405865485802;

    w(1) =  0.0828179259993445222751812523731;
    w(2) =  0.549071097383384602539010760334;
    w(3) =  1.14767031839371367238662411421;
    w(4) =  0.887107324890223869465850539752;

  elseif ( n == 5 )

    x(1) = -0.702108425894032836232448374820;
    x(2) = -0.268666945261773544694327777841;
    x(3) =  0.220227225868961343518209179230;
    x(4) =  0.653039358456608553790815164028;
    x(5) =  0.930842120163569816951085142737;

    w(1) =  0.0329106016247920636689299329544;
    w(2) =  0.256444805783695354037991444453;
    w(3) =  0.713601289772720001490035944563;
    w(4) =  1.00959169519929190423066348132;
    w(5) =  0.654118274286167343239045863379;

  elseif ( n == 6 )

    x(1) = -0.773611232355123732602532012021;
    x(2) = -0.431362254623427837535325249187;
    x(3) = -0.0180728263295041680220798103354;
    x(4) =  0.395126163954217534500188844163;
    x(5) =  0.736872116684029732026178298518;
    x(6) =  0.948190889812665614490712786006;

    w(1) =  0.0146486064549543818622276447204;
    w(2) =  0.125762377479560410622810097040;
    w(3) =  0.410316569036929681761034600615;
    w(4) =  0.756617493988329628546336413760;
    w(5) =  0.859011997894245060846045458784;
    w(6) =  0.500309621812647503028212451747;

  elseif ( n == 7 )

    x(1) = -0.822366333126005527278634734418;
    x(2) = -0.547034493182875002223997992852;
    x(3) = -0.200043026557985860387937545780;
    x(4) =  0.171995710805880507163425502299;
    x(5) =  0.518891747903884926692601716998;
    x(6) =  0.793821941703901970495546427988;
    x(7) =  0.959734452453198985538996625765;

    w(1) =  0.00714150426951365443207221475404;
    w(2) =  0.0653034050584375560578544725498;
    w(3) =  0.235377690316228918725962815880;
    w(4) =  0.505171029671130381676271523850;
    w(5) =  0.733870426238362032891332767175;
    w(6) =  0.725590596901489156295739839779;
    w(7) =  0.394212014211504966587433032679;

  elseif ( n == 8 )

    x(1) = -0.857017929919813794402037235698;
    x(2) = -0.631543407166567521509503573952;
    x(3) = -0.339104543648722903660229021109;
    x(4) = -0.0111941563689783438801237300122;
    x(5) =  0.316696017045595559454075475675;
    x(6) =  0.609049663022520165351466780939;
    x(7) =  0.834198765028697794599267293239;
    x(8) =  0.967804480896157932935972899807;

    w(1) =  0.00374814227227757804631954025851;
    w(2) =  0.0357961737041152639660521680263;
    w(3) =  0.137974910241879862433949246199;
    w(4) =  0.326515411108352185491692769217;
    w(5) =  0.547577467373226177976217604887;
    w(6) =  0.682278153375510121675529810121;
    w(7) =  0.614544746137780998436053880546;
    w(8) =  0.318231662453524478640851647411;

  elseif ( n == 9 )

    x(1) = -0.882491728426548422828684254270;
    x(2) = -0.694873684026474640346360850039;
    x(3) = -0.446537143480670863635920316400;
    x(4) = -0.159388112702326252531544826624;
    x(5) =  0.141092709224374414981503995427;
    x(6) =  0.428217823321559204544020866175;
    x(7) =  0.676480966471850715860378175342;
    x(8) =  0.863830940812464825046988286026;
    x(9) =  0.973668228805771018909618924364;

    w(1) =  0.00209009877215570354392734918986;
    w(2) =  0.0205951891648697848186537272448;
    w(3) =  0.0832489326348178964194106978875;
    w(4) =  0.210746247220398685903797568021;
    w(5) =  0.388325022916052063676224499399;
    w(6) =  0.554275165518437673725822282791;
    w(7) =  0.621388553284444032628761363828;
    w(8) =  0.523916296267173054255512857631;
    w(9) =  0.262081160888317771694556320674;

  else

    fprintf ( 1, '\n' );
    fprintf ( 1, 'LEGENDRE_SET_X2 - Fatal error!\n' );
    fprintf ( 1, '  Illegal input value of N = %d\n', n );
    error ( 'LEGENDRE_SET_X2 - Fatal error!' );

  end 

  return
end
