function [ x, w ] = rule_power ( rule, j )

%*****************************************************************************80
%
%% rule_power() returns an Alpert rule for power singular functions.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 November 2015
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Bradley Alpert,
%    Hybrid Gauss-Trapezoidal Quadrature Rules,
%    SIAM Journal on Scientific Computing,
%    Volume 20, Number 5, pages 1551-1584, 1999.
%
%  Input:
%
%    integer RULE, the index of the rule, between 1 and 12.
%
%    integer J, the number of points in the rule.
%
%  Output:
%
%    real X(J), W(J), the points and weights needed for the rule.
%
  if ( rule < 1 || 12 < rule )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'RULE_POWER - Fatal error!\n' );
    fprintf ( 1, '  Input value of RULE is not between 1 and 12.\n' );
    error ( 'RULE_POWER - Fatal error!' );
  end

  if ( rule == 1 )

    x(1) = 1.172258571393266E-01;
         
    w(1) = 5.000000000000000E-01;

  elseif ( rule == 2 )

    x(1) = 9.252112715421378E-02;
    x(2) = 1.000000000000000E-00;

    w(1) = 4.198079625266162E-01;
    w(2) = 1.080192037473384E+00;

  elseif ( rule == 3 )

    x(1) = 6.023873796408450E-02;
    x(2) = 8.780704050676215E-01;

    w(1) = 2.858439990420468E-01;
    w(2) = 1.214156000957953E+00;

  elseif ( rule == 4 )

    x(1) = 7.262978413470474E-03;
    x(2) = 2.246325512521893E-01;
    x(3) = 1.000000000000000E+00;

    w(1) = 3.907638767531813E-02;
    w(2) = 4.873484056646474E-01;
    w(3) = 9.735752066600344E-01;

  elseif ( rule == 5 )

    x(1) = 1.282368909458828E-02;
    x(2) = 2.694286346792474E-01;
    x(3) = 1.018414523786358E+00;

    w(1) = 6.363996663105925E-02;
    w(2) = 5.077434578043636E-01;
    w(3) = 9.286165755645772E-01;

  elseif ( rule == 6 )

    x(1) = 1.189242434021285E-02;
    x(2) = 2.578220434738662E-01;
    x(3) = 1.007750064585281E+00;
    x(4) = 2.000000000000000E+00;

    w(1) = 5.927215035616424E-02;
    w(2) = 4.955981740306228E-01;
    w(3) = 9.427131290628058E-01;
    w(4) = 1.002416546550407E+00;

  elseif ( rule == 7 )

    x(1) = 3.317925942699451E-03;
    x(2) = 8.283019705296352E-02;
    x(3) = 4.136094925726231E-01;
    x(4) = 1.088744373688402E+00;
    x(5) = 2.006482101852379E+00;
    x(6) = 3.000000000000000E+00;

    w(1) = 1.681780929883469E-02;
    w(2) = 1.755244404544475E-01;
    w(3) = 5.039350503858001E-01;
    w(4) = 8.266241339680867E-01;
    w(5) = 9.773065848981277E-01;
    w(6) = 9.997919809947032E-01;

  elseif ( rule == 8 )

    x(1) = 1.214130606523435E-03;
    x(2) = 3.223952700027058E-02;
    x(3) = 1.790935383649920E-01;
    x(4) = 5.437663805244631E-01;
    x(5) = 1.176116628396759E+00;
    x(6) = 2.031848210716014E+00;
    x(7) = 3.001961225690812E+00;
    x(8) = 4.000000000000000E+00;

    w(1) = 6.199844884297793E-03;
    w(2) = 7.106286791720044E-02;
    w(3) = 2.408930104410471E-01;
    w(4) = 4.975929263668960E-01;
    w(5) = 7.592446540441226E-01;
    w(6) = 9.322446399614420E-01;
    w(7) = 9.928171438160095E-01;
    w(8) = 9.999449125689846E-01;

  elseif ( rule == 9 )

    x(1) = 1.745862989163252E-04;
    x(2) = 8.613670540457314E-03;
    x(3) = 6.733385088703690E-02;
    x(4) = 2.514488774733840E-01;
    x(5) = 6.341845573737690E-01;
    x(6) = 1.248404055083152E+00;
    x(7) = 2.065688031953401E+00;
    x(8) = 3.009199358662542E+00;
    x(9) = 4.000416269690208E+00;
    x(10) = 5.000000000000000E+00;

    w(1) = 1.016950985948944E-03;
    w(2) = 2.294670686517670E-02;
    w(3) = 1.076657968022888E-01;
    w(4) = 2.734577662465576E-01;
    w(5) = 4.978815591924992E-01;
    w(6) = 7.256208919565360E-01;
    w(7) = 8.952638690320078E-01;
    w(8) = 9.778157465381624E-01;
    w(9) = 9.983390781399277E-01;
    w(10) = 9.999916342408948E-01;

  elseif ( rule == 10 )

    x(1) = 5.710218427206990E-04;
    x(2) = 1.540424351115548E-02;
    x(3) = 8.834248407196555E-02;
    x(4) = 2.824462054509770E-01;
    x(5) = 6.574869892305580E-01;
    x(6) = 1.246541060977993E+00;
    x(7) = 2.039218495130811E+00;
    x(8) = 2.979333487049800E+00;
    x(9) = 3.985772595393049E+00;
    x(10) = 4.997240804311428E+00;
    x(11) = 5.999868793951190E+00;
    x(12) = 7.000000000000000E+00;

    w(1) = 2.921018926912141E-03;
    w(2) = 3.431130611256885E-02;
    w(3) = 1.224669495638615E-01;
    w(4) = 2.761108242022520E-01;
    w(5) = 4.797809643010337E-01;
    w(6) = 6.966555677271379E-01;
    w(7) = 8.790077941972658E-01;
    w(8) = 9.868622449294327E-01;
    w(9) = 1.015142389688201E+00;
    w(10) = 1.006209712632210E+00;
    w(11) = 1.000528829922287E+00;
    w(12) = 1.000002397796838E+00;

  elseif ( rule == 11 )

    x(1) = 3.419821460249725E-04;
    x(2) = 9.296593430187960E-03;
    x(3) = 5.406214771755252E-02;
    x(4) = 1.763945096508648E-01;
    x(5) = 4.218486605653738E-01;
    x(6) = 8.274022895884040E-01;
    x(7) = 1.410287585637014E+00;
    x(8) = 2.160997505238153E+00;
    x(9) = 3.043504749358223E+00;
    x(10) = 4.005692579069439E+00;
    x(11) = 4.999732707905968E+00;
    x(12) = 5.999875191971098E+00;
    x(13) = 6.999994560568667E+00;
    x(14) = 8.000000000000000E+00;

    w(1) = 1.750957243202047E-03;
    w(2) = 2.080726584287380E-02;
    w(3) = 7.586830616433430E-02;
    w(4) = 1.766020526671851E-01;
    w(5) = 3.206624362072232E-01;
    w(6) = 4.934405290553812E-01;
    w(7) = 6.707497030698472E-01;
    w(8) = 8.244959025366557E-01;
    w(9) = 9.314646742162802E-01;
    w(10) = 9.845768443163154E-01;
    w(11) = 9.992852769154770E-01;
    w(12) = 1.000273112957723E+00;
    w(13) = 1.000022857402321E+00;
    w(14) = 1.000000081405180E+00;

  elseif ( rule == 12 )

    x(1) = 2.158438988280793E-04;
    x(2) = 5.898432743709196E-03;
    x(3) = 3.462795956896131E-02;
    x(4) = 1.145586495070213E-01;
    x(5) = 2.790344218856415E-01;
    x(6) = 5.600113798653321E-01;
    x(7) = 9.814091242883119E-01;
    x(8) = 1.553594853974655E+00;
    x(9) = 2.270179114036658E+00;
    x(10) = 3.108234601715371E+00;
    x(11) = 4.032930893996553E+00;
    x(12) = 5.006803270228157E+00;
    x(13) = 6.000815466735179E+00;
    x(14) = 7.000045035079542E+00;
    x(15) = 8.000000738923901E+00;
    x(16) = 9.000000000000000E+00;

    w(1) = 1.105804873501181E-03;
    w(2) = 1.324499944707956E-02;
    w(3) = 4.899842307592144E-02;
    w(4) = 1.165326192868815E-01;
    w(5) = 2.178586693194957E-01;
    w(6) = 3.481766016945031E-01;
    w(7) = 4.964027915911545E-01;
    w(8) = 6.469026189623831E-01;
    w(9) = 7.823688971783889E-01;
    w(10) = 8.877772445893361E-01;
    w(11) = 9.551665077035583E-01;
    w(12) = 9.876285579741800E-01;
    w(13) = 9.979929183863017E-01;
    w(14) = 9.998470620634641E-01;
    w(15) = 9.999962891645340E-01;
    w(16) = 9.999999946893169E-01;

  end
%
%  Column vectors!
%
  x = x';
  w = w';

  return
end

