Legendre polynomials
legendreP(
returns
the n
,x
)n
th degree Legendre polynomial at x
.
Find the Legendre polynomial of degree 3
at 5.6
.
legendreP(3,5.6)
ans = 430.6400
Find the Legendre polynomial of degree 2
at x
.
syms x legendreP(2,x)
ans = (3*x^2)/2 - 1/2
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 legendreP(n,x)
ans = legendreP(n, x)
Find the Legendre polynomials of degrees 1
and 2
by
setting n = [1 2]
.
syms x legendreP([1 2],x)
ans = [ x, (3*x^2)/2 - 1/2]
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]; legendreP(n,xM)
ans = [ (3*x^4)/2 - 1/2, 2519/343] [ -16/5, (3*x^2)/2 - 1/2]
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 expr = legendreP(4,x); limit(expr,x,-Inf)
ans = Inf
Use diff
to find the third derivative of
the Legendre polynomial of degree 5
.
syms n expr = legendreP(5,x); diff(expr,x,3)
ans = (945*x^2)/2 - 105/2
Use taylor
to find the
Taylor series expansion of the Legendre polynomial of degree 2
at x
= 0
.
syms x expr = legendreP(2,x); taylor(expr,x)
ans = (3*x^2)/2 - 1/2
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 = -0.94910791234275852452618968404785 -0.74153118559939443986386477328079 -0.40584515137739716690660641207696 0 0.40584515137739716690660641207696 0.74153118559939443986386477328079 0.94910791234275852452618968404785
chebyshevT
| chebyshevU
| gegenbauerC
| hermiteH
| hypergeom
| jacobiP
| laguerreL