10.4 Orthogonal Polynomials

Module: sage.functions.orthogonal_polys

Orthogonal Polynomials

This module wraps some of the orthogonal/special functions in the Maxima package "orthopoly". This package was written by Barton Willis of the University of Nebraska at Kearney. It is released under the terms of the General Public License (GPL). Send Maxima-related bug reports and comments on this module to willisb@unk.edu. In your report, please include Maxima and specfun version information.

For completeness, the Pochhammer symbol, introduced by Leo August Pochhammer, $ (x)_n$ , is used in the theory of special functions to represent the "rising factorial" or "upper factorial"

$\displaystyle (x)_n=x(x+1)(x+2)\cdots(x+n-1)=\frac{(x+n-1)!}{(x-1)!}.
$

On the other hand, the "falling factorial" or "lower factorial" is

$\displaystyle x^{\underline{n}}=\frac{x!}{(x-n)!} ,
$

in the notation of Ronald L. Graham, Donald E. Knuth and Oren Patashnik in their book Concrete Mathematics.

Methods implemented: * chebyshev_T (n, x) - the Chebyshev polynomial of the first kind for integers n > -1. REFERENCE: A&S 22.5.31 page 778 and A&S 6.1.22 page 256. * chebyshev_U (n, x) - the Chebyshev polynomial of the second kind for integers n > -1. REFERENCE: A&S, 22.8.3 page 783 and A&S 6.1.22 page 256. * gen_laguerre (n, a, x) - the generalized Laguerre polynomial for integers n > -1. REFERENCE: table on page 789 in A&S. * gen_legendre_P (n, x) - the associated (or generalized) Legendre function of the first kind for integers n > -1. * gen_legendre_Q (n, x) - the associated (or generalized) Legendre function of the second kind for integers n > -1. REFERENCE: Gradshteyn and Ryzhik 8.706 page 1000. * hermite (n,x) - the Hermite polynomial for integers n > -1. REFERENCE: A&S 22.5.40 and 22.5.41, page 779. * jacobi_P (n, a, b, x) - the Jacobi polynomial for integers n > -1 and a and b symbolic or a > -1 and b > -1. REFERENCE: table on page 789 in A&S. * laguerre (n, x) - the generalized Laguerre polynomial for integers n > -1. REFERENCE: A&S 22.5.16, page 778 and A&S page 789. * legendre_P (n, x) - the Legendre polynomial of the first kind for integers n > -1. REFERENCE: A&S 22.5.35 page 779. * legendre_Q (n, x) - the Legendre function of the second kind for integers n > -1. * ultraspherical (n,a,x) - the ultraspherical polynomials for integers n > -1. The ultraspherical polynomials are also known as Gegenbauer polynomials. REFERENCE: A&S 22.5.27

NOTE: The first call of any of these will usually cost a bit extra (it loads "specfun", but I'm not sure if that is the real reason). The next call is usually faster but not always.

TODO: Implement associated Legendre polynomials and Zernike polynomials. (Neither is in Maxima.) http://en.wikipedia.org/wiki/Associated_Legendre_polynomials http://en.wikipedia.org/wiki/Zernike_polynomials

REFERENCES: * Abramowitz and Stegun: Handbook of Mathematical Functions, http://www.math.sfu.ca/ cbm/aands/ * http://en.wikipedia.org/wiki/Chebyshev_polynomials * http://en.wikipedia.org/wiki/Legendre_polynomials * http://en.wikipedia.org/wiki/Hermite_polynomials * http://mathworld.wolfram.com/GegenbauerPolynomial.html * http://en.wikipedia.org/wiki/Jacobi_polynomials * http://en.wikipedia.org/wiki/Laguerre_polynomia * http://en.wikipedia.org/wiki/Associated_Legendre_polynomials

Author: David Joyner (2006-06)

Module-level Functions

chebyshev_T( n, x)

Returns the Chebyshev function of the first kind for integers n > -1.

sage: x = PolynomialRing(QQ, 'x').gen()
sage: chebyshev_T(2,x)
2*x^2 - 1

chebyshev_U( n, x)

Returns the Chebyshev function of the second kind for integers n > -1.

sage: x = PolynomialRing(QQ, 'x').gen()
sage: chebyshev_U(2,x)
4*x^2 - 1

gegenbauer( n, a, x)

Returns the ultraspherical (or Gegenbauer) polynomial for integers n > -1.

Computed using Maxima.

sage: x = PolynomialRing(QQ, 'x').gen()
sage: ultraspherical(2,3/2,x)
15/2*x^2 - 3/2
sage: ultraspherical(2,1/2,x)
3/2*x^2 - 1/2
sage: ultraspherical(1,1,x)
2*x      
sage: t = PolynomialRing(RationalField(),"t").gen()
sage: gegenbauer(3,2,t)
32*t^3 - 12*t

gen_laguerre( n, a, x)

Returns the generalized Laguerre polynomial for integers n > -1. Typically, a = 1/2 or a = -1/2.

sage: x = PolynomialRing(QQ, 'x').gen()
sage: gen_laguerre(2,1,x)
1/2*x^2 - 3*x + 3
sage: gen_laguerre(2,1/2,x)
1/2*x^2 - 5/2*x + 15/8
sage: gen_laguerre(2,-1/2,x)
1/2*x^2 - 3/2*x + 3/8
sage: gen_laguerre(2,0,x)
1/2*x^2 - 2*x + 1
sage: gen_laguerre(3,0,x)
-1/6*x^3 + 3/2*x^2 - 3*x + 1

gen_legendre_P( n, m, x)

Returns the generalized (or associated) Legendre function of the first kind for integers $ n > -1, m > -1$ .

The awkward code for when m is odd and > 1 results from the fact that Maxima is happy with, for example, $ (1 - t^2)^3/2$ , but SAGE is not. For these cases the function is computed from the (m-1)-case using one of the recursions satisfied by the Legendre functions.

sage: P.<t> = QQ[]
sage: gen_legendre_P(2, 0, t)
3/2*t^2 - 1/2
sage: gen_legendre_P(2, 0, t) == legendre_P(2, t)
True
sage: gen_legendre_P(3, 1, t)
(3/2 - 15*t^2/2)*sqrt(1 - t^2)
sage: gen_legendre_P(4, 3, t) 
sqrt(1 - t^2)*(105*t^3 - 105*t)
sage: gen_legendre_P(7, 3, I).expand()
-16695*sqrt(2)
sage: gen_legendre_P(4, 1, 2.5)
-583.562373654533*I

gen_legendre_Q( n, m, x)

Returns the generalized (or associated) Legendre function of the second kind for integers n > -1, m > -1.

Maxima restricts m <= n. Hence the cases m > n are computed using the same recursion used for gen_legendre_P(n,m,x) when m is odd and > 1.

sage: P.<t> = QQ[]
sage: gen_legendre_Q(2,0,t)
(3*log((-t - 1)/(t - 1))*t^2 - 6*t - log((-t - 1)/(t - 1)))/4
sage: gen_legendre_Q(2,0,t) - legendre_Q(2, t)
0
sage: gen_legendre_Q(3,1,0.5)
2.49185259170895
sage: gen_legendre_Q(0, 1, x)
-1/sqrt(1 - x^2)
sage: gen_legendre_Q(2, 4, x).factor()
48*x/((x - 1)^2*(x + 1)^2)

hermite( n, x)

Returns the Hermite polynomial for integers $ n > -1$ .

sage: x = PolynomialRing(QQ, 'x').gen()
sage: hermite(2,x)
4*x^2 - 2
sage: hermite(3,x)
8*x^3 - 12*x
sage: hermite(3,2)
40
sage: S.<y> = PolynomialRing(RR)
sage: hermite(3,y)
8.00000000000000*y^3 - 12.0000000000000*y
sage: R.<x,y> = QQ[]
sage: hermite(3,y^2)
8*y^6 - 12*y^2
sage: w = var('w')
sage: hermite(3,2*w)
-24*w*(1 - 8*w^2/3)

jacobi_P( n, a, b, x)

Returns the Jacobi polynomial $ P_n^{(a,b)}(x)$ for integers $ n > -1$ and a and b symbolic or $ a > -1$ and $ b > -1$ . The Jacobi polynomials are actually defined for all a and b. However, the Jacobi polynomial weight $ (1-x)^a(1+x)^b$ isn't integrable for $ a \leq -1$ or $ b \leq -1$ .

sage: x = PolynomialRing(QQ, 'x').gen()
sage: jacobi_P(2,0,0,x)
3/2*x^2 - 1/2
sage: jacobi_P(2,1,2,1.2)        # random output of low order bits
5.009999999999998

laguerre( n, x)

Returns the Laguerre polynomial for integers $ n > -1$ .

sage: x = PolynomialRing(QQ, 'x').gen()
sage: laguerre(2,x)
1/2*x^2 - 2*x + 1
sage: laguerre(3,x)
-1/6*x^3 + 3/2*x^2 - 3*x + 1
sage: laguerre(2,2)
-1

legendre_P( n, x)

Returns the Legendre polynomial of the first kind for integers n > -1.

sage: P.<t> = QQ[]
sage: legendre_P(2,t)
3/2*t^2 - 1/2
sage: legendre_P(3, 1.1)
1.67750000000000
sage: legendre_P(3, 1 + I)
7*I/2 - 13/2
sage: legendre_P(3, MatrixSpace(ZZ, 2)([1, 2, -4, 7]))
[-179  242]
[-484  547]
sage: legendre_P(3, GF(11)(5))
8

legendre_Q( n, x)

Returns the Legendre function of the second kind for integers n > -1.

Computed using Maxima.

sage: P.<t> = QQ[]
sage: legendre_Q(2, t)
(3*log((-t - 1)/(t - 1))*t^2 - 6*t - log((-t - 1)/(t - 1)))/4
sage: legendre_Q(3, 0.5)
-0.198654771479482
sage: legendre_Q(4, 2)
(1329*log(-3) - 1460)/48
sage: legendre_Q(4, 2.0)
NaN

ultraspherical( n, a, x)

Returns the ultraspherical (or Gegenbauer) polynomial for integers n > -1.

Computed using Maxima.

sage: x = PolynomialRing(QQ, 'x').gen()
sage: ultraspherical(2,3/2,x)
15/2*x^2 - 3/2
sage: ultraspherical(2,1/2,x)
3/2*x^2 - 1/2
sage: ultraspherical(1,1,x)
2*x      
sage: t = PolynomialRing(RationalField(),"t").gen()
sage: gegenbauer(3,2,t)
32*t^3 - 12*t

See About this document... for information on suggesting changes.