Tcl Library Source Code

Documentation
Login
EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

math::special - Special mathematical functions

Table Of Contents

SYNOPSIS

package require Tcl ?8.5 9?
package require math::special ?0.5.3?

::math::special::eulerNumber index
::math::special::bernoulliNumber index
::math::special::Beta x y
::math::special::incBeta a b x
::math::special::regIncBeta a b x
::math::special::Gamma x
::math::special::digamma x
::math::special::erf x
::math::special::erfc x
::math::special::invnorm p
::math::special::J0 x
::math::special::J1 x
::math::special::Jn n x
::math::special::J1/2 x
::math::special::J-1/2 x
::math::special::I_n x
::math::special::cn u k
::math::special::dn u k
::math::special::sn u k
::math::special::elliptic_K k
::math::special::elliptic_E k
::math::special::exponential_Ei x
::math::special::exponential_En n x
::math::special::exponential_li x
::math::special::exponential_Ci x
::math::special::exponential_Si x
::math::special::exponential_Chi x
::math::special::exponential_Shi x
::math::special::fresnel_C x
::math::special::fresnel_S x
::math::special::sinc x
::math::special::legendre n
::math::special::chebyshev n
::math::special::laguerre alpha n
::math::special::hermite n

DESCRIPTION

This package implements several so-called special functions, like the Gamma function, the Bessel functions and such.

Each function is implemented by a procedure that bears its name (well, in close approximation):

OVERVIEW

In the following table several characteristics of the functions in this package are summarized: the domain for the argument, the values for the parameters and error bounds.

Family       | Function    | Domain x    | Parameter   | Error bound
-------------+-------------+-------------+-------------+--------------
Bessel       | J0, J1,     | all of R    | n = integer |   < 1.0e-8
             | Jn          |             |             |  (|x|<20, n<20)
Bessel       | J1/2, J-1/2,|  x > 0      | n = integer |   exact
Bessel       | I_n         | all of R    | n = integer |   < 1.0e-6
             |             |             |             |
Elliptic     | cn          | 0 <= x <= 1 |     --      |   < 1.0e-10
functions    | dn          | 0 <= x <= 1 |     --      |   < 1.0e-10
             | sn          | 0 <= x <= 1 |     --      |   < 1.0e-10
Elliptic     | K           | 0 <= x < 1  |     --      |   < 1.0e-6
integrals    | E           | 0 <= x < 1  |     --      |   < 1.0e-6
             |             |             |             |
Error        | erf         |             |     --      |
functions    | erfc        |             |             |
             |             |             |             |
Inverse      | invnorm     | 0 < x < 1   |     --      |   < 1.2e-9
normal       |             |             |             |
distribution |             |             |             |
             |             |             |             |
Exponential  | Ei          |  x != 0     |     --      |   < 1.0e-10 (relative)
integrals    | En          |  x >  0     |     --      |   as Ei
             | li          |  x > 0      |     --      |   as Ei
             | Chi         |  x > 0      |     --      |   < 1.0e-8
             | Shi         |  x > 0      |     --      |   < 1.0e-8
             | Ci          |  x > 0      |     --      |   < 2.0e-4
             | Si          |  x > 0      |     --      |   < 2.0e-4
             |             |             |             |
Fresnel      | C           |  all of R   |     --      |   < 2.0e-3
integrals    | S           |  all of R   |     --      |   < 2.0e-3
             |             |             |             |
general      | Beta        | (see Gamma) |     --      |   < 1.0e-9
             | Gamma       |  x != 0,-1, |     --      |   < 1.0e-9
             |             |  -2, ...    |             |
             | incBeta     |             |  a, b > 0   |   < 1.0e-9
             | regIncBeta  |             |  a, b > 0   |   < 1.0e-9
             | digamma     |  x != 0,-1  |             |   < 1.0e-9
             |             |  -2, ...    |             |
             |             |             |             |
             | sinc        |  all of R   |     --      |   exact
             |             |             |             |
orthogonal   | Legendre    |  all of R   | n = 0,1,... |   exact
polynomials  | Chebyshev   |  all of R   | n = 0,1,... |   exact
             | Laguerre    |  all of R   | n = 0,1,... |   exact
             |             |             | alpha el. R |
             | Hermite     |  all of R   | n = 0,1,... |   exact

Note: Some of the error bounds are estimated, as no "formal" bounds were available with the implemented approximation method, others hold for the auxiliary functions used for estimating the primary functions.

The following well-known functions are currently missing from the package:

PROCEDURES

The package defines the following public procedures:

THE ORTHOGONAL POLYNOMIALS

For dealing with the classical families of orthogonal polynomials, the package relies on the math::polynomials package. To evaluate the polynomial at some coordinate, use the evalPolyn command:

set leg2 [::math::special::legendre 2]
puts "Value at x=$x: [::math::polynomials::evalPolyn $leg2 $x]"

The return value from the legendre and other commands is actually the definition of the corresponding polynomial as used in that package.

REMARKS ON THE IMPLEMENTATION

It should be noted, that the actual implementation of J0 and J1 depends on straightforward Gaussian quadrature formulas. The (absolute) accuracy of the results is of the order 1.0e-4 or better. The main reason to implement them like that was that it was fast to do (the formulas are simple) and the computations are fast too.

The implementation of J1/2 does not suffer from this: this function can be expressed exactly in terms of elementary functions.

The functions J0 and J1 are the ones you will encounter most frequently in practice.

The computation of I_n is based on Miller's algorithm for computing the minimal function from recurrence relations.

The computation of the Gamma and Beta functions relies on the combinatorics package, whereas that of the error functions relies on the statistics package.

The computation of the complete elliptic integrals uses the AGM algorithm.

Much information about these functions can be found in:

Abramowitz and Stegun: Handbook of Mathematical Functions (Dover, ISBN 486-61272-4)

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math :: special of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.

KEYWORDS

Bessel functions, error function, math, special functions

CATEGORY

Mathematics

COPYRIGHT

Copyright © 2004 Arjen Markus