function [ x, w ] = kronrod_set ( n )

%*****************************************************************************80
%
%% KRONROD_SET sets abscissas and weights for Gauss-Kronrod quadrature.
%
%  Discussion:
%
%    The integral:
%
%      Integral ( -1 <= X <= 1 ) F(X) dX
%
%    The quadrature rule:
%
%      Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
%
%    A Kronrod rule is used in conjunction with a lower order
%    Gauss rule, and provides an efficient error estimation.
%
%    The error may be estimated as the difference in the two integral
%    approximations.
%
%    The efficiency comes about because the Kronrod uses the abscissas
%    of the Gauss rule, thus saving on the number of function evaluations
%    necessary.  If the Kronrod rule were replaced by a Gauss rule of
%    the same order, a higher precision integral estimate would be
%    made, but the function would have to be evaluated at many more
%    points.
%
%    The Gauss Kronrod pair of rules involves an ( N + 1 ) / 2
%    point Gauss-Legendre rule and an N point Kronrod rule.
%    Thus, the 15 point Kronrod rule should be paired with the
%    Gauss-Legendre 7 point rule.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    12 October 2005
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    R Piessens, E de Doncker-Kapenger, C Ueberhuber, D Kahaner,
%    QUADPACK, A Subroutine Package for Automatic Integration,
%    Springer Verlag, 1983.
%
%  Parameters:
%
%    Input, integer N, the order.
%    N may be 15, 21, 31 or 41, corresponding to Gauss-Legendre rules of
%    order 7, 10, 15 or 20.
%
%    Output, real X(N), the abscissas.
%
%    Output, real W(N), the weights.
%
  x = zeros ( n, 1 );
  w = zeros ( n, 1 );

  if ( n == 15 )

    x(1) =  - 0.9914553711208126;
    x(2) =  - 0.9491079123427585;
    x(3) =  - 0.8648644233597691;
    x(4) =  - 0.7415311855993944;
    x(5) =  - 0.5860872354676911;
    x(6) =  - 0.4058451513773972;
    x(7) =  - 0.2077849550789850;
    x(8) =    0.0;
    x(9) =    0.2077849550789850;
    x(10) =   0.4058451513773972;
    x(11) =   0.5860872354676911;
    x(12) =   0.7415311855993944;
    x(13) =   0.8648644233597691;
    x(14) =   0.9491079123427585;
    x(15) =   0.9914553711208126;

    w(1) =  0.2293532201052922E-01;
    w(2) =  0.6309209262997855E-01;
    w(3) =  0.1047900103222502;
    w(4) =  0.1406532597155259;
    w(5) =  0.1690047266392679;
    w(6) =  0.1903505780647854;
    w(7) =  0.2044329400752989;
    w(8) =  0.2094821410847278;
    w(9) =  0.2044329400752989;
    w(10) = 0.1903505780647854;
    w(11) = 0.1690047266392679;
    w(12) = 0.1406532597155259;
    w(13) = 0.1047900103222502;
    w(14) = 0.6309209262997855E-01;
    w(15) = 0.2293532201052922E-01;

  elseif ( n == 21 )

    x(1) =  - 0.9956571630258081;
    x(2) =  - 0.9739065285171717;
    x(3) =  - 0.9301574913557082;
    x(4) =  - 0.8650633666889845;
    x(5) =  - 0.7808177265864169;
    x(6) =  - 0.6794095682990244;
    x(7) =  - 0.5627571346686047;
    x(8) =  - 0.4333953941292472;
    x(9) =  - 0.2943928627014602;
    x(10) = - 0.1488743389816312;
    x(11) =   0.0;
    x(12) =   0.1488743389816312;
    x(13) =   0.2943928627014602;
    x(14) =   0.4333953941292472;
    x(15) =   0.5627571346686047;
    x(16) =   0.6794095682990244;
    x(17) =   0.7808177265864169;
    x(18) =   0.8650633666889845;
    x(19) =   0.9301574913557082;
    x(20) =   0.9739065285171717;
    x(21) =   0.9956571630258081;

    w(1) =  0.1169463886737187E-01;
    w(2) =  0.3255816230796473E-01;
    w(3) =  0.5475589657435200E-01;
    w(4) =  0.7503967481091995E-01;
    w(5) =  0.9312545458369761E-01;
    w(6) =  0.1093871588022976;
    w(7) =  0.1234919762620659;
    w(8) =  0.1347092173114733;
    w(9) =  0.1427759385770601;
    w(10) = 0.1477391049013385;
    w(11) = 0.1494455540029169;
    w(12) = 0.1477391049013385;
    w(13) = 0.1427759385770601;
    w(14) = 0.1347092173114733;
    w(15) = 0.1234919762620659;
    w(16) = 0.1093871588022976;
    w(17) = 0.9312545458369761E-01;
    w(18) = 0.7503967481091995E-01;
    w(19) = 0.5475589657435200E-01;
    w(20) = 0.3255816230796473E-01;
    w(21) = 0.1169463886737187E-01;

  elseif ( n == 31 )

    x(1) =  - 0.9980022986933971;
    x(2) =  - 0.9879925180204854;
    x(3) =  - 0.9677390756791391;
    x(4) =  - 0.9372733924007059;
    x(5) =  - 0.8972645323440819;
    x(6) =  - 0.8482065834104272;
    x(7) =  - 0.7904185014424659;
    x(8) =  - 0.7244177313601700;
    x(9) =  - 0.6509967412974170;
    x(10) = - 0.5709721726085388;
    x(11) = - 0.4850818636402397;
    x(12) = - 0.3941513470775634;
    x(13) = - 0.2991800071531688;
    x(14) = - 0.2011940939974345;
    x(15) = - 0.1011420669187175;
    x(16) =   0.0;
    x(17) =   0.1011420669187175;
    x(18) =   0.2011940939974345;
    x(19) =   0.2991800071531688;
    x(20) =   0.3941513470775634;
    x(21) =   0.4850818636402397;
    x(22) =   0.5709721726085388;
    x(23) =   0.6509967412974170;
    x(24) =   0.7244177313601700;
    x(25) =   0.7904185014424659;
    x(26) =   0.8482065834104272;
    x(27) =   0.8972645323440819;
    x(28) =   0.9372733924007059;
    x(29) =   0.9677390756791391;
    x(30) =   0.9879925180204854;
    x(31) =   0.9980022986933971;

    w(1) =  0.5377479872923349E-02;
    w(2) =  0.1500794732931612E-01;
    w(3) =  0.2546084732671532E-01;
    w(4) =  0.3534636079137585E-01;
    w(5) =  0.4458975132476488E-01;
    w(6) =  0.5348152469092809E-01;
    w(7) =  0.6200956780067064E-01;
    w(8) =  0.6985412131872826E-01;
    w(9) =  0.7684968075772038E-01;
    w(10) = 0.8308050282313302E-01;
    w(11) = 0.8856444305621177E-01;
    w(12) = 0.9312659817082532E-01;
    w(13) = 0.9664272698362368E-01;
    w(14) = 0.9917359872179196E-01;
    w(15) = 0.1007698455238756;
    w(16) = 0.1013300070147915;
    w(17) = 0.1007698455238756;
    w(18) = 0.9917359872179196E-01;
    w(19) = 0.9664272698362368E-01;
    w(20) = 0.9312659817082532E-01;
    w(21) = 0.8856444305621177E-01;
    w(22) = 0.8308050282313302E-01;
    w(23) = 0.7684968075772038E-01;
    w(24) = 0.6985412131872826E-01;
    w(25) = 0.6200956780067064E-01;
    w(26) = 0.5348152469092809E-01;
    w(27) = 0.4458975132476488E-01;
    w(28) = 0.3534636079137585E-01;
    w(29) = 0.2546084732671532E-01;
    w(30) = 0.1500794732931612E-01;
    w(31) = 0.5377479872923349E-02;

  elseif ( n == 41 )

    x(1) =  - 0.9988590315882777;
    x(2) =  - 0.9931285991850949;
    x(3) =  - 0.9815078774502503;
    x(4) =  - 0.9639719272779138;
    x(5) =  - 0.9408226338317548;
    x(6) =  - 0.9122344282513259;
    x(7) =  - 0.8782768112522820;
    x(8) =  - 0.8391169718222188;
    x(9) =  - 0.7950414288375512;
    x(10) = - 0.7463319064601508;
    x(11) = - 0.6932376563347514;
    x(12) = - 0.6360536807265150;
    x(13) = - 0.5751404468197103;
    x(14) = - 0.5108670019508271;
    x(15) = - 0.4435931752387251;
    x(16) = - 0.3737060887154196;
    x(17) = - 0.3016278681149130;
    x(18) = - 0.2277858511416451;
    x(19) = - 0.1526054652409227;
    x(20) = - 0.7652652113349733E-01;
    x(21) =   0.0;
    x(22) =   0.7652652113349733E-01;
    x(23) =   0.1526054652409227;
    x(24) =   0.2277858511416451;
    x(25) =   0.3016278681149130;
    x(26) =   0.3737060887154196;
    x(27) =   0.4435931752387251;
    x(28) =   0.5108670019508271;
    x(29) =   0.5751404468197103;
    x(30) =   0.6360536807265150;
    x(31) =   0.6932376563347514;
    x(32) =   0.7463319064601508;
    x(33) =   0.7950414288375512;
    x(34) =   0.8391169718222188;
    x(35) =   0.8782768112522820;
    x(36) =   0.9122344282513259;
    x(37) =   0.9408226338317548;
    x(38) =   0.9639719272779138;
    x(39) =   0.9815078774502503;
    x(40) =   0.9931285991850949;
    x(41) =   0.9988590315882777;

    w(1) =  0.3073583718520532E-02;
    w(2) =  0.8600269855642942E-02;
    w(3) =  0.1462616925697125E-01;
    w(4) =  0.2038837346126652E-01;
    w(5) =  0.2588213360495116E-01;
    w(6) =  0.3128730677703280E-01;
    w(7) =  0.3660016975820080E-01;
    w(8) =  0.4166887332797369E-01;
    w(9) =  0.4643482186749767E-01;
    w(10) = 0.5094457392372869E-01;
    w(11) = 0.5519510534828599E-01;
    w(12) = 0.5911140088063957E-01;
    w(13) = 0.6265323755478117E-01;
    w(14) = 0.6583459713361842E-01;
    w(15) = 0.6864867292852162E-01;
    w(16) = 0.7105442355344407E-01;
    w(17) = 0.7303069033278667E-01;
    w(18) = 0.7458287540049919E-01;
    w(19) = 0.7570449768455667E-01;
    w(20) = 0.7637786767208074E-01;
    w(21) = 0.7660071191799966E-01;
    w(22) = 0.7637786767208074E-01;
    w(23) = 0.7570449768455667E-01;
    w(24) = 0.7458287540049919E-01;
    w(25) = 0.7303069033278667E-01;
    w(26) = 0.7105442355344407E-01;
    w(27) = 0.6864867292852162E-01;
    w(28) = 0.6583459713361842E-01;
    w(29) = 0.6265323755478117E-01;
    w(30) = 0.5911140088063957E-01;
    w(31) = 0.5519510534828599E-01;
    w(32) = 0.5094457392372869E-01;
    w(33) = 0.4643482186749767E-01;
    w(34) = 0.4166887332797369E-01;
    w(35) = 0.3660016975820080E-01;
    w(36) = 0.3128730677703280E-01;
    w(37) = 0.2588213360495116E-01;
    w(38) = 0.2038837346126652E-01;
    w(39) = 0.1462616925697125E-01;
    w(40) = 0.8600269855642942E-02;
    w(41) = 0.3073583718520532E-02;

  else

    fprintf ( 1, '\n' );
    fprintf ( 1, 'KRONROD_SET - Fatal error!\n' );
    fprintf ( 1, '  Illegal value of N = %d\n', n );
    fprintf ( 1, '  Legal values are 15, 21, 31 or 41.\n' );
    error ( 'KRONROD_SET - Fatal error!' );

  end 

  return
end
