function [ x, w ] = lobatto_set ( n )

%*****************************************************************************80
%
%% LOBATTO_SET sets abscissas and weights for Lobatto quadrature.
%
%  Discussion:
%
%    The integral:
%
%      Integral ( -1 <= X <= 1 ) F(X) dX
%
%    The quadrature rule:
%
%      Sum ( 1 <= I <= N ) W(I) * F ( X(I) )
%
%    The quadrature rule will integrate exactly all polynomials up to
%    X^(2*N-3).
%
%    The Lobatto rule is distinguished by the fact that both endpoints
%    (-1 and 1) are always abscissas of the rule.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    28 May 2014
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Milton Abramowitz and Irene Stegun,
%    Handbook of Mathematical Functions,
%    National Bureau of Standards, 1964.
%
%    Arthur Stroud and Don Secrest,
%    Gaussian Quadrature Formulas,
%    Prentice Hall, 1966.
%
%    Daniel Zwillinger, editor,
%    Standard Mathematical Tables and Formulae,
%    30th Edition,
%    CRC Press, 1996.
%
%  Parameters:
%
%    Input, integer N, the order.
%    N must be between 1 and 20.
%
%    Output, real X(N), the abscissas.
%
%    Output, real W(N), the weights.
%
  x = zeros ( n, 1 );
  w = zeros ( n, 1 );

  if ( n == 1 )

    x(1) = -1.0;

    w(1) = 2.0;

  elseif ( n == 2 )

    x(1) =  - 1.0;
    x(2) =    1.0;

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

  elseif ( n == 3 )

    x(1) =  - 1.0;
    x(2) =    0.0;
    x(3) =    1.0;

    w(1) =  1.0 / 3.0;
    w(2) =  4.0 / 3.0;
    w(3) =  1.0 / 3.0;

  elseif ( n == 4 )

    x(1) =  - 1.0;
    x(2) =  - 0.447213595499957939281834733746;
    x(3) =    0.447213595499957939281834733746;
    x(4) =    1.0;

    w(1) =  1.0 / 6.0;
    w(2) =  5.0 / 6.0;
    w(3) =  5.0 / 6.0;
    w(4) =  1.0 / 6.0;

  elseif ( n == 5 )

    x(1) =  - 1.0;
    x(2) =  - 0.654653670707977143798292456247;
    x(3) =    0.0;
    x(4) =    0.654653670707977143798292456247;
    x(5) =    1.0;

    w(1) =  9.0 / 90.0;
    w(2) = 49.0 / 90.0;
    w(3) = 64.0 / 90.0;
    w(4) = 49.0 / 90.0;
    w(5) =  9.0 / 90.0;

  elseif ( n == 6 )

    x(1) =  - 1.0;
    x(2) =  - 0.765055323929464692851002973959;
    x(3) =  - 0.285231516480645096314150994041;
    x(4) =    0.285231516480645096314150994041;
    x(5) =    0.765055323929464692851002973959;
    x(6) =    1.0;

    w(1) =  0.066666666666666666666666666667;
    w(2) =  0.378474956297846980316612808212;
    w(3) =  0.554858377035486353016720525121;
    w(4) =  0.554858377035486353016720525121;
    w(5) =  0.378474956297846980316612808212;
    w(6) =  0.066666666666666666666666666667;

  elseif ( n == 7 )

    x(1) =  - 1.0;
    x(2) =  - 0.830223896278566929872032213967;
    x(3) =  - 0.468848793470714213803771881909;
    x(4) =    0.0;
    x(5) =    0.468848793470714213803771881909;
    x(6) =    0.830223896278566929872032213967;
    x(7) =    1.0;

    w(1) =  0.476190476190476190476190476190E-01;
    w(2) =  0.276826047361565948010700406290;
    w(3) =  0.431745381209862623417871022281;
    w(4) =  0.487619047619047619047619047619;
    w(5) =  0.431745381209862623417871022281;
    w(6) =  0.276826047361565948010700406290;
    w(7) =  0.476190476190476190476190476190E-01;

  elseif ( n == 8 )

    x(1) =  - 1.0;
    x(2) =  - 0.871740148509606615337445761221;
    x(3) =  - 0.591700181433142302144510731398;
    x(4) =  - 0.209299217902478868768657260345;
    x(5) =    0.209299217902478868768657260345;
    x(6) =    0.591700181433142302144510731398;
    x(7) =    0.871740148509606615337445761221;
    x(8) =    1.0;

    w(1) =  0.357142857142857142857142857143E-01;
    w(2) =  0.210704227143506039382991065776;
    w(3) =  0.341122692483504364764240677108;
    w(4) =  0.412458794658703881567052971402;
    w(5) =  0.412458794658703881567052971402;
    w(6) =  0.341122692483504364764240677108;
    w(7) =  0.210704227143506039382991065776;
    w(8) =  0.357142857142857142857142857143E-01;

  elseif ( n == 9 )

    x(1) =  - 1.0;
    x(2) =  - 0.899757995411460157312345244418;
    x(3) =  - 0.677186279510737753445885427091;
    x(4) =  - 0.363117463826178158710752068709;
    x(5) =    0.0;
    x(6) =    0.363117463826178158710752068709;
    x(7) =    0.677186279510737753445885427091;
    x(8) =    0.899757995411460157312345244418;
    x(9) =    1.0;

    w(1) =  0.277777777777777777777777777778E-01;
    w(2) =  0.165495361560805525046339720029;
    w(3) =  0.274538712500161735280705618579;
    w(4) =  0.346428510973046345115131532140;
    w(5) =  0.371519274376417233560090702948;
    w(6) =  0.346428510973046345115131532140;
    w(7) =  0.274538712500161735280705618579;
    w(8) =  0.165495361560805525046339720029;
    w(9) =  0.277777777777777777777777777778E-01;

  elseif ( n == 10 )

    x(1) =  - 1.0;
    x(2) =  - 0.919533908166458813828932660822;
    x(3) =  - 0.738773865105505075003106174860;
    x(4) =  - 0.477924949810444495661175092731;
    x(5) =  - 0.165278957666387024626219765958;
    x(6) =    0.165278957666387024626219765958;
    x(7) =    0.477924949810444495661175092731;
    x(8) =    0.738773865105505075003106174860;
    x(9) =    0.919533908166458813828932660822;
    x(10) =   1.0;

    w(1) =  0.222222222222222222222222222222E-01;
    w(2) =  0.133305990851070111126227170755;
    w(3) =  0.224889342063126452119457821731;
    w(4) =  0.292042683679683757875582257374;
    w(5) =  0.327539761183897456656510527917;
    w(6) =  0.327539761183897456656510527917;
    w(7) =  0.292042683679683757875582257374;
    w(8) =  0.224889342063126452119457821731;
    w(9) =  0.133305990851070111126227170755;
    w(10) = 0.222222222222222222222222222222E-01;

  elseif ( n == 11 )

    x(1) =  - 1.0;
    x(2) =  - 0.934001430408059134332274136099;
    x(3) =  - 0.784483473663144418622417816108;
    x(4) =  - 0.565235326996205006470963969478;
    x(5) =  - 0.295758135586939391431911515559;
    x(6) =    0.0;
    x(7) =    0.295758135586939391431911515559;
    x(8) =    0.565235326996205006470963969478;
    x(9) =    0.784483473663144418622417816108;
    x(10) =   0.934001430408059134332274136099;
    x(11) =   1.0;

    w(1) =  0.181818181818181818181818181818E-01;
    w(2) =  0.109612273266994864461403449580;
    w(3) =  0.187169881780305204108141521899;
    w(4) =  0.248048104264028314040084866422;
    w(5) =  0.286879124779008088679222403332;
    w(6) =  0.300217595455690693785931881170;
    w(7) =  0.286879124779008088679222403332;
    w(8) =  0.248048104264028314040084866422;
    w(9) =  0.187169881780305204108141521899;
    w(10) = 0.109612273266994864461403449580;
    w(11) = 0.181818181818181818181818181818E-01;

  elseif ( n == 12 )

    x(1) =  - 1.0;
    x(2) =  - 0.944899272222882223407580138303;
    x(3) =  - 0.819279321644006678348641581717;
    x(4) =  - 0.632876153031869677662404854444;
    x(5) =  - 0.399530940965348932264349791567;
    x(6) =  - 0.136552932854927554864061855740;
    x(7) =    0.136552932854927554864061855740;
    x(8) =    0.399530940965348932264349791567;
    x(9) =    0.632876153031869677662404854444;
    x(10) =   0.819279321644006678348641581717;
    x(11) =   0.944899272222882223407580138303;
    x(12) =   1.0;

    w(1) =  0.151515151515151515151515151515E-01;
    w(2) =  0.916845174131961306683425941341E-01;
    w(3) =  0.157974705564370115164671062700;
    w(4) =  0.212508417761021145358302077367;
    w(5) =  0.251275603199201280293244412148;
    w(6) =  0.271405240910696177000288338500;
    w(7) =  0.271405240910696177000288338500;
    w(8) =  0.251275603199201280293244412148;
    w(9) =  0.212508417761021145358302077367;
    w(10) = 0.157974705564370115164671062700;
    w(11) = 0.916845174131961306683425941341E-01;
    w(12) = 0.151515151515151515151515151515E-01;

  elseif ( n == 13 )

    x(1) =  - 1.0;
    x(2) =  - 0.953309846642163911896905464755;
    x(3) =  - 0.846347564651872316865925607099;
    x(4) =  - 0.686188469081757426072759039566;
    x(5) =  - 0.482909821091336201746937233637;
    x(6) =  - 0.249286930106239992568673700374;
    x(7) =    0.0;
    x(8) =    0.249286930106239992568673700374;
    x(9) =    0.482909821091336201746937233637;
    x(10) =   0.686188469081757426072759039566;
    x(11) =   0.846347564651872316865925607099;
    x(12) =   0.953309846642163911896905464755;
    x(13) =   1.0;

    w(1) =  0.128205128205128205128205128205E-01;
    w(2) =  0.778016867468189277935889883331E-01;
    w(3) =  0.134981926689608349119914762589;
    w(4) =  0.183646865203550092007494258747;
    w(5) =  0.220767793566110086085534008379;
    w(6) =  0.244015790306676356458578148360;
    w(7) =  0.251930849333446736044138641541;
    w(8) =  0.244015790306676356458578148360;
    w(9) =  0.220767793566110086085534008379;
    w(10) = 0.183646865203550092007494258747;
    w(11) = 0.134981926689608349119914762589;
    w(12) = 0.778016867468189277935889883331E-01;
    w(13) = 0.128205128205128205128205128205E-01;

  elseif ( n == 14 )

    x(1) =  - 1.0;
    x(2) =  - 0.959935045267260901355100162015;
    x(3) =  - 0.867801053830347251000220202908;
    x(4) =  - 0.728868599091326140584672400521;
    x(5) =  - 0.550639402928647055316622705859;
    x(6) =  - 0.342724013342712845043903403642;
    x(7) =  - 0.116331868883703867658776709736;
    x(8) =    0.116331868883703867658776709736;
    x(9) =    0.342724013342712845043903403642;
    x(10) =   0.550639402928647055316622705859;
    x(11) =   0.728868599091326140584672400521;
    x(12) =   0.867801053830347251000220202908;
    x(13) =   0.959935045267260901355100162015;
    x(14) =   1.0;

    w(1) =  0.109890109890109890109890109890E-01;
    w(2) =  0.668372844976812846340706607461E-01;
    w(3) =  0.116586655898711651540996670655;
    w(4) =  0.160021851762952142412820997988;
    w(5) =  0.194826149373416118640331778376;
    w(6) =  0.219126253009770754871162523954;
    w(7) =  0.231612794468457058889628357293;
    w(8) =  0.231612794468457058889628357293;
    w(9) =  0.219126253009770754871162523954;
    w(10) = 0.194826149373416118640331778376;
    w(11) = 0.160021851762952142412820997988;
    w(12) = 0.116586655898711651540996670655;
    w(13) = 0.668372844976812846340706607461E-01;
    w(14) = 0.109890109890109890109890109890E-01;

  elseif ( n == 15 )

    x(1) =  - 1.0;
    x(2) =  - 0.965245926503838572795851392070;
    x(3) =  - 0.885082044222976298825401631482;
    x(4) =  - 0.763519689951815200704118475976;
    x(5) =  - 0.606253205469845711123529938637;
    x(6) =  - 0.420638054713672480921896938739;
    x(7) =  - 0.215353955363794238225679446273;
    x(8) =    0.0;
    x(9) =    0.215353955363794238225679446273;
    x(10) =   0.420638054713672480921896938739;
    x(11) =   0.606253205469845711123529938637;
    x(12) =   0.763519689951815200704118475976;
    x(13) =   0.885082044222976298825401631482;
    x(14) =   0.965245926503838572795851392070;
    x(15) =   1.0;

    w(1) =  0.952380952380952380952380952381E-02;
    w(2) =  0.580298930286012490968805840253E-01;
    w(3) =  0.101660070325718067603666170789;
    w(4) =  0.140511699802428109460446805644;
    w(5) =  0.172789647253600949052077099408;
    w(6) =  0.196987235964613356092500346507;
    w(7) =  0.211973585926820920127430076977;
    w(8) =  0.217048116348815649514950214251;
    w(9) =  0.211973585926820920127430076977;
    w(10) = 0.196987235964613356092500346507;
    w(11) = 0.172789647253600949052077099408;
    w(12) = 0.140511699802428109460446805644;
    w(13) = 0.101660070325718067603666170789;
    w(14) = 0.580298930286012490968805840253E-01;
    w(15) = 0.952380952380952380952380952381E-02;

  elseif ( n == 16 )

    x(1) =  - 1.0;
    x(2) =  - 0.969568046270217932952242738367;
    x(3) =  - 0.899200533093472092994628261520;
    x(4) =  - 0.792008291861815063931088270963;
    x(5) =  - 0.652388702882493089467883219641;
    x(6) =  - 0.486059421887137611781890785847;
    x(7) =  - 0.299830468900763208098353454722;
    x(8) =  - 0.101326273521949447843033005046;
    x(9) =    0.101326273521949447843033005046;
    x(10) =   0.299830468900763208098353454722;
    x(11) =   0.486059421887137611781890785847;
    x(12) =   0.652388702882493089467883219641;
    x(13) =   0.792008291861815063931088270963;
    x(14) =   0.899200533093472092994628261520;
    x(15) =   0.969568046270217932952242738367;
    x(16) =   1.0;

    w(1) =  0.833333333333333333333333333333E-02;
    w(2) =  0.508503610059199054032449195655E-01;
    w(3) =  0.893936973259308009910520801661E-01;
    w(4) =  0.124255382132514098349536332657;
    w(5) =  0.154026980807164280815644940485;
    w(6) =  0.177491913391704125301075669528;
    w(7) =  0.193690023825203584316913598854;
    w(8) =  0.201958308178229871489199125411;
    w(9) =  0.201958308178229871489199125411;
    w(10) = 0.193690023825203584316913598854;
    w(11) = 0.177491913391704125301075669528;
    w(12) = 0.154026980807164280815644940485;
    w(13) = 0.124255382132514098349536332657;
    w(14) = 0.893936973259308009910520801661E-01;
    w(15) = 0.508503610059199054032449195655E-01;
    w(16) = 0.833333333333333333333333333333E-02;

  elseif ( n == 17 )

    x(1) =  - 1.0;
    x(2) =  - 0.973132176631418314156979501874;
    x(3) =  - 0.910879995915573595623802506398;
    x(4) =  - 0.815696251221770307106750553238;
    x(5) =  - 0.691028980627684705394919357372;
    x(6) =  - 0.541385399330101539123733407504;
    x(7) =  - 0.372174433565477041907234680735;
    x(8) =  - 0.189511973518317388304263014753;
    x(9) =    0.0;
    x(10) =   0.189511973518317388304263014753;
    x(11) =   0.372174433565477041907234680735;
    x(12) =   0.541385399330101539123733407504;
    x(13) =   0.691028980627684705394919357372;
    x(14) =   0.815696251221770307106750553238;
    x(15) =   0.910879995915573595623802506398;
    x(16) =   0.973132176631418314156979501874;
    x(17) =   1.0;

    w(1) =  0.735294117647058823529411764706E-02;
    w(2) =  0.449219405432542096474009546232E-01;
    w(3) =  0.791982705036871191902644299528E-01;
    w(4) =  0.110592909007028161375772705220;
    w(5) =  0.137987746201926559056201574954;
    w(6) =  0.160394661997621539516328365865;
    w(7) =  0.177004253515657870436945745363;
    w(8) =  0.187216339677619235892088482861;
    w(9) =  0.190661874753469433299407247028;
    w(10) = 0.187216339677619235892088482861;
    w(11) = 0.177004253515657870436945745363;
    w(12) = 0.160394661997621539516328365865;
    w(13) = 0.137987746201926559056201574954;
    w(14) = 0.110592909007028161375772705220;
    w(15) = 0.791982705036871191902644299528E-01;
    w(16) = 0.449219405432542096474009546232E-01;
    w(17) = 0.735294117647058823529411764706E-02;

  elseif ( n == 18 )

    x(1) =  - 1.0;
    x(2) =  - 0.976105557412198542864518924342;
    x(3) =  - 0.920649185347533873837854625431;
    x(4) =  - 0.835593535218090213713646362328;
    x(5) =  - 0.723679329283242681306210365302;
    x(6) =  - 0.588504834318661761173535893194;
    x(7) =  - 0.434415036912123975342287136741;
    x(8) =  - 0.266362652878280984167665332026;
    x(9) =  - 0.897490934846521110226450100886E-01;
    x(10) =   0.897490934846521110226450100886E-01;
    x(11) =   0.266362652878280984167665332026;
    x(12) =   0.434415036912123975342287136741;
    x(13) =   0.588504834318661761173535893194;
    x(14) =   0.723679329283242681306210365302;
    x(15) =   0.835593535218090213713646362328;
    x(16) =   0.920649185347533873837854625431;
    x(17) =   0.976105557412198542864518924342;
    x(18) =   1.0;

    w(1) =  0.653594771241830065359477124183E-02;
    w(2) =  0.399706288109140661375991764101E-01;
    w(3) =  0.706371668856336649992229601678E-01;
    w(4) =  0.990162717175028023944236053187E-01;
    w(5) =  0.124210533132967100263396358897;
    w(6) =  0.145411961573802267983003210494;
    w(7) =  0.161939517237602489264326706700;
    w(8) =  0.173262109489456226010614403827;
    w(9) =  0.179015863439703082293818806944;
    w(10) = 0.179015863439703082293818806944;
    w(11) = 0.173262109489456226010614403827;
    w(12) = 0.161939517237602489264326706700;
    w(13) = 0.145411961573802267983003210494;
    w(14) = 0.124210533132967100263396358897;
    w(15) = 0.990162717175028023944236053187E-01;
    w(16) = 0.706371668856336649992229601678E-01;
    w(17) = 0.399706288109140661375991764101E-01;
    w(18) = 0.653594771241830065359477124183E-02;

  elseif ( n == 19 )

    x(1) =  - 1.0;
    x(2) =  - 0.978611766222080095152634063110;
    x(3) =  - 0.928901528152586243717940258797;
    x(4) =  - 0.852460577796646093085955970041;
    x(5) =  - 0.751494202552613014163637489634;
    x(6) =  - 0.628908137265220497766832306229;
    x(7) =  - 0.488229285680713502777909637625;
    x(8) =  - 0.333504847824498610298500103845;
    x(9) =  - 0.169186023409281571375154153445;
    x(10) =   0.0;
    x(11) =   0.169186023409281571375154153445;
    x(12) =   0.333504847824498610298500103845;
    x(13) =   0.488229285680713502777909637625;
    x(14) =   0.628908137265220497766832306229;
    x(15) =   0.751494202552613014163637489634;
    x(16) =   0.852460577796646093085955970041;
    x(17) =   0.928901528152586243717940258797;
    x(18) =   0.978611766222080095152634063110;
    x(19) =   1.0;

    w(1) =  0.584795321637426900584795321637E-02;
    w(2) =  0.357933651861764771154255690351E-01;
    w(3) =  0.633818917626297368516956904183E-01;
    w(4) =  0.891317570992070844480087905562E-01;
    w(5) =  0.112315341477305044070910015464;
    w(6) =  0.132267280448750776926046733910;
    w(7) =  0.148413942595938885009680643668;
    w(8) =  0.160290924044061241979910968184;
    w(9) =  0.167556584527142867270137277740;
    w(10) = 0.170001919284827234644672715617;
    w(11) = 0.167556584527142867270137277740;
    w(12) = 0.160290924044061241979910968184;
    w(13) = 0.148413942595938885009680643668;
    w(14) = 0.132267280448750776926046733910;
    w(15) = 0.112315341477305044070910015464;
    w(16) = 0.891317570992070844480087905562E-01;
    w(17) = 0.633818917626297368516956904183E-01;
    w(18) = 0.357933651861764771154255690351E-01;
    w(19) = 0.584795321637426900584795321637E-02;

  elseif ( n == 20 )

    x(1) =  - 1.0;
    x(2) =  - 0.980743704893914171925446438584;
    x(3) =  - 0.935934498812665435716181584931;
    x(4) =  - 0.866877978089950141309847214616;
    x(5) =  - 0.775368260952055870414317527595;
    x(6) =  - 0.663776402290311289846403322971;
    x(7) =  - 0.534992864031886261648135961829;
    x(8) =  - 0.392353183713909299386474703816;
    x(9) =  - 0.239551705922986495182401356927;
    x(10) = - 0.805459372388218379759445181596E-01;
    x(11) =   0.805459372388218379759445181596E-01;
    x(12) =   0.239551705922986495182401356927;
    x(13) =   0.392353183713909299386474703816;
    x(14) =   0.534992864031886261648135961829;
    x(15) =   0.663776402290311289846403322971;
    x(16) =   0.775368260952055870414317527595;
    x(17) =   0.866877978089950141309847214616;
    x(18) =   0.935934498812665435716181584931;
    x(19) =   0.980743704893914171925446438584;
    x(20) =   1.0;

    w(1) =  0.526315789473684210526315789474E-02;
    w(2) =  0.322371231884889414916050281173E-01;
    w(3) =  0.571818021275668260047536271732E-01;
    w(4) =  0.806317639961196031447768461137E-01;
    w(5) =  0.101991499699450815683781205733;
    w(6) =  0.120709227628674725099429705002;
    w(7) =  0.136300482358724184489780792989;
    w(8) =  0.148361554070916825814713013734;
    w(9) =  0.156580102647475487158169896794;
    w(10) = 0.160743286387845749007726726449;
    w(11) = 0.160743286387845749007726726449;
    w(12) = 0.156580102647475487158169896794;
    w(13) = 0.148361554070916825814713013734;
    w(14) = 0.136300482358724184489780792989;
    w(15) = 0.120709227628674725099429705002;
    w(16) = 0.101991499699450815683781205733;
    w(17) = 0.806317639961196031447768461137E-01;
    w(18) = 0.571818021275668260047536271732E-01;
    w(19) = 0.322371231884889414916050281173E-01;
    w(20) = 0.526315789473684210526315789474E-02;

  else

    fprintf ( 1, '\n' );
    fprintf ( 1, 'LOBATTO_SET - Fatal error!\n' );
    fprintf ( 1, '  Illegal value of N = %d\n', n );
    fprintf ( 1, '  Legal values are between 1 and 20.\n' );
    error ( 'LOBATTO_SET - Fatal error!' );

  end

  return
end
