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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)