function value = gp_abscissa ( order, i )

%*****************************************************************************80
%
%% GP_ABSCISSA returns the I-th abscissa for a Gauss-Patterson rule.
%
%  Discussion:
%
%    The rule is specified by its order.
%
%    The number of points in the rule, known as the order, is
%    related to the level by the formula:
%
%      ORDER = 2^(LEVEL+1)-1.
%
%    Only rules of order 1, 3, 7, 15, 31, 63, 127 and 255 are allowed.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 December 2009
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Prem Kythe, Michael Schaeferkotter,
%    Handbook of Computational Methods for Integration,
%    Chapman and Hall, 2004,
%    ISBN: 1-58488-428-2,
%    LC: QA299.3.K98.
%
%    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 ORDER, the order of the rule.
%    ORDER must be 1, 3, 7, 15, 31, 63, 127 and 255.
%
%    Input, integer I, the index of the point in the rule.
%
%    Output, real VALUE, the value of the I-th
%    abscissa in the rule of level LEVEL and order ORDER.
%
  order_pointer = [ 0, 1, 4, 11, 26, 57, 120, 247 ];

  xtab = [ ...
     0.0, ...
    -0.77459666924148337704, ...
     0.0, ...
     0.77459666924148337704, ...
    -0.96049126870802028342, ...
    -0.77459666924148337704, ...
    -0.43424374934680255800, ...
     0.0, ...
     0.43424374934680255800, ...
     0.77459666924148337704, ...
     0.96049126870802028342, ...
    -0.99383196321275502221, ...
    -0.96049126870802028342, ...
    -0.88845923287225699889, ...
    -0.77459666924148337704, ...
    -0.62110294673722640294, ...
    -0.43424374934680255800, ...
    -0.22338668642896688163, ...
     0.0, ...
     0.22338668642896688163, ...
     0.43424374934680255800, ...
     0.62110294673722640294, ...
     0.77459666924148337704, ...
     0.88845923287225699889, ...
     0.96049126870802028342, ...
     0.99383196321275502221, ...
    -0.99909812496766759766, ...
    -0.99383196321275502221, ...
    -0.98153114955374010687, ...
    -0.96049126870802028342, ...
    -0.92965485742974005667, ...
    -0.88845923287225699889, ...
    -0.83672593816886873550, ...
    -0.77459666924148337704, ...
    -0.70249620649152707861, ...
    -0.62110294673722640294, ...
    -0.53131974364437562397, ...
    -0.43424374934680255800, ...
    -0.33113539325797683309, ...
    -0.22338668642896688163, ...
    -0.11248894313318662575, ...
     0.0, ...
     0.11248894313318662575, ...
     0.22338668642896688163, ...
     0.33113539325797683309, ...
     0.43424374934680255800, ...
     0.53131974364437562397, ...
     0.62110294673722640294, ...
     0.70249620649152707861, ...
     0.77459666924148337704, ...
     0.83672593816886873550, ...
     0.88845923287225699889, ...
     0.92965485742974005667, ...
     0.96049126870802028342, ...
     0.98153114955374010687, ...
     0.99383196321275502221, ...
     0.99909812496766759766, ...
    -0.99987288812035761194, ...
    -0.99909812496766759766, ...
    -0.99720625937222195908, ...
    -0.99383196321275502221, ...
    -0.98868475754742947994, ...
    -0.98153114955374010687, ...
    -0.97218287474858179658, ...
    -0.96049126870802028342, ...
    -0.94634285837340290515, ...
    -0.92965485742974005667, ...
    -0.91037115695700429250, ...
    -0.88845923287225699889, ...
    -0.86390793819369047715, ...
    -0.83672593816886873550, ...
    -0.80694053195021761186, ...
    -0.77459666924148337704, ...
    -0.73975604435269475868, ...
    -0.70249620649152707861, ...
    -0.66290966002478059546, ...
    -0.62110294673722640294, ...
    -0.57719571005204581484, ...
    -0.53131974364437562397, ...
    -0.48361802694584102756, ...
    -0.43424374934680255800, ...
    -0.38335932419873034692, ...
    -0.33113539325797683309, ...
    -0.27774982202182431507, ...
    -0.22338668642896688163, ...
    -0.16823525155220746498, ...
    -0.11248894313318662575, ...
    -0.056344313046592789972, ...
     0.0, ...
     0.056344313046592789972, ...
     0.11248894313318662575, ...
     0.16823525155220746498, ...
     0.22338668642896688163, ...
     0.27774982202182431507, ...
     0.33113539325797683309, ...
     0.38335932419873034692, ...
     0.43424374934680255800, ...
     0.48361802694584102756, ...
     0.53131974364437562397, ...
     0.57719571005204581484, ...
     0.62110294673722640294, ...
     0.66290966002478059546, ...
     0.70249620649152707861, ...
     0.73975604435269475868, ...
     0.77459666924148337704, ...
     0.80694053195021761186, ...
     0.83672593816886873550, ...
     0.86390793819369047715, ...
     0.88845923287225699889, ...
     0.91037115695700429250, ...
     0.92965485742974005667, ...
     0.94634285837340290515, ...
     0.96049126870802028342, ...
     0.97218287474858179658, ...
     0.98153114955374010687, ...
     0.98868475754742947994, ...
     0.99383196321275502221, ...
     0.99720625937222195908, ...
     0.99909812496766759766, ...
     0.99987288812035761194, ...
    -0.99998243035489159858, ...
    -0.99987288812035761194, ...
    -0.99959879967191068325, ...
    -0.99909812496766759766, ...
    -0.99831663531840739253, ...
    -0.99720625937222195908, ...
    -0.99572410469840718851, ...
    -0.99383196321275502221, ...
    -0.99149572117810613240, ...
    -0.98868475754742947994, ...
    -0.98537149959852037111, ...
    -0.98153114955374010687, ...
    -0.97714151463970571416, ...
    -0.97218287474858179658, ...
    -0.96663785155841656709, ...
    -0.96049126870802028342, ...
    -0.95373000642576113641, ...
    -0.94634285837340290515, ...
    -0.93832039777959288365, ...
    -0.92965485742974005667, ...
    -0.92034002547001242073, ...
    -0.91037115695700429250, ...
    -0.89974489977694003664, ...
    -0.88845923287225699889, ...
    -0.87651341448470526974, ...
    -0.86390793819369047715, ...
    -0.85064449476835027976, ...
    -0.83672593816886873550, ...
    -0.82215625436498040737, ...
    -0.80694053195021761186, ...
    -0.79108493379984836143, ...
    -0.77459666924148337704, ...
    -0.75748396638051363793, ...
    -0.73975604435269475868, ...
    -0.72142308537009891548, ...
    -0.70249620649152707861, ...
    -0.68298743109107922809, ...
    -0.66290966002478059546, ...
    -0.64227664250975951377, ...
    -0.62110294673722640294, ...
    -0.59940393024224289297, ...
    -0.57719571005204581484, ...
    -0.55449513263193254887, ...
    -0.53131974364437562397, ...
    -0.50768775753371660215, ...
    -0.48361802694584102756, ...
    -0.45913001198983233287, ...
    -0.43424374934680255800, ...
    -0.40897982122988867241, ...
    -0.38335932419873034692, ...
    -0.35740383783153215238, ...
    -0.33113539325797683309, ...
    -0.30457644155671404334, ...
    -0.27774982202182431507, ...
    -0.25067873030348317661, ...
    -0.22338668642896688163, ...
    -0.19589750271110015392, ...
    -0.16823525155220746498, ...
    -0.14042423315256017459, ...
    -0.11248894313318662575, ...
    -0.084454040083710883710, ...
    -0.056344313046592789972, ...
    -0.028184648949745694339, ...
     0.0, ...
     0.028184648949745694339, ...
     0.056344313046592789972, ...
     0.084454040083710883710, ...
     0.11248894313318662575, ...
     0.14042423315256017459, ...
     0.16823525155220746498, ...
     0.19589750271110015392, ...
     0.22338668642896688163, ...
     0.25067873030348317661, ...
     0.27774982202182431507, ...
     0.30457644155671404334, ...
     0.33113539325797683309, ...
     0.35740383783153215238, ...
     0.38335932419873034692, ...
     0.40897982122988867241, ...
     0.43424374934680255800, ...
     0.45913001198983233287, ...
     0.48361802694584102756, ...
     0.50768775753371660215, ...
     0.53131974364437562397, ...
     0.55449513263193254887, ...
     0.57719571005204581484, ...
     0.59940393024224289297, ...
     0.62110294673722640294, ...
     0.64227664250975951377, ...
     0.66290966002478059546, ...
     0.68298743109107922809, ...
     0.70249620649152707861, ...
     0.72142308537009891548, ...
     0.73975604435269475868, ...
     0.75748396638051363793, ...
     0.77459666924148337704, ...
     0.79108493379984836143, ...
     0.80694053195021761186, ...
     0.82215625436498040737, ...
     0.83672593816886873550, ...
     0.85064449476835027976, ...
     0.86390793819369047715, ...
     0.87651341448470526974, ...
     0.88845923287225699889, ...
     0.89974489977694003664, ...
     0.91037115695700429250, ...
     0.92034002547001242073, ...
     0.92965485742974005667, ...
     0.93832039777959288365, ...
     0.94634285837340290515, ...
     0.95373000642576113641, ...
     0.96049126870802028342, ...
     0.96663785155841656709, ...
     0.97218287474858179658, ...
     0.97714151463970571416, ...
     0.98153114955374010687, ...
     0.98537149959852037111, ...
     0.98868475754742947994, ...
     0.99149572117810613240, ...
     0.99383196321275502221, ...
     0.99572410469840718851, ...
     0.99720625937222195908, ...
     0.99831663531840739253, ...
     0.99909812496766759766, ...
     0.99959879967191068325, ...
     0.99987288812035761194, ...
     0.99998243035489159858, ...
    -0.99999759637974846462, ...
    -0.99998243035489159858, ...
    -0.99994399620705437576, ...
    -0.99987288812035761194, ...
    -0.99976049092443204733, ...
    -0.99959879967191068325, ...
    -0.99938033802502358193, ...
    -0.99909812496766759766, ...
    -0.99874561446809511470, ...
    -0.99831663531840739253, ...
    -0.99780535449595727456, ...
    -0.99720625937222195908, ...
    -0.99651414591489027385, ...
    -0.99572410469840718851, ...
    -0.99483150280062100052, ...
    -0.99383196321275502221, ...
    -0.99272134428278861533, ...
    -0.99149572117810613240, ...
    -0.99015137040077015918, ...
    -0.98868475754742947994, ...
    -0.98709252795403406719, ...
    -0.98537149959852037111, ...
    -0.98351865757863272876, ...
    -0.98153114955374010687, ...
    -0.97940628167086268381, ...
    -0.97714151463970571416, ...
    -0.97473445975240266776, ...
    -0.97218287474858179658, ...
    -0.96948465950245923177, ...
    -0.96663785155841656709, ...
    -0.96364062156981213252, ...
    -0.96049126870802028342, ...
    -0.95718821610986096274, ...
    -0.95373000642576113641, ...
    -0.95011529752129487656, ...
    -0.94634285837340290515, ...
    -0.94241156519108305981, ...
    -0.93832039777959288365, ...
    -0.93406843615772578800, ...
    -0.92965485742974005667, ...
    -0.92507893290707565236, ...
    -0.92034002547001242073, ...
    -0.91543758715576504064, ...
    -0.91037115695700429250, ...
    -0.90514035881326159519, ...
    -0.89974489977694003664, ...
    -0.89418456833555902286, ...
    -0.88845923287225699889, ...
    -0.88256884024734190684, ...
    -0.87651341448470526974, ...
    -0.87029305554811390585, ...
    -0.86390793819369047715, ...
    -0.85735831088623215653, ...
    -0.85064449476835027976, ...
    -0.84376688267270860104, ...
    -0.83672593816886873550, ...
    -0.82952219463740140018, ...
    -0.82215625436498040737, ...
    -0.81462878765513741344, ...
    -0.80694053195021761186, ...
    -0.79909229096084140180, ...
    -0.79108493379984836143, ...
    -0.78291939411828301639, ...
    -0.77459666924148337704, ...
    -0.76611781930376009072, ...
    -0.75748396638051363793, ...
    -0.74869629361693660282, ...
    -0.73975604435269475868, ...
    -0.73066452124218126133, ...
    -0.72142308537009891548, ...
    -0.71203315536225203459, ...
    -0.70249620649152707861, ...
    -0.69281376977911470289, ...
    -0.68298743109107922809, ...
    -0.67301883023041847920, ...
    -0.66290966002478059546, ...
    -0.65266166541001749610, ...
    -0.64227664250975951377, ...
    -0.63175643771119423041, ...
    -0.62110294673722640294, ...
    -0.61031811371518640016, ...
    -0.59940393024224289297, ...
    -0.58836243444766254143, ...
    -0.57719571005204581484, ...
    -0.56590588542365442262, ...
    -0.55449513263193254887, ...
    -0.54296566649831149049, ...
    -0.53131974364437562397, ...
    -0.51955966153745702199, ...
    -0.50768775753371660215, ...
    -0.49570640791876146017, ...
    -0.48361802694584102756, ...
    -0.47142506587165887693, ...
    -0.45913001198983233287, ...
    -0.44673538766202847374, ...
    -0.43424374934680255800, ...
    -0.42165768662616330006, ...
    -0.40897982122988867241, ...
    -0.39621280605761593918, ...
    -0.38335932419873034692, ...
    -0.37042208795007823014, ...
    -0.35740383783153215238, ...
    -0.34430734159943802278, ...
    -0.33113539325797683309, ...
    -0.31789081206847668318, ...
    -0.30457644155671404334, ...
    -0.29119514851824668196, ...
    -0.27774982202182431507, ...
    -0.26424337241092676194, ...
    -0.25067873030348317661, ...
    -0.23705884558982972721, ...
    -0.22338668642896688163, ...
    -0.20966523824318119477, ...
    -0.19589750271110015392, ...
    -0.18208649675925219825, ...
    -0.16823525155220746498, ...
    -0.15434681148137810869, ...
    -0.14042423315256017459, ...
    -0.12647058437230196685, ...
    -0.11248894313318662575, ...
    -0.098482396598119202090, ...
    -0.084454040083710883710, ...
    -0.070406976042855179063, ...
    -0.056344313046592789972, ...
    -0.042269164765363603212, ...
    -0.028184648949745694339, ...
    -0.014093886410782462614, ...
    0.0, ...
    0.014093886410782462614, ...
    0.028184648949745694339, ...
    0.042269164765363603212, ...
    0.056344313046592789972, ...
    0.070406976042855179063, ...
    0.084454040083710883710, ...
    0.098482396598119202090, ...
    0.11248894313318662575, ...
    0.12647058437230196685, ...
    0.14042423315256017459, ...
    0.15434681148137810869, ...
    0.16823525155220746498, ...
    0.18208649675925219825, ...
    0.19589750271110015392, ...
    0.20966523824318119477, ...
    0.22338668642896688163, ...
    0.23705884558982972721, ...
    0.25067873030348317661, ...
    0.26424337241092676194, ...
    0.27774982202182431507, ...
    0.29119514851824668196, ...
    0.30457644155671404334, ...
    0.31789081206847668318, ...
    0.33113539325797683309, ...
    0.34430734159943802278, ...
    0.35740383783153215238, ...
    0.37042208795007823014, ...
    0.38335932419873034692, ...
    0.39621280605761593918, ...
    0.40897982122988867241, ...
    0.42165768662616330006, ...
    0.43424374934680255800, ...
    0.44673538766202847374, ...
    0.45913001198983233287, ...
    0.47142506587165887693, ...
    0.48361802694584102756, ...
    0.49570640791876146017, ...
    0.50768775753371660215, ...
    0.51955966153745702199, ...
    0.53131974364437562397, ...
    0.54296566649831149049, ...
    0.55449513263193254887, ...
    0.56590588542365442262, ...
    0.57719571005204581484, ...
    0.58836243444766254143, ...
    0.59940393024224289297, ...
    0.61031811371518640016, ...
    0.62110294673722640294, ...
    0.63175643771119423041, ...
    0.64227664250975951377, ...
    0.65266166541001749610, ...
    0.66290966002478059546, ...
    0.67301883023041847920, ...
    0.68298743109107922809, ...
    0.69281376977911470289, ...
    0.70249620649152707861, ...
    0.71203315536225203459, ...
    0.72142308537009891548, ...
    0.73066452124218126133, ...
    0.73975604435269475868, ...
    0.74869629361693660282, ...
    0.75748396638051363793, ...
    0.76611781930376009072, ...
    0.77459666924148337704, ...
    0.78291939411828301639, ...
    0.79108493379984836143, ...
    0.79909229096084140180, ...
    0.80694053195021761186, ...
    0.81462878765513741344, ...
    0.82215625436498040737, ...
    0.82952219463740140018, ...
    0.83672593816886873550, ...
    0.84376688267270860104, ...
    0.85064449476835027976, ...
    0.85735831088623215653, ...
    0.86390793819369047715, ...
    0.87029305554811390585, ...
    0.87651341448470526974, ...
    0.88256884024734190684, ...
    0.88845923287225699889, ...
    0.89418456833555902286, ...
    0.89974489977694003664, ...
    0.90514035881326159519, ...
    0.91037115695700429250, ...
    0.91543758715576504064, ...
    0.92034002547001242073, ...
    0.92507893290707565236, ...
    0.92965485742974005667, ...
    0.93406843615772578800, ...
    0.93832039777959288365, ...
    0.94241156519108305981, ...
    0.94634285837340290515, ...
    0.95011529752129487656, ...
    0.95373000642576113641, ...
    0.95718821610986096274, ...
    0.96049126870802028342, ...
    0.96364062156981213252, ...
    0.96663785155841656709, ...
    0.96948465950245923177, ...
    0.97218287474858179658, ...
    0.97473445975240266776, ...
    0.97714151463970571416, ...
    0.97940628167086268381, ...
    0.98153114955374010687, ...
    0.98351865757863272876, ...
    0.98537149959852037111, ...
    0.98709252795403406719, ...
    0.98868475754742947994, ...
    0.99015137040077015918, ...
    0.99149572117810613240, ...
    0.99272134428278861533, ...
    0.99383196321275502221, ...
    0.99483150280062100052, ...
    0.99572410469840718851, ...
    0.99651414591489027385, ...
    0.99720625937222195908, ...
    0.99780535449595727456, ...
    0.99831663531840739253, ...
    0.99874561446809511470, ...
    0.99909812496766759766, ...
    0.99938033802502358193, ...
    0.99959879967191068325, ...
    0.99976049092443204733, ...
    0.99987288812035761194, ...
    0.99994399620705437576, ...
    0.99998243035489159858, ...
    0.99999759637974846462 ];

  if ( i < 1 | order < i )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'GP_ABSCISSA - Fatal error!\n' );
    fprintf ( 1, '  I < 1 or ORDER < I.\n' );
    fprintf ( 1, '  I = %d\n', i );
    fprintf ( 1, '  ORDER = %d\n', order );
    error ( 'GP_ABSCISSA - Fatal error!' );
  end
%
%  Assuming ORDER is one of the expected values, this
%  will retrieve the value of LEVEL.
%
  level = 0;
  j = floor ( ( order + 1 ) / 2 );

  while ( 1 < j )
    level = level + 1;
    j = floor ( j / 2 );
  end

  j = order_pointer(level+1) + i;

  value = xtab(j);

  return
end
