function [ x, w ] = hermite_gk18_set ( n )

%*****************************************************************************80
%
%% HERMITE_GK18_SET sets a Hermite Genz-Keister 18 rule.
%
%  Discussion:
%
%    The integral:
%
%      integral ( -oo <= x <= +oo ) f(x) exp ( - x * x ) dx
%
%    The quadrature rule:
%
%      sum ( 1 <= i <= n ) w(i) * f ( x(i) )
%
%    A nested family of rules for the Hermite integration problem
%    was produced by Genz and Keister.  The structure of the nested
%    family was denoted by 1+2+6+10+18, that is, it comprised rules 
%    of successive orders O = 1, 3, 9, 19, and 37.
%
%    The precisions of these rules are P = 1, 5, 15, 29, and 55.
%
%    Some of the data in this function was kindly supplied directly by
%    Alan Genz on 24 April 2011.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    30 April 2011
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Alan Genz, Bradley Keister,
%    Fully symmetric interpolatory rules for multiple integrals
%    over infinite regions with Gaussian weight,
%    Journal of Computational and Applied Mathematics,
%    Volume 71, 1996, pages 299-309
%
%    Florian Heiss, Viktor Winschel,
%    Likelihood approximation by numerical integration on sparse grids,
%    Journal of Econometrics,
%    Volume 144, 2008, pages 62-80.
%
%    Thomas Patterson,
%    The Optimal Addition of Points to Quadrature Formulae,
%    Mathematics of Computation,
%    Volume 22, Number 104, October 1968, pages 847-856.
%
%  Parameters:
%
%    Input, integer N, the order.
%    N must be 1, 3, 9, 19, or 37.
%
%    Output, real X(N,1), the abscissas.
%
%    Output, real W(N,1), the weights.
%
  x = zeros ( n, 1 );
  w = zeros ( n, 1 );

  if ( n == 1 )

    x( 1) =   0.0000000000000000E+00;

    w( 1) =   1.7724538509055159E+00;

  elseif ( n == 3 )

    x( 1) =  -1.2247448713915889E+00;
    x( 2) =   0.0000000000000000E+00;
    x( 3) =   1.2247448713915889E+00;

    w( 1) =   2.9540897515091930E-01;
    w( 2) =   1.1816359006036772E+00;
    w( 3) =   2.9540897515091930E-01;

  elseif ( n == 9 )

    x( 1) =  -2.9592107790638380E+00;
    x( 2) =  -2.0232301911005157E+00;
    x( 3) =  -1.2247448713915889E+00;
    x( 4) =  -5.2403354748695763E-01;
    x( 5) =   0.0000000000000000E+00;
    x( 6) =   5.2403354748695763E-01;
    x( 7) =   1.2247448713915889E+00;
    x( 8) =   2.0232301911005157E+00;
    x( 9) =   2.9592107790638380E+00;

    w( 1) =   1.6708826306882348E-04;
    w( 2) =   1.4173117873979098E-02;
    w( 3) =   1.6811892894767771E-01;
    w( 4) =   4.7869428549114124E-01;
    w( 5) =   4.5014700975378197E-01;
    w( 6) =   4.7869428549114124E-01;
    w( 7) =   1.6811892894767771E-01;
    w( 8) =   1.4173117873979098E-02;
    w( 9) =   1.6708826306882348E-04;

  elseif ( n == 19 )

    x( 1) =  -4.4995993983103881E+00;
    x( 2) =  -3.6677742159463378E+00;
    x( 3) =  -2.9592107790638380E+00;
    x( 4) =  -2.2665132620567876E+00;
    x( 5) =  -2.0232301911005157E+00;
    x( 6) =  -1.8357079751751868E+00;
    x( 7) =  -1.2247448713915889E+00;
    x( 8) =  -8.7004089535290285E-01;
    x( 9) =  -5.2403354748695763E-01;
    x(10) =   0.0000000000000000E+00;
    x(11) =   5.2403354748695763E-01;
    x(12) =   8.7004089535290285E-01;
    x(13) =   1.2247448713915889E+00;
    x(14) =   1.8357079751751868E+00;
    x(15) =   2.0232301911005157E+00;
    x(16) =   2.2665132620567876E+00;
    x(17) =   2.9592107790638380E+00;
    x(18) =   3.6677742159463378E+00;
    x(19) =   4.4995993983103881E+00;

    w( 1) =   1.5295717705322357E-09;
    w( 2) =   1.0802767206624762E-06;
    w( 3) =   1.0656589772852267E-04;
    w( 4) =   5.1133174390883855E-03;
    w( 5) =  -1.1232438489069229E-02;
    w( 6) =   3.2055243099445879E-02;
    w( 7) =   1.1360729895748269E-01;
    w( 8) =   1.0838861955003017E-01;
    w( 9) =   3.6924643368920851E-01;
    w(10) =   5.3788160700510168E-01;
    w(11) =   3.6924643368920851E-01;
    w(12) =   1.0838861955003017E-01;
    w(13) =   1.1360729895748269E-01;
    w(14) =   3.2055243099445879E-02;
    w(15) =  -1.1232438489069229E-02;
    w(16) =   5.1133174390883855E-03;
    w(17) =   1.0656589772852267E-04;
    w(18) =   1.0802767206624762E-06;
    w(19) =   1.5295717705322357E-09;

  elseif ( n == 37 )

    x( 1) =  -6.853200069757519;
    x( 2) =  -6.124527854622158;
    x( 3) =  -5.521865209868350;
    x( 4) =  -4.986551454150765;
    x( 5) =  -4.499599398310388;
    x( 6) =  -4.057956316089741;
    x( 7) =  -3.667774215946338;
    x( 8) =  -3.315584617593290;
    x( 9) =  -2.959210779063838;
    x(10) =  -2.597288631188366;
    x(11) =  -2.266513262056788;
    x(12) =  -2.023230191100516;
    x(13) =  -1.835707975175187;
    x(14) =  -1.561553427651873;
    x(15) =  -1.224744871391589;
    x(16) =  -0.870040895352903;
    x(17) =  -0.524033547486958;
    x(18) =  -0.214618180588171;
    x(19) =   0.000000000000000;
    x(20) =   0.214618180588171;
    x(21) =   0.524033547486958;
    x(22) =   0.870040895352903;
    x(23) =   1.224744871391589;
    x(24) =   1.561553427651873;
    x(25) =   1.835707975175187;
    x(26) =   2.023230191100516;
    x(27) =   2.266513262056788;
    x(28) =   2.597288631188366;
    x(29) =   2.959210779063838;
    x(30) =   3.315584617593290;
    x(31) =   3.667774215946338;
    x(32) =   4.057956316089741;
    x(33) =   4.499599398310388;
    x(34) =   4.986551454150765;
    x(35) =   5.521865209868350;
    x(36) =   6.124527854622158;
    x(37) =   6.853200069757519;

    w( 1) = 0.19030350940130498E-20;
    w( 2) = 0.187781893143728947E-16;
    w( 3) = 0.182242751549129356E-13;
    w( 4) = 0.45661763676186859E-11;
    w( 5) = 0.422525843963111041E-09;
    w( 6) = 0.16595448809389819E-07;
    w( 7) = 0.295907520230744049E-06;
    w( 8) = 0.330975870979203419E-05;
    w( 9) = 0.32265185983739747E-04;
    w(10) = 0.234940366465975222E-03;
    w(11) = 0.985827582996483824E-03;
    w(12) = 0.176802225818295443E-02;
    w(13) = 0.43334988122723492E-02;
    w(14) = 0.15513109874859354E-01;
    w(15) = 0.442116442189845444E-01;
    w(16) = 0.937208280655245902E-01;
    w(17) = 0.143099302896833389E+00;
    w(18) = 0.147655710402686249E+00;
    w(19) = 0.968824552928425499E-01;
    w(20) = 0.147655710402686249E+00;
    w(21) = 0.143099302896833389E+00;
    w(22) = 0.937208280655245902E-01;
    w(23) = 0.442116442189845444E-01;
    w(24) = 0.15513109874859354E-01;
    w(25) = 0.43334988122723492E-02;
    w(26) = 0.176802225818295443E-02;
    w(27) = 0.985827582996483824E-03;
    w(28) = 0.234940366465975222E-03;
    w(29) = 0.32265185983739747E-04;
    w(30) = 0.330975870979203419E-05;
    w(31) = 0.295907520230744049E-06;
    w(32) = 0.16595448809389819E-07;
    w(33) = 0.422525843963111041E-09;
    w(34) = 0.45661763676186859E-11;
    w(35) = 0.182242751549129356E-13;
    w(36) = 0.187781893143728947E-16;
    w(37) = 0.19030350940130498E-20;

  else

    fprintf ( 1, '\n' );
    fprintf ( 1, 'HERMITE_GK18_SET - Fatal error!\n' );
    fprintf ( 1, '  Illegal input value of N.\n' );
    fprintf ( 1, '  N must be 1, 3, 9, 19, or 37.\n' );
    error ( 'HERMITE_GK18_SET - Fatal error!' );

  end

  return
end
