function [A,W]=Schwarz(n) % Schwarz算法求高斯-勒让德求积公式的节点和权系数 % Input - n 是公式中节点个数 % Output - A 是节点向量,按升序排列 % - W 是权系数,按A中对应顺序排列 % NUMERICAL METHODS: Matlab Programs % (c) 2007 by Xie Liling % Complementary Software to accompany the textbook: % Information and Computing Science: A Laboratory Course beta = (1:n-1)./sqrt(4*(1:n-1).^2-1); J = diag(beta,-1)+diag(beta,1); [V,D] = eig(J); [A,ix]=sort(diag(D)); V(:,1:n)=V(:,ix); W=2*V(1,ix)'.^2;