function [ x, w ] = fejer2_set ( n )

%*****************************************************************************80
%
%% FEJER2_SET sets abscissas and weights for Fejer type 2 quadrature.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    03 March 2007
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Philip Davis, Philip Rabinowitz,
%    Methods of Numerical Integration,
%    Second Edition,
%    Dover, 2007,
%    ISBN: 0486453391,
%    LC: QA299.3.D28.
%
%    Walter Gautschi,
%    Numerical Quadrature in the Presence of a Singularity,
%    SIAM Journal on Numerical Analysis,
%    Volume 4, Number 3, 1967, pages 357-362.
%
%    Joerg Waldvogel,
%    Fast Construction of the Fejer and Clenshaw-Curtis Quadrature Rules,
%    BIT Numerical Mathematics,
%    Volume 43, Number 1, 2003, pages 1-18.
%
%  Parameters:
%
%    Input, integer N, the order.  
%    N should 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.000000000000000;
    w(1) =  2.000000000000000;

  elseif ( n == 2 )

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

    w(1) =  1.0000000000000000;
    w(2) =  1.0000000000000000;

  elseif ( n == 3 )

    x( 1) =  -0.7071067811865476;
    x( 2) =   0.0000000000000000;
    x( 3) =   0.7071067811865476;

    w(1) =  0.6666666666666666;
    w(2) =  0.6666666666666666;
    w(3) =  0.6666666666666666;

  elseif ( n == 4 )

    x( 1) =  -0.8090169943749475;
    x( 2) =  -0.3090169943749475;
    x( 3) =   0.3090169943749475;
    x( 4) =   0.8090169943749475;

    w( 1) = 0.4254644007500070;
    w( 2) = 0.5745355992499930;
    w( 3) = 0.5745355992499930;
    w( 4) = 0.4254644007500070;

  elseif ( n == 5 )

    x( 1) =  -0.8660254037844387;
    x( 2) =  -0.5000000000000000;
    x( 3) =   0.0000000000000000;
    x( 4) =   0.5000000000000000;
    x( 5) =   0.8660254037844387;

    w( 1) = 0.3111111111111111;
    w( 2) = 0.4000000000000000;
    w( 3) = 0.5777777777777777;
    w( 4) = 0.4000000000000000;
    w( 5) = 0.3111111111111111;

  elseif ( n == 6 )

    x( 1) =  -0.9009688679024191;
    x( 2) =  -0.6234898018587336;
    x( 3) =  -0.2225209339563144;
    x( 4) =   0.2225209339563144;
    x( 5) =   0.6234898018587336;
    x( 6) =   0.9009688679024191;

    w( 1) = 0.2269152467244296;
    w( 2) = 0.3267938603769863;
    w( 3) = 0.4462908928985841;
    w( 4) = 0.4462908928985841;
    w( 5) = 0.3267938603769863;
    w( 6) = 0.2269152467244296;

  elseif ( n == 7 )

    x( 1) =  -0.9238795325112867;
    x( 2) =  -0.7071067811865476;
    x( 3) =  -0.3826834323650898;
    x( 4) =   0.0000000000000000;
    x( 5) =   0.3826834323650898;
    x( 6) =   0.7071067811865476;
    x( 7) =   0.9238795325112867;

    w( 1) = 0.1779646809620499;
    w( 2) = 0.2476190476190476;
    w( 3) = 0.3934638904665215;
    w( 4) = 0.3619047619047619;
    w( 5) = 0.3934638904665215;
    w( 6) = 0.2476190476190476;
    w( 7) = 0.1779646809620499;

  elseif ( n == 8 )

    x( 1) =  -0.9396926207859084;
    x( 2) =  -0.7660444431189780;
    x( 3) =  -0.5000000000000000;
    x( 4) =  -0.1736481776669304;
    x( 5) =   0.1736481776669304;
    x( 6) =   0.5000000000000000;
    x( 7) =   0.7660444431189780;
    x( 8) =   0.9396926207859084;

    w( 1) = 0.1397697435050225;
    w( 2) = 0.2063696457302284;
    w( 3) = 0.3142857142857143;
    w( 4) = 0.3395748964790348;
    w( 5) = 0.3395748964790348;
    w( 6) = 0.3142857142857143;
    w( 7) = 0.2063696457302284;
    w( 8) = 0.1397697435050225;

  elseif ( n == 9 )

    x( 1) =  -0.9510565162951535;
    x( 2) =  -0.8090169943749475;
    x( 3) =  -0.5877852522924731;
    x( 4) =  -0.3090169943749475;
    x( 5) =   0.0000000000000000;
    x( 6) =   0.3090169943749475;
    x( 7) =   0.5877852522924731;
    x( 8) =   0.8090169943749475;
    x( 9) =   0.9510565162951535;

    w( 1) = 0.1147810750857217;
    w( 2) = 0.1654331942222276;
    w( 3) = 0.2737903534857068;
    w( 4) = 0.2790112502222170;
    w( 5) = 0.3339682539682539;
    w( 6) = 0.2790112502222170;
    w( 7) = 0.2737903534857068;
    w( 8) = 0.1654331942222276;
    w( 9) = 0.1147810750857217;

  elseif ( n == 10 )

    x( 1) =  -0.9594929736144974;
    x( 2) =  -0.8412535328311812;
    x( 3) =  -0.6548607339452851;
    x( 4) =  -0.4154150130018864;
    x( 5) =  -0.1423148382732851;
    x( 6) =   0.1423148382732851;
    x( 7) =   0.4154150130018864;
    x( 8) =   0.6548607339452851;
    x( 9) =   0.8412535328311812;
    x(10) =   0.9594929736144974;

    w( 1) = 0.09441954173982806;
    w( 2) = 0.1411354380109716;
    w( 3) = 0.2263866903636005;
    w( 4) = 0.2530509772156453;
    w( 5) = 0.2850073526699544;
    w( 6) = 0.2850073526699544;
    w( 7) = 0.2530509772156453;
    w( 8) = 0.2263866903636005;
    w( 9) = 0.1411354380109716;
    w(10) = 0.09441954173982806;

  else

    fprintf ( 1, '\n' );
    fprintf ( 1, 'FEJER2_SET - Fatal error!\n' );
    fprintf ( 1,'  Illegal value of N = %d\n', n );
    fprintf ( 1, '  Legal values are 1 through 10.\n' );
    error ( 'FEJER2_SET - Fatal error!' );

  end

  return
end
