Showing posts with label Legendre polynomials. Show all posts
Showing posts with label Legendre polynomials. Show all posts

Sunday, December 25, 2011

Legendre functions (also associated) of the first and second kind in Maxima

In order to do Legendre functions in Maxima the command is

legendre_p(n, x)

where n is the degree of the polynomial.  For example, for the Legendre polynomial of the first kind of the 5th degree simply type legendre_p(5, x).


For the Legendre function of the second kind the command is

legendre_q(n, x)


For the associated Legendre functions where there is also an order, m, in addition to the degree, n, to specify. Remember that regular Legendre functions are just associated Legendre functions of order 0.

assoc_legendre_q(n, m, x)

assoc_legendre_q(n, m, x)


Here are some links to these commands and more special functions and orthogonal functions/polynomials.

http://www.ma.utexas.edu/maxima/maxima_16.html

Although this link^ has the regular Legendre function with an order which is not needed.  It is listed as

legendre_p(n, m, x)

where it should just be like it is posted above.

Friday, December 23, 2011

Legendre polynomials of the first kind, plots of degrees n = 0, 1, 2, 3, 4, 5

\( P_0 \left( x \right) = 1 \)


\( P_1 \left( x \right) = x \)


\( P_2 \left( x \right) = \dfrac{1}{2} \left( 3 x^2 - 1 \right) \)


\( P_3 \left( x \right) = \dfrac{1}{2} x \left( 5 x^2 - 3 \right) \)


\( P_4 \left( x \right) = \dfrac{1}{8} \left( 35 x^4 - 30 x^2 + 3 \right) \)


\( P_5 \left( x \right) = \dfrac{1}{8} x \left( 63 x^4 - 70 x^2 + 15 \right) \)





\( P_0 \left( x \right), P_1 \left( x \right), P_2 \left( x \right), P_3 \left( x \right), P_4 \left( x \right), P_5 \left( x \right) \)





Code for last graph in wxMaxima:

plot2d([legendre_p(0, x), legendre_p(1, x), legendre_p(2, x),legendre_p(3, x), 
legendre_p(4, x), legendre_p(5, x)], [x, -2, 2], [y, -2, 2], 
[legend,"P_0 (x) = 1","P_1 (x) = x","P_2 (x) = (1/2)*(3*x^2 - 1)",
"P_3 (x) = (1/2)*x*(5*x^2 - 3)","P_4 (x) = (1/8)*(35*x^4 - 30*x^2 + 3)",
"P_5 (x) = (1/8)*x*(63*x^4 - 70*x^2 + 15)" ], [ylabel,"P_n (x)"], [gnuplot_preamble,"set key bottom"]);

Legendre - DE, functions and polynomials of the first and second kind, associated Legendre functions

Legendre equation, function, and polynomial links (also contains properties and more).

http://mathworld.wolfram.com/LegendrePolynomial.html

http://mathworld.wolfram.com/LegendreDifferentialEquation.html

http://mathworld.wolfram.com/LegendreFunctionoftheFirstKind.html

http://mathworld.wolfram.com/LegendreFunctionoftheSecondKind.html

http://reference.wolfram.com/mathematica/tutorial/OrthogonalPolynomials.html

http://en.wikipedia.org/wiki/Legendre_polynomials

http://en.wikipedia.org/wiki/Legendre_function

The Legendre differential equation is of the form:

\[ \dfrac{\mathrm{d}}{\mathrm{d}x} \left[ \left( 1 - x^2 \right) \dfrac{\mathrm{d} F}{\mathrm{d}x} \right] + n \left( n + 1 \right) F \]

or

\[ \left( 1 - x^2 \right) F'' - 2 x F' + n \left( n + 1 \right) F = 0  \]

which has the general solution of

\[ C_1 P_n \left( x \right) + C_2 Q_n \left( x \right) \]

where \( P_n \left( x \right) \) is the Legendre function of the first kind, \( Q_n \left( x \right) \), and \( n \) is a non-negative integer which is also the degree of the Legendre polynomial.

A more general equation is the associated Legendre differential equation in the form of:

\[ \left( 1 - x^2 \right) F'' - 2 x F' + \left[ n \left( n + 1 \right) - \dfrac{m^2}{1 - x^2} \right] F = 0 \]

which has the general solution of

\[ C_1 P_n^m \left( x \right) + C_2 Q_n^m \left( x \right) \]

where \( P_n \left( x \right) \) is the associated Legendre function of the first kind, \( Q_n \left( x \right) \) is the associated Legendre function of the second kind, \( n \) is a non-negative integer, the degree of the Legendre polynomial, and \( m \) is also a non-negative integer which determines the degree of the Legendre functions/polynomials.

When the degree is zero, \( m = 0 \), the associated Legendre functions,  \( P_n^0 \left( x \right) \) and \( Q_n^0 \left( x \right) \), return the regular Legendre functions, \( P_n \left( x \right) \) and \( Q_n \left( x \right) \)

The Legendre DE can be solved by a power series expansion method also called the Frobenius method.

The difference between Legendre polynomials and functions is that when the \( n \)th-degree is an integer the Legendre function converges to a polynomial on the interval \( -1 \le x \le 1 \).

For associated Legendre functions of odd integers where \( m \le n \), the function contains \( \sqrt{1 - x^2} \) which demotes the function from a polynomial.

The Legendre equation usually arises in physics problems when the separation of variables method is applied the PDE Laplace's equation in spherical polar coordinates.

\[ \dfrac{1}{\sin \phi} \dfrac{\mathrm{d}}{\mathrm{d}\phi} \left( \sin \phi \dfrac{\mathrm{d} F}{\mathrm{d}\phi} \right) +  \left[ n \left( n + 1 \right) - \dfrac{m^2}{\sin^2 \phi} \right] F = 0 \]

Where \( \phi \) is the colatitudinal angle and the substitution \( x = \cos \phi \) recovers the previous Legendre equation version.