Corrected function legendre p 584 …
Corrected function legendre p 584
function [x,w] = legendre(n) % [x,w]=LEGENDRE(n) computes the nodes nd weights in the % Gauss-Legendre quadrature rule with n+1 nodes (n>1) % in the interval [-1,1]. gamma = 1./sqrt(4 - [1:n].^(-2)); gamma(n+1) = 0; b0 = gamma(1:2:n+1); % error #1 removed "(1)" b1 = gamma(2:2:n); % error #2 removed "(k)" B = diag(b0,0) + diag(b1,1); [P,S,Q] = svd(B); x = diag(S); [x,i] = sort(x); w = Q(1,i).^2; % error #3 Should be "Q" not "P" N = length(x); if (rem(n,2) == 0) w(1) = 2*w(1); end
Published May 5, 2010 2:23 PM
- Last modified May 28, 2010 12:57 PM