主要内容

legendreP

勒让德多项式

说明

y = legendreP(n,x) 返回在 x 处的 n勒让德多项式

示例

示例

全部折叠

5.6 处的 3 次勒让德多项式。

y = legendreP(3,5.6)
y = 
430.6400

x 处的 2 次勒让德多项式。

syms x
y = legendreP(2,x)
y = 

3x22-12

如果您未为次数 n 指定数值,legendreP 函数便无法求出多项式的显式形式,并且将返回函数调用。

syms n
y = legendreP(n,x)
y = legendreP(n,x)

通过设置 n = [1 2]1 次和 2 次勒让德多项式。

syms x
y = legendreP([1 2],x)
y = 

(x3x22-12)

legendrePn 按元素进行操作,返回包含两个元素的向量。

如果将多个输入指定为向量、矩阵或多维数组,则这些输入的大小必须相同。求输入参量 nx 均为矩阵时的勒让德多项式。

n = [2 3; 1 2];
xM = [x^2 11/7; -3.2 -x];
yM = legendreP(n,xM)
yM = 

(3x42-122519343-1653x22-12)

legendrePnx 按元素进行操作,返回与 nx 大小相同的矩阵。

使用 limit3 次勒让德多项式在 x 趋于 - 时的极限。

syms x
P3 = legendreP(3,x);
P3 = limit(P3,x,-Inf)
P3 = -

使用 diff5 次勒让德多项式的三阶导数。

P5 = legendreP(5,x);
D3P5 = diff(P5,x,3)
D3P5 = 

945x22-1052

使用 taylor2 次勒让德多项式在 x = 0 处的泰勒级数展开。

syms x
y = legendreP(2,x)
y = 

3x22-12

t = taylor(y,x)
t = 

3x22-12

绘制 1 次到 4 次勒让德多项式。

syms x y
fplot(legendreP(1:4, x))
axis([-1.5 1.5 -1 1])
grid on

ylabel('P_n(x)')
title('Legendre polynomials of degrees 1 through 4')
legend('1','2','3','4','Location','best')

Figure contains an axes object. The axes object with title Legendre polynomials of degrees 1 through 4, ylabel P indexOf n baseline (x) contains 4 objects of type functionline. These objects represent 1, 2, 3, 4.

使用 vpasolve7 次勒让德多项式的根。

syms x
roots = vpasolve(legendreP(7,x) == 0)
roots = 

(-0.94910791234275852452618968404785-0.74153118559939443986386477328079-0.4058451513773971669066064120769600.405845151377397166906606412076960.741531185599394439863864773280790.94910791234275852452618968404785)

输入参数

全部折叠

多项式的次数,指定为非负数、向量、矩阵、多维数组、符号数、符号向量、符号矩阵、符号函数或符号多维数组。非标量输入的所有元素均应为非负整数或符号。

输入,指定为数字、向量、矩阵、多维数组、符号数、符号向量、符号矩阵、符号函数或符号多维数组。

输出参量

全部折叠

勒让德多项式,以数字、向量、矩阵、多维数组、符号数、符号向量、符号矩阵、符号函数或符号多维数组形式返回。

详细信息

全部折叠

版本历史记录

在 R2014b 中推出