www.delorie.com/gnu/docs/maxima/maxima_54.html   search  
 
Buy GNU books!


Maxima Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.1 Introduction to Orthogonal Polynomials

The specfun package, located in the share directory, 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 following table lists each function in specfun, its Maxima name, restrictions on its arguments ( m and n must be integers), and a reference to the algorithm specfun uses to evaluate it. With few exceptions, specfun follows the conventions of Abramowitz and Stegun. Before you use specfun, check that specfun's conventions match your expectations.

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 (2ed, 1970).

Function Maxima Name Restrictions Reference(s)
Chebyshev T chebyshev_t(n, x) n > -1 A&S 22.5.31
Chebyshev U chebyshev_u(n, x) n > -1 A&S 22.5.32
generalized Laguerre gen_laguerre(n,a,x) n > -1 A&S page 789
Laguerre laguerre(n,x) n > -1 A&S 22.5.67
Hermite hermite(n,x) n > -1 A&S 22.4.40, 22.5.41
Jacobi jacobi_p(n,a,b,x) n > -1, a, b > -1 A&S page 789
associated Legendre P assoc_legendre_p(n,m,x) n > -1 A&S 22.5.37, 8.6.6, 8.2.5
associated Legendre Q assoc_legendre_q(n,m,x) n > -1, m > -1 G & R 8.706
Legendre P legendre_p(n,m,x) n > -1 A&S 22.5.35
Legendre Q legendre_q(n,m,x) n > -1 A&S 8.6.19
spherical Hankel 1st spherical_hankel1(n, x) n > -1 A&S 10.1.36
spherical Hankel 2nd spherical_hankel2(n, x) n > -1 A&S 10.1.17
spherical Bessel J spherical_bessel_j(n,x) n > -1 A&S 10.1.8, 10.1.15
spherical Bessel Y spherical_bessel_y(n,x) n > -1 A&S 10.1.9, 10.1.15
spherical harmonic spherical_harmonic(n,m,x,y) n > -1, |m| <= n Merzbacher 9.64
ultraspherical (Gegenbauer) 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 bfloats), 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 attempt has been made to define simplification rules (based on recursion relations) for unevaluated functions. Users should be aware that it is possible for an expression involving sums of unevaluated special functions to vanish, yet Maxima is unable to reduce it to zero. Be careful.

To access functions in specfun, you must first load specfun.o. Alternatively, you may append autoload statements to your init.lsp file (located in your working directory). To autoload the hermite function, for example, append
 
   (defprop |$hermite| #"specfun.o" autoload) 
   (add2lnc '|$hermite| $props) 
to your init.lsp file. An example use of specfun is
 
(c1) load("specfun.o")$
(c2) [hermite(0,x),hermite(1,x),hermite(2,x)];
(d2) [1,2*x,-2*(1-2*x^2)]
(c3) diff(hermite(n,x),x);
(d3) 2*n*hermite(n-1,x)

When using the compiled version of specfun, be especially careful to use the correct number of function arguments; calling them with too few arguments may generate a fatal error messages. For example
 
(c1) load("specfun")$
/* chebyshev_t requires two arguments. */
(c2) chebyshev_t(8);
Error: Caught fatal error [memory may be damaged]
Fast links are on: do (si::use-fast-links nil) for debugging
Error signalled by MMAPCAR.
Broken at SIMPLIFY.  Type :H for Help.
Maxima code translated into Lisp handles such errors more gracefully. If specfun.LISP is installed on your machine, the same computation results in a clear error message. For example
 
(c1) load("specfun.LISP")$
(c2) chebyshev_t(8);
Error: Expected 2 args but received 1 args
Fast links are on: do (si::use-fast-links nil) for debugging
Error signalled by MACSYMA-TOP-LEVEL.
Broken at |$CHEBYSHEV_T|.  Type :H for Help.
Generally, compiled code runs faster than translated code; however, translated code may be better for program development.

For some functions, when the order is symbolic but has been declared to be an integer, specfun will return a series representation. (The series representation is not used by specfun for any computations.) You may use this feature to find symbolic values for special values orthogonal polynomials. An example:
 
(c1) load("specfun")$
(c2) legendre_p(n,1);
(d2)        legendre_p(n, 1)
/* Declare n to be an integer; now legendre_p(n,1) evaluates to 1. */
(c3) declare(n,integer)$
(c4) legendre_p(n,1);
(d4)        1
(c5) ultraspherical(n,3/2,1);
(d4)         (n+1)*gamma (n+3) / (2*gamma (n+2))
Although the preceding example doesn't show it, two terms of the sum are added outside the summation. Removing these two terms avoids errors 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:

 
(c1) load("specfun.o")$
(c2) declare(n,integer)$
(c3) e : legendre_p(n,x)$
(c4) 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);)
(c5) ev(e,sum,n=0),sumhack : true;
(d5)         1

Most functions in specfun have a gradef property; derivatives with respect to the order or other function parameters aren't unevaluated.

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 Maxima and specfun version information. The specfun version may be found using get:
 
 (c2) get('specfun,'version);
 (d2)          110


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003