legndr.m
来自「matlab的数学物理方程数值算法源程序。这是"Numerical Method」· M 代码 · 共 17 行
M
17 行
function p = legndr(n,x)
% Legendre polynomials function
% Inputs
% n = Highest order polynomial returned
% x = Value at which polynomial is evaluated
% Output
% p = Vector containing P(x) for order 0,1,...,n
%* Perform upward recursion
p(1)=1; % P(x) for n=0
if(n == 0) return; end
p(2)=x; % P(x) for n=1
for i=3:n+1 % Use upward recursion to obtain other n's
p(i) = ((2*i-3)*x*p(i-1) - (i-2)*p(i-2))/(i-1);
end
return;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?