function [ x, w ] = ncoh_set ( n )

%*****************************************************************************80
%
%% NCOH_SET sets abscissas and weights for Newton-Cotes "open half" quadrature.
%
%  Discussion:
%
%    The Newton-Cotes rules use equally spaced abscissas, and
%    hence may be used with equally spaced data.
%
%    The rules are called "open" because the abscissas do not include
%    the interval endpoints.
%
%    For this uncommon type of open Newton-Cotes rule, the abscissas for
%    rule N are found by dividing the interval into N equal subintervals,
%    and using the midpoint of each subinterval as the abscissa.
%
%    Most of the rules involve negative weights.  These can produce loss
%    of accuracy due to the subtraction of large, nearly equal quantities.
%
%    The integral:
%
%      Integral ( -1 <= X <= 1 ) F(X) dX
%
%    The quadrature rule:
%
%      Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
%
%    In Mathematica, the Newton-Cotes "open half" weights and abscissas
%    can be computed by the commands:
%
%      Needs["NumericalDifferentialEquationAnalysis`"]
%      NewtonCotesWeights [ n, -1, 1, QuadratureType -> Open ]
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    21 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.
%
%    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.
%    1 <= N <= 17.
%
%    Output, real X(N), the abscissas.
%
%    Output, real W(N), the weights.
%
  x = zeros ( n, 1 );
  w = zeros ( n, 1 );

  if ( n == 1 )

    w(1) = 2.0;

  elseif ( n == 2 )

    w(1) = 1.0;
    w(2) = 1.0;

  elseif ( n == 3 )

    d = 4.0;

    w(1) =   3.0 / d;
    w(2) =   2.0 / d;
    w(3) =   3.0 / d;

  elseif ( n == 4 )

    d = 24.0;

    w(1) = 13.0 / d;
    w(2) = 11.0 / d;
    w(3) = 11.0 / d;
    w(4) = 13.0 / d;

  elseif ( n == 5 )

    d = 576.0;

    w(1) =  275.0 / d;
    w(2) =  100.0 / d;
    w(3) =  402.0 / d;
    w(4) =  100.0 / d;
    w(5) =  275.0 / d;

  elseif ( n == 6 )

    d = 640.0;

    w(1) =   247.0 / d;
    w(2) =   139.0 / d;
    w(3) =   254.0 / d;
    w(4) =   254.0 / d;
    w(5) =   139.0 / d;
    w(6) =   247.0 / d;

  elseif ( n == 7 )

    d = 138240.0;

    w(1) =   49490.0 / d;
    w(2) =    1764.0 / d;
    w(3) =  112014.0 / d;
    w(4) =  -50056.0 / d;
    w(5) =  112014.0 / d;
    w(6) =    1764.0 / d;
    w(7) =   49490.0 / d;

  elseif ( n == 8 )

    d = 967680.0;

    w(1) =  295627.0 / d;
    w(2) =   71329.0 / d;
    w(3) =  471771.0 / d;
    w(4) =  128953.0 / d;
    w(5) =  128953.0 / d;
    w(6) =  471771.0 / d;
    w(7) =   71329.0 / d;
    w(8) =  295627.0 / d;

  elseif ( n == 9 )

    d = 2867200.0;

    w(1) =    832221.0 / d;
    w(2) =   -260808.0 / d;
    w(3) =   2903148.0 / d;
    w(4) =  -3227256.0 / d;
    w(5) =   5239790.0 / d;
    w(6) =  -3227256.0 / d;
    w(7) =   2903148.0 / d;
    w(8) =   -260808.0 / d;
    w(9) =    832221.0 / d;

  elseif ( n == 10 )

    d = 18579456.0;

    w(1) =    4751285.0 / d;
    w(2) =    -492755.0 / d;
    w(3) =   12269956.0 / d;
    w(4) =   -6274220.0 / d;
    w(5) =    8325190.0 / d;
    w(6) =    8325190.0 / d;
    w(7) =   -6274220.0 / d;
    w(8) =   12269956.0 / d;
    w(9) =    -492755.0 / d;
    w(10) =   4751285.0 / d;

  elseif ( n == 11 )

    w( 1) = + 0.246271364278193434009406231628;
    w( 2) = - 0.167027133984260177836566725456;
    w( 3) = + 1.27129728179339588844797178131;
    w( 4) = - 2.19004533609595458553791887125;
    w( 5) = + 3.91748917836991567460317460317;
    w( 6) = - 4.15597070872258046737213403880;
    w( 7) = + 3.91748917836991567460317460317;
    w( 8) = - 2.19004533609595458553791887125;
    w( 9) = + 1.27129728179339588844797178131;
    w(10) = - 0.167027133984260177836566725456;
    w(11) = + 0.246271364278193434009406231628;

  elseif ( n == 12 )

    w( 1) = + 0.221603210581329477813852813853;
    w( 2) = - 0.103156166902352205086580086580;
    w( 3) = + 0.889254983348763866341991341991;
    w( 4) = - 1.08160728355506797889610389610;
    w( 5) = + 1.49180546087620062229437229437;
    w( 6) = - 0.417900204348873782467532467532;
    w( 7) = - 0.417900204348873782467532467532;
    w( 8) = + 1.49180546087620062229437229437;
    w( 9) = - 1.08160728355506797889610389610; 
    w(10) = + 0.889254983348763866341991341991;
    w(11) = - 0.103156166902352205086580086580;
    w(12) = + 0.221603210581329477813852813853;

  elseif ( n == 13 )

    w(1) = 0.215232356419153566228270676022;
    w(2) = -0.227154289276070155983970468097;
    w(3) = 1.57154640756958579127322926926;
    w(4) = -3.60188931740556785445074962271;
    w(5) = 7.51615534838963020202557032914;
    w(6) = -10.7785343238762239297023523214;
    w(7) = 12.6092876363589847612200042756;
    w(8) = -10.7785343238762239297023523214;
    w(9) = 7.51615534838963020202557032914;
    w(10) = -3.60188931740556785445074962271;
    w(11) = 1.57154640756958579127322926926;
    w(12) = -0.227154289276070155983970468097;
    w(13) = 0.215232356419153566228270676022;

  elseif ( n == 14 )

    w(1) = 0.196600731862944474955289480752;
    w(2) = -0.165179242362168469504443173425;
    w(3) = 1.16085790162743923526801130968;
    w(4) = -2.14582271238684154514413484321;
    w(5) = 3.66584923423684682693019643251;
    w(6) = -3.34045051168652382743365816282;
    w(7) = 1.62814459870830330492873895652;
    w(8) = 1.62814459870830330492873895652;
    w(9) = -3.34045051168652382743365816282;
    w(10) = 3.66584923423684682693019643251;
    w(11) = -2.14582271238684154514413484321;
    w(12) = 1.16085790162743923526801130968;
    w(13) = -0.165179242362168469504443173425;
    w(14) = 0.196600731862944474955289480752;

  elseif ( n == 15 )

    w(1) = 0.192053656112251156523443074782;
    w(2) = -0.277042941258250537556131864168;
    w(3) = 1.90509434600895135399617123947;
    w(4) = -5.39701622989083452471078029114;
    w(5) = 13.1085281753546466152623727959;
    w(6) = -23.3466945206436771323681898459;
    w(7) = 33.4478422682091702199516443378;
    w(8) = -37.2655295077845143021970588935;
    w(9) = 33.4478422682091702199516443378;
    w(10) = -23.3466945206436771323681898459;
    w(11) = 13.1085281753546466152623727959;
    w(12) = -5.39701622989083452471078029114;
    w(13) = 1.90509434600895135399617123947;
    w(14) = -0.277042941258250537556131864168;
    w(15) = 0.192053656112251156523443074782;

  elseif ( n == 16 )

    w(1) = 0.177408479879589716830780293564;
    w(2) = -0.217359399771056183974705378131;
    w(3) = 1.46740967914595726066296033468;
    w(4) = -3.56820982596198712548876407280;
    w(5) = 7.42429624597447227175662173974;
    w(6) = -10.1614344802943189309930887295;
    w(7) = 9.74825566269696996625640284529;
    w(8) = -3.87036636166962697505020703289;
    w(9) = -3.87036636166962697505020703289;
    w(10) = 9.74825566269696996625640284529;
    w(11) = -10.1614344802943189309930887295;
    w(12) = 7.42429624597447227175662173974;
    w(13) = -3.56820982596198712548876407280;
    w(14) = 1.46740967914595726066296033468;
    w(15) = -0.217359399771056183974705378131;
    w(16) = 0.177408479879589716830780293564;

  elseif ( n == 17 )

    w(1) = 0.174021728363203743659784786159;
    w(2) = -0.319844636797863622878597303396;
    w(3) = 2.26685253417620917889510925819;
    w(4) = -7.60565246092744264614795072379;
    w(5) = 21.2205863313196208783745036601;
    w(6) = -44.9326914054546061828308816595;
    w(7) = 76.6598740687724224896458863733;
    w(8) = -104.621704713086021393464459433;
    w(9) = 116.317117107268955109493210084;
    w(10) = -104.621704713086021393464459433;
    w(11) = 76.6598740687724224896458863733;
    w(12) = -44.9326914054546061828308816595;
    w(13) = 21.2205863313196208783745036601;
    w(14) = -7.60565246092744264614795072379;
    w(15) = 2.26685253417620917889510925819;
    w(16) = -0.319844636797863622878597303396;
    w(17) = 0.174021728363203743659784786159;

  else

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

  end
%
%  Set the abscissas.
%
  a = -1.0;
  b = +1.0;

  for i = 1 : n
    x(i) = ( ( 2 * n - 2 * i + 1 ) * a   ...
           + (         2 * i - 1 ) * b ) ...
           / ( 2 * n             );
  end

  return
end
