function [ x, w ] = fejer1_set ( n ) %*****************************************************************************80 % %% FEJER1_SET sets abscissas and weights for Fejer type 1 quadrature. % % Licensing: % % This code is distributed under the GNU LGPL license. % % Modified: % % 22 April 2010 % % Author: % % John Burkardt % % Reference: % % Philip Davis, Philip Rabinowitz, % Methods of Numerical Integration, % Second Edition, % Dover, 2007, % ISBN: 0486453391, % LC: QA299.3.D28. % % Walter Gautschi, % Numerical Quadrature in the Presence of a Singularity, % SIAM Journal on Numerical Analysis, % Volume 4, Number 3, 1967, pages 357-362. % % Joerg Waldvogel, % Fast Construction of the Fejer and Clenshaw-Curtis Quadrature Rules, % BIT Numerical Mathematics, % Volume 43, Number 1, 2003, pages 1-18. % % Parameters: % % Input, integer N, the order. % N should be between 1 and 10. % % 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) = 0.000000000000000; w(1) = 2.000000000000000; elseif ( n == 2 ) x(1) = -0.7071067811865475; x(2) = 0.7071067811865475; w(1) = 1.000000000000000; w(2) = 1.000000000000000; elseif ( n == 3 ) x( 1) = -0.8660254037844387; x( 2) = 0.0000000000000000; x( 3) = 0.8660254037844387; w(1) = 0.4444444444444444; w(2) = 1.111111111111111; w(3) = 0.4444444444444444; elseif ( n == 4 ) x( 1) = -0.9238795325112867; x( 2) = -0.3826834323650897; x( 3) = 0.3826834323650898; x( 4) = 0.9238795325112867; w( 1) = 0.2642977396044841; w( 2) = 0.7357022603955158; w( 3) = 0.7357022603955158; w( 4) = 0.2642977396044841; elseif ( n == 5 ) x( 1) = -0.9510565162951535; x( 2) = -0.5877852522924730; x( 3) = 0.0000000000000000; x( 4) = 0.5877852522924731; x( 5) = 0.9510565162951535; w( 1) = 0.1677812284666835; w( 2) = 0.5255521048666498; w( 3) = 0.6133333333333333; w( 4) = 0.5255521048666498; w( 5) = 0.1677812284666835; elseif ( n == 6 ) x( 1) = -0.9659258262890682; x( 2) = -0.7071067811865475; x( 3) = -0.2588190451025206; x( 4) = 0.2588190451025207; x( 5) = 0.7071067811865476; x( 6) = 0.9659258262890683; w( 1) = 0.1186610213812358; w( 2) = 0.3777777777777778; w( 3) = 0.5035612008409863; w( 4) = 0.5035612008409863; w( 5) = 0.3777777777777778; w( 6) = 0.1186610213812358; elseif ( n == 7 ) x( 1) = -0.9749279121818237; x( 2) = -0.7818314824680295; x( 3) = -0.4338837391175581; x( 4) = 0.0000000000000000; x( 5) = 0.4338837391175582; x( 6) = 0.7818314824680298; x( 7) = 0.9749279121818236; w( 1) = 0.08671618072672234; w( 2) = 0.2878313947886919; w( 3) = 0.3982415401308441; w( 4) = 0.4544217687074830; w( 5) = 0.3982415401308441; w( 6) = 0.2878313947886919; w( 7) = 0.08671618072672234; elseif ( n == 8 ) x( 1) = -0.9807852804032304; x( 2) = -0.8314696123025453; x( 3) = -0.5555702330196020; x( 4) = -0.1950903220161282; x( 5) = 0.1950903220161283; x( 6) = 0.5555702330196023; x( 7) = 0.8314696123025452; x( 8) = 0.9807852804032304; w( 1) = 0.06698294569858981; w( 2) = 0.2229879330145788; w( 3) = 0.3241525190645244; w( 4) = 0.3858766022223071; w( 5) = 0.3858766022223071; w( 6) = 0.3241525190645244; w( 7) = 0.2229879330145788; w( 8) = 0.06698294569858981; elseif ( n == 9 ) x( 1) = -0.9848077530122080; x( 2) = -0.8660254037844385; x( 3) = -0.6427876096865394; x( 4) = -0.3420201433256685; x( 5) = 0.0000000000000000; x( 6) = 0.3420201433256688; x( 7) = 0.6427876096865394; x( 8) = 0.8660254037844387; x( 9) = 0.9848077530122080; w( 1) = 0.05273664990990676; w( 2) = 0.1791887125220458; w( 3) = 0.2640372225410044; w( 4) = 0.3308451751681364; w( 5) = 0.3463844797178130; w( 6) = 0.3308451751681364; w( 7) = 0.2640372225410044; w( 8) = 0.1791887125220458; w( 9) = 0.05273664990990676; elseif ( n == 10 ) x( 1) = -0.9876883405951377; x( 2) = -0.8910065241883678; x( 3) = -0.7071067811865475; x( 4) = -0.4539904997395467; x( 5) = -0.1564344650402306; x( 6) = 0.1564344650402309; x( 7) = 0.4539904997395468; x( 8) = 0.7071067811865476; x( 9) = 0.8910065241883679; x(10) = 0.9876883405951378; w( 1) = 0.04293911957413078; w( 2) = 0.1458749193773909; w( 3) = 0.2203174603174603; w( 4) = 0.2808792186638755; w( 5) = 0.3099892820671425; w( 6) = 0.3099892820671425; w( 7) = 0.2808792186638755; w( 8) = 0.2203174603174603; w( 9) = 0.1458749193773909; w(10) = 0.04293911957413078; else fprintf ( 1, '\n' ); fprintf ( 1, 'FEJER1_SET - Fatal error!\n' ); fprintf ( 1, ' Illegal value of N = %d\n', n ); fprintf ( 1, ' Legal values are 1 through 10.\n' ); error ( 'FEJER1_SET - Fatal error!' ); end return end