{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# jags - J =diag(dm diag(ds,1 diag(ds-1 Create Jacobi matrix...

This preview shows page 1. Sign up to view the full content.

function [varargout]=jags(n,alp,bet); % The function x=jags(n,alp,bet) computes the n nodes % Jacobi-Gauss quadrature, with parameter (alp,bet) % by using eigenvalue method for nodes. % The function [x,w]=jags(n, alp, bet) also returns weights (stored in w). apb=alp+bet; id=[0:n-1]; % Indices if alp==bet, dm=zeros(size(id)); else dm=(bet^2-alp^2)./((2*id+apb).*(2*id+apb+2)); % Create maindiagnal end; id=[1:n-1]; % Indices ds=4*id.*(id+alp).*(id+bet).*(id+apb)./((2*id+apb-1).*(2*id+apb).^2.*(2*id+apb+1)); % Create subdiagonals ds=sqrt(ds);
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: J =diag(dm)+diag(ds,1)+diag(ds,-1); % Create Jacobi matrix x= sort(eig(sparse(J))); % Compute eigenvalues if nargout==1, varargout{1}=x; % Return nodes return; end; if nargout==2, varargout{1}=x; % Return nodes gn=(apb+1)*log(2)+gammaln(n+alp+1)+gammaln(n+bet+1)-gammaln(n+1)-gammaln(n+apb+1); gn=exp(gn); % Constant in the weight expression [dy,y]=japoly(n,alp,bet,x); % Compute derivative of Jacobi polynomial of degree n % at nodes varargout{2}=gn./((1-x.^2).*dy.^2) % Compute weights by using weight expression. end;...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online