LegendreP
Details
- Mathematical function, suitable for both symbolic and numerical manipulation.
- Explicit formulas are given for integers n and m.
- The Legendre polynomials satisfy the differential equation
. - The Legendre polynomials are orthogonal with unit weight function.
- The associated Legendre polynomials are defined by
. - For arbitrary complex values of n, m, and z, LegendreP[n,z] and LegendreP[n,m,z] give Legendre functions of the first kind.
- LegendreP[n,m,a,z] gives Legendre functions of type a. The default is type 1.
- The symbolic form of type 1 involves
, of type 2 involves
, and of type 3 involves
. - Type 1 is defined only for
within the unit circle in the complex plane. Type 2 represents an analytic continuation of type 1 outside the unit circle. - Type 2 functions have branch cuts from
to
and from
to
in the complex
plane. - Type 3 functions have a single branch cut from
to
. - LegendreP[n,m,a,z] is defined to be Hypergeometric2F1Regularized[-n,n+1,1-m,(1-z)/2] multiplied by
for type 2 and by
for type 3. - For certain special arguments, LegendreP automatically evaluates to exact values.
- LegendreP can be evaluated to arbitrary numerical precision.
- LegendreP automatically threads over lists.
- LegendreP can be used with Interval and CenteredInterval objects. »
Examples
open all close allBasic Examples (6)
LegendreP[2.5, 2]Compute the
Legendre polynomial:
LegendreP[10, x]Plot over a subset of the reals:
Plot[LegendreP[1 / 2, x], {x, -1, 1}]Plot over a subset of the complexes:
ComplexPlot3D[LegendreP[1 / 2, z], {z, -2 - 2I, 2 + 2I}, PlotLegends -> Automatic]Series expansion at the origin:
Series[LegendreP[1 / 2, x], {x, 0, 2}]Asymptotic expansion at Infinity:
Series[LegendreP[1 / 2, x], {x, ∞, 3}]//Normal//FullSimplifyScope (50)
Numerical Evaluation (7)
Evaluate numerically at fixed points:
{LegendreP[2, 2], LegendreP[2, 2, 2], LegendreP[1.5, 2]}N[LegendreP[3 / 2, 2], 50]The precision of the output tracks the precision of the input:
LegendreP[3 / 2, 2.000000000000000000000000000]Evaluate for complex orders and arguments:
LegendreP[3 / 2 + I, 1.5 - I]Evaluate LegendreP efficiently at high precision:
LegendreP[3 / 2, 2`300]//TimingLegendreP[3 / 2, 2`3000];//TimingLegendreP can deal with real-valued intervals:
LegendreP[3, Interval[{-0.5, 0.5}]]Compute worst-case guaranteed intervals using Interval and CenteredInterval objects:
LegendreP[1 / 2, 2 / 3, Interval[{0.4, 0.5}]]LegendreP[1 / 2, CenteredInterval[2, 1 / 100]]LegendreP[1 / 2, 2 / 3, CenteredInterval[2, 1 / 100]]Or compute average-case statistical intervals using Around:
LegendreP[2, Around[3, 0.5]]Compute the elementwise values of an array:
LegendreP[1, {{5 / 6, 0}, {1 / 2, -1 / 3}}]Or compute the matrix LegendreP function using MatrixFunction:
MatrixFunction[LegendreP[2, #]&, {{5 / 6, 0}, {1 / 2, -1 / 3}}]Specific Values (5)
Legendre polynomial for symbolic
:
LegendreP[n, 0]//FunctionExpandLegendreP[n, 1]Find a local maximum as a root of
:
xmax = Solve[D[LegendreP[5, x], x] == 0 && 0 < x < 0.5, x][[1, 1, 2]]Plot[LegendreP[5, x], {x, -1, 1}, Epilog -> Style[Point[{xmax, LegendreP[5, xmax]}], PointSize[Large], Red]]Compute the associated Legendre polynomial
:
LegendreP[10, 2, x]Compute an associated Legendre polynomial for half-integer
and
:
LegendreP[3 / 2, 1 / 2, x]Different LegendreP types give different symbolic forms:
Table[LegendreP[2, 1, a, z], {a, 1, 3}]Visualization (3)
Plot the LegendreP function for various orders:
Plot[{LegendreP[1, x], LegendreP[2, x], LegendreP[3, x], LegendreP[4, x]}, {x, -1, 1}]ComplexContourPlot[Re[LegendreP[3, z]], {z, -3 - 3 I, 3 + 3 I}, IconizedObject[«PlotOptions»]]ComplexContourPlot[Im[LegendreP[3, z]], {z, -3 - 3 I, 3 + 3 I}, IconizedObject[«PlotOptions»]]Type 2 and 3 of Legendre functions have different branch cut structures:
Plot3D[Im[LegendreP[2, 1, 2, x + I y]], {x, -1.5, 1.5}, {y, -0.5, 0.5}, Exclusions -> {{y == 0, Abs[x] > 1}}]Plot3D[Im[LegendreP[2, 1, 3, x + I y]], {x, -1.5, 1.5}, {y, -0.5, 0.5}, Exclusions -> {{y == 0, -1 < x < 1}}]Function Properties (12)
is defined for all
for integer
and for
for noninteger
:
FunctionDomain[LegendreP[n, z], z]In the complex plane, it is defined for
when
is not an integer:
FunctionDomain[LegendreP[n, z], z, Complexes]The associated Legendre function
is additionally undefined at
when
is not an even integer:
FunctionDomain[LegendreP[n, m, z], z, Complexes]The range for Legendre polynomials of integer orders:
{FunctionRange[LegendreP[1, x], x, y], FunctionRange[LegendreP[2, x], x, y], FunctionRange[LegendreP[3, x], x, y], FunctionRange[LegendreP[4, x], x, y]}The range for complex values is the whole plane:
{FunctionRange[LegendreP[1, z], z, y, Complexes], FunctionRange[LegendreP[2, z], z, y, Complexes], FunctionRange[LegendreP[3, z], z, y, Complexes], FunctionRange[LegendreP[4, z], z, y, Complexes]}Legendre polynomial of an odd order is odd:
LegendreP[1, -x] == -LegendreP[1, x]Legendre polynomial of an even order is even:
LegendreP[2, -x] == LegendreP[2, x]Legendre polynomials have the mirror property
:
{LegendreP[1, Conjugate[z]] == Conjugate[LegendreP[1, z]], LegendreP[2, Conjugate[z]] == Conjugate[LegendreP[2, z]]}
is an analytic function of
for integer
:
FunctionAnalytic[LegendreP[n, x], x, Assumptions -> n∈ℤ]It is neither analytic nor meromorphic for noninteger
:
FunctionAnalytic[LegendreP[1 / 2, x], x]FunctionMeromorphic[LegendreP[1 / 2, x], x]The associated Legendre function
is analytic as long as
is also an even integer:
FunctionAnalytic[LegendreP[n, m, x], x, Assumptions -> {n, (m/2)}∈ℤ]
is neither non-decreasing nor non-increasing for integers
:
Table[FunctionMonotonicity[LegendreP[n, x], x], {n, 0, 5}]
is neither non-decreasing nor non-increasing for integers
:
Table[FunctionInjective[LegendreP[n, x], x], {n, 5}]Plot[{LegendreP[2, x], LegendreP[3, x], LegendreP[4, x], 1 / 4}, {x, -2, 2}, PlotRange -> 1]
is surjective for positive odd integer values of
but not even values:
Table[FunctionSurjective[LegendreP[n, x], x], {n, 4}]Plot[{LegendreP[1, x], LegendreP[2, x], LegendreP[3, x], LegendreP[4, x], -1}, {x, -2, 2}, PlotRange -> 2]LegendreP is neither non-negative nor non-positive:
Table[FunctionSign[LegendreP[n, x], x], {n, 4}]
has no singularities or discontinuities when
is an integer:
FunctionSingularities[LegendreP[n, x], x]FunctionDiscontinuities[LegendreP[n, x], x]The associated Legendre function
has additional singularities when
is not an even integer:
FunctionSingularities[LegendreP[n, m, x], x]
is neither non-decreasing nor non-increasing for integers
:
Table[FunctionConvexity[LegendreP[n, x], x], {n, 5}]Differentiation (3)
D[LegendreP[n, x], x]derivs = Table[D[LegendreP[n, x], {x, l}], {l, 1, 4}]//FullSimplifyPlot[Evaluate[derivs /. n -> 5], {x, -1, 1}, PlotRange -> {-50, 50}, PlotLegends -> {"First Derivative", "Second Derivative", "Third Derivative", "Fourth Derivative"}]D[LegendreP[n, x], {x, l}]Integration (3)
Indefinite integral of LegendreP:
Integrate[LegendreP[n, x], x]Indefinite integral of an algebraic function with
:
Integrate[(1 - x^2)^(-3 - n/2)LegendreP[n, x], x]Integrate[LegendreP[n, x], {x, -1, 1}]Series Expansions (4)
Series[LegendreP[n, x], {x, 0, 5}]//FullSimplifyPlot the first three approximations for
at
:
terms = Normal@Table[Series[LegendreP[7, x], {x, 0, m}], {m, 1, 5, 2}];
Plot[{LegendreP[7, x], terms}, {x, -1, 1}, PlotRange -> {-1, 1}]General term in the series expansion of
:
SeriesCoefficient[LegendreP[n, x], {x, 0, l}]//FullSimplifyTaylor expansion for the associated Legendre polynomial
:
Series[LegendreP[n, m, x], {x, 0, 1}]//FullSimplifyLegendreP can be applied to a power series:
LegendreP[3 / 2, 1 / 2, Sin[x] + O[x] ^ 5]Integral Transforms (4)
The Fourier transform of a Legendre polynomial with order
using FourierTransform:
FourierTransform[LegendreP[2, t], t, ω ]The Laplace transform of a Legendre polynomial with order
using LaplaceTransform:
LaplaceTransform[LegendreP[3, t], t, s ]The Mellin transform of a Legendre polynomial with order
using MellinTransform:
MellinTransform[LegendreP[3, x], x, s ]The Hankel transform of a Legendre polynomial with order
using HankelTransform:
HankelTransform[LegendreP[1, x], x, s ]Function Identities and Simplifications (4)
LegendreP may reduce to simpler functions:
LegendreP[(3/4), (1/4), 2, x]//TogetherAssociated Legendre polynomials in terms of ordinary Legendre polynomials:
FullSimplify[(-1)^m(1 - x^2)^m / 2D[LegendreP[n, x], {x, m}], Element[m, Integers]]Sum[LegendreP[n, x]t^n, {n, 0, Infinity}](n + 1) LegendreP[n + 1, z] == (2 n + 1) z LegendreP[n, z] - n LegendreP[n - 1, z]//FullSimplifyFunction Representations (5)
Representation in terms of MeijerG:
LegendreP[n, x] == -(1/π)Limit[Sin[π ν]MeijerG[{{ν + 1, -ν}, {}}, {{0}, {0}}, (x - 1/2)], ν -> n]//FullSimplifyLegendreP can be expressed as a DifferentialRoot:
DifferentialRootReduce[LegendreP[n, x], x]SphericalHarmonicY uses associated Legendre function in its definition:
FullSimplify[SphericalHarmonicY[n, m, θ, ϕ] == Sqrt[(2n + 1) / (4π)]Sqrt[(n - m)! / (n + m)!]LegendreP[n, m, Cos[θ]]Exp[I m ϕ], Element[m, Integers] && -n ≤ m ≤ n]//PowerExpandAssociated Legendre polynomials in terms of the angular spheroidal function:
SpheroidalPS[n, m, 0, z]//FullSimplifyTraditionalForm formatting:
LegendreP[n, z]//TraditionalFormLegendreP[n, m, z]//TraditionalFormGeneralizations & Extensions (3)
LegendreP can deal with real-valued intervals:
LegendreP[3, Interval[{-1, 1}]]Different LegendreP types give different symbolic forms:
LegendreP[2, 1, 1, z]LegendreP[2, 1, 2, z]LegendreP[2, 1, 3, z]Types 2 and 3 have different branch cut structures:
Plot3D[Im[LegendreP[2, 1, 2, x + I y]], {x, -1.5, 1.5}, {y, -0.5, 0.5}, Exclusions -> {{y == 0, Abs[x] > 1}}]Plot3D[Im[LegendreP[2, 1, 3, x + I y]], {x, -1.5, 1.5}, {y, -0.5, 0.5}, Exclusions -> {{y == 0, -1 < x < 1}}]Applications (5)
Angular momentum eigenfunctions:
DSolve[Sin[θ] D[Sin[θ] f'[θ], θ] - m^2f[θ] == -λ(λ + 1)Sin[θ]^2f[θ], f[θ], θ]The Pöschl–Teller potential is a special class of potentials for which the one-dimensional Schrödinger equation can be solved in terms of special functions.
Find quantum eigenfunctions for the modified Pöschl–Teller potential:
DSolve[-f''[x] - j(j + 1) / Cosh[x] ^ 2 f[x] == -n ^ 2 f[x], f[x], x]A
-analog of the Legendre polynomial can be defined in terms of QHypergeometricPFQ:
qLegendreP[n_, θ_, q_] := QHypergeometricPFQ[{q^-n, q^n + 1, q^1 / 4E^I θ, q^1 / 4E^-I θ}, {q, -q, -q^1 / 2}, q, q]qLegendreP[2, θ, q]//FunctionExpand//ExpToTrig//SimplifyRecover the Legendre polynomial as
:
Limit[%, q -> 1]LegendreP[2, Cos[θ]]//SimplifyGeneralized Fourier transform for functions on the interval -1 to 1:
Table[(n + 1 / 2)Integrate[LegendreP[n, x]Sin[Pi x], {x, -1, 1}], {n, 0, 3}]Plot[ {Sin[Pi x], %.Table[LegendreP[n - 1, x], {n, Length[%]}]}, {x, -1, 1}]An n-point Gaussian quadrature rule is based on the roots of the n
-order Legendre polynomial. Compute the nodes and weights of an n-point Gaussian quadrature rule:
n = 9;
lp[x_] = LegendreP[n, x];
gaussNodes = x /. NSolve[lp[x], x]w1 = x |-> (2/n LegendreP[n - 1, x]lp'[x]);
gaussWeights = w1[gaussNodes]Use the n-point Gaussian quadrature rule to numerically evaluate an integral:
fun[x_] := (1/1 / 100 + (x - 3 / 10)^2) + (1/1 / 25 + (x - 9 / 10)^2) - 6a = 1 / 2;b = 1;
est1 = ((b - a/2)gaussWeights).Map[fun, Rescale[gaussNodes, {-1, 1}, {a, b}]]Compare the result of the Gaussian quadrature with the result from NIntegrate:
est1 - NIntegrate[fun[x], {x, a, b}]Properties & Relations (4)
Use FunctionExpand to expand into simpler functions:
FunctionExpand[LegendreP[(3/4), (1/4), 2, x]]LegendreP can be expressed as a DifferenceRoot:
DifferenceRootReduce[LegendreP[k, y, z], k]DifferenceRootReduce[LegendreP[2, 2, k], k]The generating function for LegendreP:
GeneratingFunction[LegendreP[n, k], n, x]The exponential generating function for LegendreP:
ExponentialGeneratingFunction[LegendreP[n, k], n, x]Possible Issues (1)
Neat Examples (3)
Visualize distribution of zeros:
ListPlot[Flatten[Table[{n, x} /. NSolve[LegendreP[n, x] == 0, x], {n, 1, 40}], 1], Axes -> False, Frame -> True]Generalized Lissajous figures:
ParametricPlot[ {LegendreP[7, x], LegendreP[13, x]}, {x, -1, 1}]An expression for the Legendre polynomial in terms of the Hilbert matrix:
myLegendre[n_, x_] := (-1)^nBinomial[2n, n]FromDigits[Prepend[Reverse[LinearSolve[HilbertMatrix[n], -(1/Range[n + 1, 2n])]], 1], (1 - x/2)]Verify the expression for the first few cases:
Table[myLegendre[n, x] == LegendreP[n, x]//Simplify, {n, 20}]See Also
LegendreQ SphericalHarmonicY SpheroidalPS GegenbauerC JacobiP
Function Repository: EpsteinHubbellOmega
Tech Notes
Related Links
History
Introduced in 1988 (1.0) | Updated in 1996 (3.0) ▪ 2003 (5.0) ▪ 2021 (13.0) ▪ 2022 (13.1)
Text
Wolfram Research (1988), LegendreP, Wolfram Language function, https://reference.wolfram.com/language/ref/LegendreP.html (updated 2022).
CMS
Wolfram Language. 1988. "LegendreP." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/LegendreP.html.
APA
Wolfram Language. (1988). LegendreP. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LegendreP.html
BibTeX
@misc{reference.wolfram_2026_legendrep, author="Wolfram Research", title="{LegendreP}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/LegendreP.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_legendrep, organization={Wolfram Research}, title={LegendreP}, year={2022}, url={https://reference.wolfram.com/language/ref/LegendreP.html}, note=[Accessed: 12-June-2026]}