function [ x, w ] = legendre_set_cos2 ( n )

%*****************************************************************************80
%
%% LEGENDRE_SET_COS2 sets a Gauss-Legendre rule for COS(X) * F(X) on [0,PI/2].
%
%  Discussion:
%%
%    The integral:
%
%      Integral ( 0 <= X <= PI/2 ) COS(X) * F(X) dX
%
%    The quadrature rule:
%
%      Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
%
%    The integral:
%
%      Integral ( 0 <= X <= PI/2 ) SIN(X) * F(X) dX
%
%    The quadrature rule:
%
%      Sum ( 1 <= I <= N ) W(I) * F ( PI/2 - X(I) )
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    13 October 2005
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Gwynne Evans,
%    Practical Numerical Integration,
%    Wiley, 1993, QA299.3E93, page 311.
%
%  Parameters:
%
%    Input, integer N, the order.
%    N must be between 2, 4, 8 or 16.
%
%    Output, real X(N), the abscissas.
%
%    Output, real W(N), the weights.
%
  x = zeros ( n, 1 );
  w = zeros ( n, 1 );

  if ( n == 2 )

    x(1) = 0.26587388056307823382;
    x(2) = 1.0351526093171315182;

    w(1) = 0.60362553280827113087;
    w(2) = 0.39637446719172886913;

  elseif ( n == 4 )

    x(1) = 0.095669389196858636773;
    x(2) = 0.45240902327067096554;
    x(3) = 0.93185057672024082424;
    x(4) = 1.3564439599666466230;

    w( 1) = 0.23783071419515504517;
    w( 2) = 0.40265695523581253512;
    w( 3) = 0.28681737948564715225;
    w( 4) = 0.072694951083385267446;

  elseif ( n == 8 )

    x(1) = 0.029023729768913933432;
    x(2) = 0.14828524404581819442;
    x(3) = 0.34531111151664787488;
    x(4) = 0.59447696797658360178;
    x(5) = 0.86538380686123504827;
    x(6) = 1.1263076093187456632;
    x(7) = 1.3470150460281258016;
    x(8) = 1.5015603622059195568;

    w( 1) = 0.073908998095117384985;
    w( 2) = 0.16002993702338006099;
    w( 3) = 0.21444434341803549108;
    w( 4) = 0.21979581268851903339;
    w( 5) = 0.17581164478209568886;
    w( 6) = 0.10560448025308322171;
    w( 7) = 0.042485497299217201089;
    w( 8) = 0.0079192864405519178899;

  elseif ( n == 16 )

    x( 1) = 0.0080145034906295973494;
    x( 2) = 0.041893031354246254797;
    x( 3) = 0.10149954486757579459;
    x( 4) = 0.18463185923836617507;
    x( 5) = 0.28826388487760574589;
    x( 6) = 0.40870579076464794191;
    x( 7) = 0.54176054986913847463;
    x( 8) = 0.68287636658719416893;
    x( 9) = 0.82729287620416833520;
    x(10) = 0.97018212594829367065;
    x(11) = 1.1067865150286247873;
    x(12) = 1.2325555697227748824;
    x(13) = 1.3432821921580721861;
    x(14) = 1.4352370549295032923;
    x(15) = 1.5052970876794669248;
    x(16) = 1.5510586944086135769;

    w( 1) = 0.020528714977215248902;
    w( 2) = 0.046990919853597958123;
    w( 3) = 0.071441021312218541698;
    w( 4) = 0.092350338329243052271;
    w( 5) = 0.10804928026816236935;
    w( 6) = 0.11698241243306261791;
    w( 7) = 0.11812395361762037649;
    w( 8) = 0.11137584940420091049;
    w( 9) = 0.097778236145946543110;
    w(10) = 0.079418758985944482077;
    w(11) = 0.059039620053768691402;
    w(12) = 0.039458876783728165671;
    w(13) = 0.022987785677206847531;
    w(14) = 0.011010405600421536861;
    w(15) = 0.0038123928030499915653;
    w(16) = 0.00065143375461266656171;

  else

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

  end

  return
end
