Go to the first, previous, next, last section, table of contents.


Orthogonal Polynomials

Introduction to Orthogonal Polynomials

The specfun package contains Maxima code for the evaluation of all orthogonal polynomials listed in Chapter 22 of Abramowitz and Stegun. These include Chebyshev, Laguerre, Hermite, Jacobi, Legendre, and ultraspherical (Gegenbauer) polynomials. Additionally, specfun contains code for spherical Bessel, spherical Hankel, and spherical harmonic functions. The specfun package is not part of Maxima proper; it is loaded at request of the user via load or automatically via the autoload system.

The following table lists each function in specfun, its Maxima name, restrictions on its arguments, and a reference to the algorithm specfun uses to evaluate it. With few exceptions, specfun follows the conventions of Abramowitz and Stegun. In all cases, m and n must be integers.

A&S refers to Abramowitz and Stegun, Handbook of Mathematical Functions (10th printing, December 1972), G&R to Gradshteyn and Ryzhik, Table of Integrals, Series, and Products (1980 corrected and enlarged edition), and Merzbacher to Quantum Mechanics (second edition, 1970).

Function Chebyshev T Chebyshev U generalized Laguerre Laguerre Hermite Jacobi associated Legendre P associated Legendre Q Legendre P Legendre Q spherical Hankel 1st spherical Hankel 2nd spherical Bessel J spherical Bessel Y spherical harmonic ultraspherical (Gegenbauer)
Maxima Name Restrictions Reference(s)
chebyshev_t(n, x) n > -1 A&S 22.5.31
chebyshev_u(n, x) n > -1 A&S 22.5.32
gen_laguerre(n,a,x) n > -1 A&S page 789
laguerre(n,x) n > -1 A&S 22.5.67
hermite(n,x) n > -1 A&S 22.4.40, 22.5.41
jacobi_p(n,a,b,x) n > -1, a, b > -1 A&S page 789
assoc_legendre_p(n,m,x) n > -1 A&S 22.5.37, 8.6.6, 8.2.5
assoc_legendre_q(n,m,x) n > -1, m > -1 G & R 8.706
legendre_p(n,m,x) n > -1 A&S 22.5.35
legendre_q(n,m,x) n > -1 A&S 8.6.19
spherical_hankel1(n, x) n > -1 A&S 10.1.36
spherical_hankel2(n, x) n > -1 A&S 10.1.17
spherical_bessel_j(n,x) n > -1 A&S 10.1.8, 10.1.15
spherical_bessel_y(n,x) n > -1 A&S 10.1.9, 10.1.15
spherical_harmonic(n,m,x,y) n > -1, |m| <= n Merzbacher 9.64
ultraspherical(n,a,x) n > -1 A&S 22.5.27
The specfun package is primarily intended for symbolic computation. It is hoped that it gives accurate floating point results as well; however, no claims are made that the algorithms are well suited for numerical evaluation. Some effort, however, has been made to provide good numerical performance. When all arguments, except for the order, are floats (but not bigfloats), many functions in specfun call a float modedeclared version of the Jacobi function. This greatly speeds floating point evaluation of the orthogonal polynomials. specfun handles most domain errors by returning an unevaluated function. No simplification rules (based on recursion relations) are defined for unevaluated functions. It is possible for an expression involving sums of unevaluated special functions to vanish, yet Maxima is unable to reduce it to zero. load ("specfun") loads the specfun package. Alternatively, setup_autoload causes the package to be loaded when one of the specfun functions appears in an expression. setup_autoload may appear at the command line or in the maxima-init.mac file. See setup_autoload. An example use of specfun is
(%i1) load ("specfun")$
(%i2) [hermite (0, x), hermite (1, x), hermite (2, x)];
                                         2
(%o2)               [1, 2 x, - 2 (1 - 2 x )]
(%i3) diff (hermite (n, x), x);
(%o3)                 2 n hermite(n - 1, x)
Generally, compiled code runs faster than translated code; however, translated code may be better for program development. Some functions (namely jacobi_p, ultraspherical, chebyshev_t, chebyshev_u, and legendre_p), return a series representation when the order is a symbolic integer. The series representation is not used by specfun for any computations, but it may be simplified by Maxima automatically, or it may be possible to use the series to evaluate the function through further manipulations. For example:
(%i1) load ("specfun")$
(%i2) legendre_p (n, x);
(%o2)                   legendre_p(n, x)
(%i3) ultraspherical (n, 3/2, 2);
             genfact(3, n, - 1) jacobi_p(n, 1, 1, 2)
(%o3)        ---------------------------------------
                       genfact(2, n, - 1)
(%i4) declare (n, integer)$
(%i5) legendre_p (n, x);
       n - 1
       ====
       \                                                 n - i%
(%o5) ( >     binomial(n, i%) binomial(n, n - i%) (x - 1)
       /
       ====
       i% = 1

                                    i%          n          n   n
                             (x + 1)   + (x + 1)  + (x - 1) )/2
(%i6) ultraspherical (n, 3/2, 2);
                          n - 1
                          ====
                          \       i%
(%o6) genfact(3, n, - 1) ( >     3   binomial(n + 1, i%)
                          /
                          ====
                          i% = 1

                                    n
 binomial(n + 1, n - i%) + (n + 1) 3  + n + 1)

                      n
/(genfact(2, n, - 1) 2 )
The first and last terms of the sum are added outside the summation. Removing these two terms avoids Maxima bugs associated with 0^0 terms in a sum that should evaluate to 1, but evaluate to 0 in a Maxima summation. Because the sum index runs from 1 to n - 1, the lower sum index will exceed the upper sum index when n = 0; setting sumhack to true provides a fix. For example:
(%i1) load ("specfun")$
(%i2) declare (n, integer)$
(%i3) e: legendre_p(n,x)$
(%i4) ev (e, sum, n=0);
Lower bound to sum: 1
is greater than the upper bound: - 1
 -- an error.  Quitting.  To debug this try debugmode(true);
(%i5) ev (e, sum, n=0, sumhack=true);
(%o5)                           1
Most functions in specfun have a gradef property; derivatives with respect to the order or other function parameters are undefined, and an attempt to compute such a derivative yields an error message. The specfun package and its documentation were written by Barton Willis of the University of Nebraska at Kearney. It is released under the terms of the General Public License (GPL). Send bug reports and comments on this package to willisb@unk.edu. In your report, please include the Maxima version, as reported by build_info(), and the specfun version, as reported by get ('specfun, 'version).

Definitions for Orthogonal Polynomials

Function: assoc_legendre_p (n, m, x)
Returns the associated Legendre function of the first kind for integers n > -1 and m > -1. When | m | > n and n >= 0, we have assoc_legendre_p (n, m, x) = 0. Reference: A&S 22.5.37 page 779, A&S 8.6.6 (second equation) page 334, and A&S 8.2.5 page 333.

load ("specfun") loads this function.

See assoc_legendre_q, legendre_p, and legendre_q.

Function: assoc_legendre_q (n, m, x)

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

Reference: Gradshteyn and Ryzhik 8.706 page 1000.

load ("specfun") loads this function.

See also assoc_legendre_p, legendre_p, and legendre_q.

Function: chebyshev_t (n, x)

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

Reference: A&S 22.5.31 page 778 and A&S 6.1.22 page 256.

load ("specfun") loads this function.

See also chebyshev_u.

Function: chebyshev_u (n, x)

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

Reference: A&S, 22.8.3 page 783 and A&S 6.1.22 page 256.

load ("specfun") loads this function.

See also chebyshev_t.

Function: gen_laguerre (n, a, x)

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

load ("specfun") loads this function.

Reference: table on page 789 in A&S.

Function: hermite (n, x)

Returns the Hermite polynomial for integers n > -1.

load ("specfun") loads this function.

Reference: A&S 22.5.40 and 22.5.41, page 779.

Function: jacobi_p (n, a, b, x)

Returns the Jacobi polynomial 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 <= -1 or b <= -1.)

When a, b, and x are floats (but not bfloats) specfun calls a special modedeclared version of jacobi_p. For numerical values, the modedeclared version is much faster than the other version. Many functions in specfun are computed as a special case of the Jacobi polynomials; they also enjoy the speed boost from the modedeclared version of jacobi.

If n has been declared to be an integer, jacobi_p (n, a, b, x) returns a summation representation for the Jacobi function. Because Maxima simplifies 0^0 to 0 in a sum, two terms of the sum are added outside the summation.

load ("specfun") loads this function.

Reference: table on page 789 in A&S.

Function: laguerre (n, x)

Returns the Laguerre polynomial for integers n > -1.

Reference: A&S 22.5.16, page 778 and A&S page 789.

load ("specfun") loads this function.

See also gen_laguerre.

Function: legendre_p (n, x)

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

Reference: A&S 22.5.35 page 779.

load ("specfun") loads this function.

See legendre_q.

Function: legendre_q (n, x)

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

Reference: A&S 8.6.19 page 334.

load ("specfun") loads this function.

See also legendre_p.

Function: spherical_bessel_j (n, x)

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

Reference: A&S 10.1.8 page 437 and A&S 10.1.15 page 439.

load ("specfun") loads this function.

See also spherical_hankel1, spherical_hankel2, and spherical_bessel_y.

Function: spherical_bessel_y (n, x)

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

Reference: A&S 10.1.9 page 437 and 10.1.15 page 439.

load ("specfun") loads this function.

See also spherical_hankel1, spherical_hankel2, and spherical_bessel_y.

Function: spherical_hankel1 (n, x)

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

Reference: A&S 10.1.36 page 439.

load ("specfun") loads this function.

See also spherical_hankel2, spherical_bessel_j, and spherical_bessel_y.

Function: spherical_hankel2 (n, x)

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

Reference: A&S 10.1.17 page 439.

load ("specfun") loads this function.

See also spherical_hankel1, spherical_bessel_j, and spherical_bessel_y.

Function: spherical_harmonic (n, m, x, y)

Returns the spherical harmonic function for integers n > -1 and | m | <= n .

Reference: Merzbacher 9.64.

load ("specfun") loads this function.

See also assoc_legendre_p.

Function: ultraspherical (n, a, x)

Returns the ultraspherical polynomials for integers n > -1. The ultraspherical polynomials are also known as Gegenbauer polynomials.

Reference: A&S 22.5.27

load ("specfun") loads this function.

See also jacobi_p.


Go to the first, previous, next, last section, table of contents.