legendreP
Legendre polynomials
Syntax
Description
returns the y = legendreP(n,x)nth degree Legendre
polynomial at x.
Examples
Find the Legendre polynomial of degree 3 at 5.6.
y = legendreP(3,5.6)
y = 430.6400
Find the Legendre polynomial of degree 2 at x.
syms x
y = legendreP(2,x)y =
If you do not specify a numerical value for the degree n, the legendreP function cannot find the explicit form of the polynomial and returns the function call.
syms n
y = legendreP(n,x)y =
Find the Legendre polynomials of degrees 1 and 2 by setting n = [1 2].
syms x
y = legendreP([1 2],x)y =
legendreP acts element-wise on n to return a vector with two elements.
If multiple inputs are specified as a vector, matrix, or multidimensional array, the inputs must be the same size. Find the Legendre polynomials where input arguments n and x are matrices.
n = [2 3; 1 2]; xM = [x^2 11/7; -3.2 -x]; yM = legendreP(n,xM)
yM =
legendreP acts element-wise on n and x to return a matrix of the same size as n and x.
Use limit to find the limit of a Legendre polynomial of degree 3 as x tends to .
syms x
P3 = legendreP(3,x);
P3 = limit(P3,x,-Inf)P3 =
Use diff to find the third derivative of the Legendre polynomial of degree 5.
P5 = legendreP(5,x); D3P5 = diff(P5,x,3)
D3P5 =
Use taylor to find the Taylor series expansion of the Legendre polynomial of degree 2 at x = 0.
syms x
y = legendreP(2,x)y =
t = taylor(y,x)
t =
Plot Legendre polynomials of orders 1 through 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')

Use vpasolve to find the roots of the Legendre polynomial of degree 7.
syms x
roots = vpasolve(legendreP(7,x) == 0)roots =
Input Arguments
Degree of polynomial, specified as a nonnegative number, vector, matrix, multidimensional array, or a symbolic number, vector, matrix, function, or multidimensional array. All elements of nonscalar inputs should be nonnegative integers or symbols.
Input, specified as a number, vector, matrix, multidimensional array, or a symbolic number, vector, matrix, function, or multidimensional array.
Output Arguments
Legendre polynomial, returned as a number, vector, matrix, multidimensional array, or a symbolic number, vector, matrix, function, or multidimensional array.
More About
The Legendre polynomials are defined as
The Legendre polynomials satisfy the recursion formula
The Legendre polynomials are orthogonal on the interval [-1,1] with respect to the weight function w(x) = 1, where
The relation with Gegenbauer polynomials G(n,a,x) is
The relation with Jacobi polynomials P(n,a,b,x) is
Version History
Introduced in R2014b
See Also
chebyshevT | chebyshevU | gegenbauerC | hermiteH | hypergeom | jacobiP | laguerreL
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)