1 @cindex special functions
3 This chapter describes the GSL special function library. The library
4 includes routines for calculating the values of Airy functions, Bessel
5 functions, Clausen functions, Coulomb wave functions, Coupling
6 coefficients, the Dawson function, Debye functions, Dilogarithms,
7 Elliptic integrals, Jacobi elliptic functions, Error functions,
8 Exponential integrals, Fermi-Dirac functions, Gamma functions,
9 Gegenbauer functions, Hypergeometric functions, Laguerre functions,
10 Legendre functions and Spherical Harmonics, the Psi (Digamma) Function,
11 Synchrotron functions, Transport functions, Trigonometric functions and
12 Zeta functions. Each routine also computes an estimate of the numerical
13 error in the calculated value of the function.
15 The functions in this chapter are declared in individual header files,
16 such as @file{gsl_sf_airy.h}, @file{gsl_sf_bessel.h}, etc. The complete
17 set of header files can be included using the file @file{gsl_sf.h}.
20 * Special Function Usage::
21 * The gsl_sf_result struct::
22 * Special Function Modes::
23 * Airy Functions and Derivatives::
27 * Coupling Coefficients::
31 * Elementary Operations::
32 * Elliptic Integrals::
33 * Elliptic Functions (Jacobi)::
35 * Exponential Functions::
36 * Exponential Integrals::
37 * Fermi-Dirac Function::
38 * Gamma and Beta Functions::
39 * Gegenbauer Functions::
40 * Hypergeometric Functions::
41 * Laguerre Functions::
42 * Lambert W Functions::
43 * Legendre Functions and Spherical Harmonics::
44 * Logarithm and Related Functions::
47 * Psi (Digamma) Function::
48 * Synchrotron Functions::
49 * Transport Functions::
50 * Trigonometric Functions::
52 * Special Functions Examples::
53 * Special Functions References and Further Reading::
56 @node Special Function Usage
59 The special functions are available in two calling conventions, a
60 @dfn{natural form} which returns the numerical value of the function and
61 an @dfn{error-handling form} which returns an error code. The two types
62 of function provide alternative ways of accessing the same underlying
65 The @dfn{natural form} returns only the value of the function and can be
66 used directly in mathematical expressions. For example, the following
67 function call will compute the value of the Bessel function
71 double y = gsl_sf_bessel_J0 (x);
75 There is no way to access an error code or to estimate the error using
76 this method. To allow access to this information the alternative
77 error-handling form stores the value and error in a modifiable argument,
81 int status = gsl_sf_bessel_J0_e (x, &result);
85 The error-handling functions have the suffix @code{_e}. The returned
86 status value indicates error conditions such as overflow, underflow or
87 loss of precision. If there are no errors the error-handling functions
88 return @code{GSL_SUCCESS}.
90 @node The gsl_sf_result struct
91 @section The gsl_sf_result struct
93 @cindex gsl_sf_result_e10
95 The error handling form of the special functions always calculate an
96 error estimate along with the value of the result. Therefore,
97 structures are provided for amalgamating a value and error estimate.
98 These structures are declared in the header file @file{gsl_sf_result.h}.
100 The @code{gsl_sf_result} struct contains value and error fields.
111 The field @var{val} contains the value and the field @var{err} contains
112 an estimate of the absolute error in the value.
114 In some cases, an overflow or underflow can be detected and handled by a
115 function. In this case, it may be possible to return a scaling exponent
116 as well as an error/value pair in order to save the result from
117 exceeding the dynamic range of the built-in types. The
118 @code{gsl_sf_result_e10} struct contains value and error fields as well
119 as an exponent field such that the actual result is obtained as
120 @code{result * 10^(e10)}.
128 @} gsl_sf_result_e10;
131 @node Special Function Modes
134 The goal of the library is to achieve double precision accuracy wherever
135 possible. However the cost of evaluating some special functions to
136 double precision can be significant, particularly where very high order
137 terms are required. In these cases a @code{mode} argument allows the
138 accuracy of the function to be reduced in order to improve performance.
139 The following precision levels are available for the mode argument,
142 @item GSL_PREC_DOUBLE
143 Double-precision, a relative accuracy of approximately @c{$2 \times 10^{-16}$}
145 @item GSL_PREC_SINGLE
146 Single-precision, a relative accuracy of approximately @c{$1 \times 10^{-7}$}
148 @item GSL_PREC_APPROX
149 Approximate values, a relative accuracy of approximately @c{$5 \times 10^{-4}$}
154 The approximate mode provides the fastest evaluation at the lowest
157 @node Airy Functions and Derivatives
158 @section Airy Functions and Derivatives
159 @include specfunc-airy.texi
161 @node Bessel Functions
162 @section Bessel Functions
163 @include specfunc-bessel.texi
165 @node Clausen Functions
166 @section Clausen Functions
167 @include specfunc-clausen.texi
169 @node Coulomb Functions
170 @section Coulomb Functions
171 @include specfunc-coulomb.texi
173 @node Coupling Coefficients
174 @section Coupling Coefficients
175 @include specfunc-coupling.texi
177 @node Dawson Function
178 @section Dawson Function
179 @include specfunc-dawson.texi
181 @node Debye Functions
182 @section Debye Functions
183 @include specfunc-debye.texi
187 @include specfunc-dilog.texi
189 @node Elementary Operations
190 @section Elementary Operations
191 @include specfunc-elementary.texi
193 @node Elliptic Integrals
194 @section Elliptic Integrals
195 @include specfunc-ellint.texi
197 @node Elliptic Functions (Jacobi)
198 @section Elliptic Functions (Jacobi)
199 @include specfunc-elljac.texi
201 @node Error Functions
202 @section Error Functions
203 @include specfunc-erf.texi
205 @node Exponential Functions
206 @section Exponential Functions
207 @include specfunc-exp.texi
209 @node Exponential Integrals
210 @section Exponential Integrals
211 @include specfunc-expint.texi
213 @node Fermi-Dirac Function
214 @section Fermi-Dirac Function
215 @include specfunc-fermi-dirac.texi
217 @node Gamma and Beta Functions
218 @section Gamma and Beta Functions
219 @include specfunc-gamma.texi
221 @node Gegenbauer Functions
222 @section Gegenbauer Functions
223 @include specfunc-gegenbauer.texi
225 @node Hypergeometric Functions
226 @section Hypergeometric Functions
227 @include specfunc-hyperg.texi
229 @node Laguerre Functions
230 @section Laguerre Functions
231 @include specfunc-laguerre.texi
233 @node Lambert W Functions
234 @section Lambert W Functions
235 @include specfunc-lambert.texi
237 @node Legendre Functions and Spherical Harmonics
238 @section Legendre Functions and Spherical Harmonics
239 @include specfunc-legendre.texi
241 @node Logarithm and Related Functions
242 @section Logarithm and Related Functions
243 @include specfunc-log.texi
245 @node Mathieu Functions
246 @section Mathieu Functions
247 @include specfunc-mathieu.texi
250 @section Power Function
251 @include specfunc-pow-int.texi
253 @node Psi (Digamma) Function
254 @section Psi (Digamma) Function
255 @include specfunc-psi.texi
257 @node Synchrotron Functions
258 @section Synchrotron Functions
259 @include specfunc-synchrotron.texi
261 @node Transport Functions
262 @section Transport Functions
263 @include specfunc-transport.texi
265 @node Trigonometric Functions
266 @section Trigonometric Functions
267 @include specfunc-trig.texi
270 @section Zeta Functions
271 @include specfunc-zeta.texi
273 @node Special Functions Examples
276 The following example demonstrates the use of the error handling form of
277 the special functions, in this case to compute the Bessel function
281 @verbatiminclude examples/specfun_e.c
285 Here are the results of running the program,
289 @verbatiminclude examples/specfun_e.out
293 The next program computes the same quantity using the natural form of
294 the function. In this case the error term @var{result.err} and return
295 status are not accessible.
298 @verbatiminclude examples/specfun.c
302 The results of the function are the same,
306 @verbatiminclude examples/specfun.out
311 @node Special Functions References and Further Reading
312 @section References and Further Reading
314 The library follows the conventions of @cite{Abramowitz & Stegun} where
318 Abramowitz & Stegun (eds.), @cite{Handbook of Mathematical Functions}
322 The following papers contain information on the algorithms used
323 to compute the special functions,
327 MISCFUN: A software package to compute uncommon special functions.
328 @cite{ACM Trans.@: Math.@: Soft.}, vol.@: 22, 1996, 288--301
331 G.N. Watson, A Treatise on the Theory of Bessel Functions,
332 2nd Edition (Cambridge University Press, 1944).
335 G. Nemeth, Mathematical Approximations of Special Functions,
336 Nova Science Publishers, ISBN 1-56072-052-2
339 B.C. Carlson, Special Functions of Applied Mathematics (1977)
342 W.J. Thompson, Atlas for Computing Mathematical Functions, John Wiley & Sons,
346 Y.Y. Luke, Algorithms for the Computation of Mathematical Functions, Academic
347 Press, New York (1977).
350 @comment Fermi-Dirac functions of orders @math{-1/2}, @math{1/2}, @math{3/2}, and
351 @comment @math{5/2}. @cite{ACM Trans. Math. Soft.}, vol. 24, 1998, 1-12.