function [ x, w ] = legendre_set ( n )

%*****************************************************************************80
%
%% LEGENDRE_SET sets abscissas and weights for Gauss-Legendre quadrature.
%
%  Discussion:
%
%    The integral:
%
%      integral ( -1 <= x <= 1 ) f(x) dx
%
%    The quadrature rule:
%
%      sum ( 1 <= i <= n ) w(i) * f ( x(i) )
%
%    The quadrature rule is exact for polynomials through degree 2*N-1.
%
%    The abscissas are the zeroes of the Legendre polynomial P(N)(X).
%
%    Mathematica can compute the abscissas and weights of a Gauss-Legendre
%    rule of order N for the interval [A,B] with P digits of precision
%    by the commands:
%
%    Needs["NumericalDifferentialEquationAnalysis`"]
%    GaussianQuadratureWeights [ n, a, b, p ]
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    20 April 2010
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Milton Abramowitz, Irene Stegun,
%    Handbook of Mathematical Functions,
%    National Bureau of Standards, 1964,
%    ISBN: 0-486-61272-4,
%    LC: QA47.A34.
%
%    Vladimir Krylov,
%    Approximate Calculation of Integrals,
%    Dover, 2006,
%    ISBN: 0486445798,
%    LC: QA311.K713.
%
%    Arthur Stroud, Don Secrest,
%    Gaussian Quadrature Formulas,
%    Prentice Hall, 1966,
%    LC: QA299.4G3S7.
%
%    Stephen Wolfram,
%    The Mathematica Book,
%    Fourth Edition,
%    Cambridge University Press, 1999,
%    ISBN: 0-521-64314-7,
%    LC: QA76.95.W65.
%
%    Daniel Zwillinger, editor,
%    CRC Standard Mathematical Tables and Formulae,
%    30th Edition,
%    CRC Press, 1996,
%    ISBN: 0-8493-2479-3,
%    LC: QA47.M315.
%
%  Parameters:
%
%    Input, integer N, the order.
%    N must be between 1 and 10.
%
%    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.000000000000000000000000000000;

    w(1) = 2.000000000000000000000000000000;

  elseif ( n == 2 )

    x(1) = -0.577350269189625764509148780502;
    x(2) = 0.577350269189625764509148780502;

    w(1) = 1.000000000000000000000000000000;
    w(2) = 1.000000000000000000000000000000;

  elseif ( n == 3 )

    x(1) = -0.774596669241483377035853079956;
    x(2) = 0.000000000000000000000000000000;
    x(3) = 0.774596669241483377035853079956;

    w(1) = 0.555555555555555555555555555556;
    w(2) = 0.888888888888888888888888888889;
    w(3) = 0.555555555555555555555555555556;

  elseif ( n == 4 )

    x(1) = -0.861136311594052575223946488893;
    x(2) = -0.339981043584856264802665759103;
    x(3) = 0.339981043584856264802665759103;
    x(4) = 0.861136311594052575223946488893;

    w(1) = 0.347854845137453857373063949222;
    w(2) = 0.652145154862546142626936050778;
    w(3) = 0.652145154862546142626936050778;
    w(4) = 0.347854845137453857373063949222;

  elseif ( n == 5 )

    x(1) = -0.906179845938663992797626878299;
    x(2) = -0.538469310105683091036314420700;
    x(3) = 0.000000000000000000000000000000;
    x(4) = 0.538469310105683091036314420700;
    x(5) = 0.906179845938663992797626878299;

    w(1) = 0.236926885056189087514264040720;
    w(2) = 0.478628670499366468041291514836;
    w(3) = 0.568888888888888888888888888889;
    w(4) = 0.478628670499366468041291514836;
    w(5) = 0.236926885056189087514264040720;

  elseif ( n == 6 )

    x(1) = -0.932469514203152027812301554494;
    x(2) = -0.661209386466264513661399595020;
    x(3) = -0.238619186083196908630501721681;
    x(4) = 0.238619186083196908630501721681;
    x(5) = 0.661209386466264513661399595020;
    x(6) = 0.932469514203152027812301554494;

    w(1) = 0.171324492379170345040296142173;
    w(2) = 0.360761573048138607569833513838;
    w(3) = 0.467913934572691047389870343990;
    w(4) = 0.467913934572691047389870343990;
    w(5) = 0.360761573048138607569833513838;
    w(6) = 0.171324492379170345040296142173;

  elseif ( n == 7 )

    x(1) = -0.949107912342758524526189684048;
    x(2) = -0.741531185599394439863864773281;
    x(3) = -0.405845151377397166906606412077;
    x(4) = 0.000000000000000000000000000000;
    x(5) = 0.405845151377397166906606412077;
    x(6) = 0.741531185599394439863864773281;
    x(7) = 0.949107912342758524526189684048;

    w(1) = 0.129484966168869693270611432679;
    w(2) = 0.279705391489276667901467771424;
    w(3) = 0.381830050505118944950369775489;
    w(4) = 0.417959183673469387755102040816;
    w(5) = 0.381830050505118944950369775489;
    w(6) = 0.279705391489276667901467771424;
    w(7) = 0.129484966168869693270611432679;

  elseif ( n == 8 )

    x(1) = -0.960289856497536231683560868569;
    x(2) = -0.796666477413626739591553936476;
    x(3) = -0.525532409916328985817739049189;
    x(4) = -0.183434642495649804939476142360;
    x(5) = 0.183434642495649804939476142360;
    x(6) = 0.525532409916328985817739049189;
    x(7) = 0.796666477413626739591553936476;
    x(8) = 0.960289856497536231683560868569;

    w(1) = 0.101228536290376259152531354310;
    w(2) = 0.222381034453374470544355994426;
    w(3) = 0.313706645877887287337962201987;
    w(4) = 0.362683783378361982965150449277;
    w(5) = 0.362683783378361982965150449277;
    w(6) = 0.313706645877887287337962201987;
    w(7) = 0.222381034453374470544355994426;
    w(8) = 0.101228536290376259152531354310;

  elseif ( n == 9 )

    x(1) = -0.968160239507626089835576203;
    x(2) = -0.836031107326635794299429788;
    x(3) = -0.613371432700590397308702039;
    x(4) = -0.324253423403808929038538015;
    x(5) = 0.000000000000000000000000000;
    x(6) = 0.324253423403808929038538015;
    x(7) = 0.613371432700590397308702039;
    x(8) = 0.836031107326635794299429788;
    x(9) = 0.968160239507626089835576203;

    w(1) = 0.081274388361574411971892158111;
    w(2) = 0.18064816069485740405847203124;
    w(3) = 0.26061069640293546231874286942;
    w(4) = 0.31234707704000284006863040658;
    w(5) = 0.33023935500125976316452506929;
    w(6) = 0.31234707704000284006863040658;
    w(7) = 0.26061069640293546231874286942;
    w(8) = 0.18064816069485740405847203124;
    w(9) = 0.081274388361574411971892158111;

  elseif ( n == 10 )

    x(1) = -0.973906528517171720077964012;
    x(2) = -0.865063366688984510732096688;
    x(3) = -0.679409568299024406234327365;
    x(4) = -0.433395394129247190799265943;
    x(5) = -0.148874338981631210884826001;
    x(6) = 0.148874338981631210884826001;
    x(7) = 0.433395394129247190799265943;
    x(8) = 0.679409568299024406234327365;
    x(9) = 0.865063366688984510732096688;
    x(10) = 0.973906528517171720077964012;

    w(1) = 0.066671344308688137593568809893;
    w(2) = 0.14945134915058059314577633966;
    w(3) = 0.21908636251598204399553493423;
    w(4) = 0.26926671930999635509122692157;
    w(5) = 0.29552422471475287017389299465;
    w(6) = 0.29552422471475287017389299465;
    w(7) = 0.26926671930999635509122692157;
    w(8) = 0.21908636251598204399553493423;
    w(9) = 0.14945134915058059314577633966;
    w(10) = 0.066671344308688137593568809893;

  else

    fprintf ( 1, '\n' );
    fprintf ( 1, 'LEGENDRE_SET - Fatal error!\n' );
    fprintf ( 1, '  Illegal value of N.\n' );
    error ( 'LEGENDRE_SET - Fatal error!' );

  end

  return
end

