herdif.m

来自「matlab6矩阵微分工具 matlab6矩阵微分工具」· M 代码 · 共 40 行

M
40
字号
function [x, DM] = herdif(N, M, b);%  The function [x, DM] = herdif(N, M, b) computes the%  differentiation matrices D1, D2, ..., DM on Hermite points.%%  Input:%  N:    Number of points, i.e., order of differentiation matrices (integer).%  M:    Number of derivatives required (integer).%  b:    Scaling parameter (real, positive).%%  Note:  0 < M < N-1.%%  Output:%  x:    Vector of nodes (zeros of Hermite polynomial of degree N,%        scaled by the parameter b.)%  DM:   DM(1:N,1:N,l) contains l-th derivative matrix, l=1..M.%  J.A.C Weideman, S.C. Reddy 1998.x = herroots(N);                      % Compute Hermite roots.alpha = exp(-x.^2/2);                 % Compute weights.beta(1,:) = ones(size(x'));           % Set up beta matrix s.t. beta(l,j) =beta(2,:) = -x';                      % (l-th derivative of alpha(x))/alpha(x),                                      % evaluated at x = x(j).for ell = 3:M+1                          beta(ell,:) = -x'.*beta(ell-1,:)-(ell-2)*beta(ell-2,:);endbeta(1,:) = [];                       % Remove initializing row from betaDM = poldif(x, alpha, beta);          % Compute differentiation matrix (b=1).x = x/b;                              % Scale nodes by the factor b.for ell = 1:M                         % Adjust for b not equal to 1. DM(:,:,ell) = (b^ell)*DM(:,:,ell);end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?