function x = gl_space ( a, b, n ); % % function x = gl_space ( a, b, n ) % % For 1 <= N <= 10, returns the weights W and abscissas X of an % N point Gauss-Legendre quadrature rule over the interval [-1,1]. % x = ones(1,n); if ( n == 1 ) x(1) = 0.0; elseif ( n == 2 ) x(1) = - 0.577350269189625764509148780502; x(2) = 0.577350269189625764509148780502; elseif ( n == 3 ) x(1) = - 0.774596669241483377035853079956; x(2) = 0.000000000000000; x(3) = 0.774596669241483377035853079956; elseif ( n == 4 ) x(1) = - 0.861136311594052575223946488893; x(2) = - 0.339981043584856264802665759103; x(3) = 0.339981043584856264802665759103; x(4) = 0.861136311594052575223946488893; elseif ( n == 5 ) x(1) = - 0.906179845938663992797626878299; x(2) = - 0.538469310105683091036314420700; x(3) = 0.0; x(4) = 0.538469310105683091036314420700; x(5) = 0.906179845938663992797626878299; elseif ( n == 6 ) x(1) = - 0.932469514203152027812301554494; x(2) = - 0.661209386466264513661399595020; x(3) = - 0.238619186083196908630501721681; x(4) = 0.238619186083196908630501721681; x(5) = 0.661209386466264513661399595020; x(6) = 0.932469514203152027812301554494; elseif ( n == 7 ) x(1) = - 0.949107912342758524526189684048; x(2) = - 0.741531185599394439863864773281; x(3) = - 0.405845151377397166906606412077; x(4) = 0.0; x(5) = 0.405845151377397166906606412077; x(6) = 0.741531185599394439863864773281; x(7) = 0.949107912342758524526189684048; elseif ( n == 8 ) x(1) = - 0.960289856497536231683560868569; x(2) = - 0.796666477413626739591553936476; x(3) = - 0.525532409916328985817739049189; x(4) = - 0.183434642495649804939476142360; x(5) = 0.183434642495649804939476142360; x(6) = 0.525532409916328985817739049189; x(7) = 0.796666477413626739591553936476; x(8) = 0.960289856497536231683560868569; elseif ( n == 9 ) x(1) = - 0.968160239507626089835576202904; x(2) = - 0.836031107326635794299429788070; x(3) = - 0.613371432700590397308702039341; x(4) = - 0.324253423403808929038538014643; x(5) = 0.0; x(6) = 0.324253423403808929038538014643; x(7) = 0.613371432700590397308702039341; x(8) = 0.836031107326635794299429788070; x(9) = 0.968160239507626089835576202904; elseif ( n == 10 ) x(1) = - 0.973906528517171720077964012084; x(2) = - 0.865063366688984510732096688423; x(3) = - 0.679409568299024406234327365115; x(4) = - 0.433395394129247290799265943166; x(5) = - 0.148874338981631210884826001130; x(6) = 0.148874338981631210884826001130; x(7) = 0.433395394129247290799265943166; x(8) = 0.679409568299024406234327365115; x(9) = 0.865063366688984510732096688423; x(10) = 0.973906528517171720077964012084; else ' ' 'GL_SPACE - Fatal error!' ' Illegal value of N.' end; % % Transform the X values from [-1,1] to [A,B]. % for i = 1 : n x(i) = ( ( 1.0 - x(i) ) * a + ( 1.0 + x(i) ) * b ) / 2.0; end