GNU Scientific Library
Reference Manual
Edition 1.13, for GSL Version 1.13
25 August 2009
Mark Galassi
Los Alamos National Laboratory
Jim Davies
Department of Computer Science, Georgia Institute of Technology
James Theiler
Astrophys ics and Radiation Measurements Group, Los Alamos National Laboratory
Brian Gough
Network Theory Limited
Gerard Jungman
Theoretical Astrophysics Group, Los Alamos National Laboratory
Patrick Alken
Department of Physics, University of Colorado at Boulder
Michael Booth
Department of Physics and Astronomy, The Johns Hopkins University
Fabrice Rossi
University of Paris-Dauphine
Copyright
c
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2009 The GSL Team.
Permission is granted to copy, distribute and/or modify this document under the terms of
the GNU Free Documentation License, Version 1.3 or any later version published by the Free
Software Foundation; with the Invariant Sections being “GNU General Public License” and
“Fr ee Software Needs Free Documentation”, the Front-Cover text being “A GNU Manual”,
and with the Back-Cover Text being (a) (see below). A copy of the license is included in
the section entitled “GNU Free Documentation License”.
(a) The Back-Cover Text is: “You have the freedom to copy and modify this GNU
Manual.” Printed copies of this manual can be purchased from Network Theory Ltd at
http://www.network-theory.co.uk/gsl/manual/.
The money raised from sales of the manual helps sup port the development of GSL.
i
Table of Cont ents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Routines available in GSL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 GSL is Free Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Obtaining GSL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 No Warranty. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 Reporting Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 Further Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.7 Conventions used in this manual. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Using the library . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1 An Example Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Compiling and Linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2.1 Linking programs with the library. . . . . . . . . . . . . . . . . . . . . . . . 4
2.2.2 Linking with an alternative BLAS library . . . . . . . . . . . . . . . . . 5
2.3 Shared Libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 ANSI C Compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.5 Inline functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.6 Long double . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.7 Portability fun ctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.8 Alternative optimized fu nctions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.9 Support for different numeric typ es . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.10 Compatibility w ith C++. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.11 Aliasing of arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.12 Thread-safety . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.13 Deprecated Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.14 Code Reuse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1 Error Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.3 Error Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.4 Using GSL error reporting in your own functions . . . . . . . . . . . . . 13
3.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4 Mathematical Functions. . . . . . . . . . . . . . . . . . . 16
4.1 Mathematical Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2 Infinities an d Not-a-number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.3 Elementary Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.4 Small integer powers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.5 Testing the Sign of Numb ers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.6 Testing for Odd and Even Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.7 Maximum and Minimum functions. . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.8 Approximate Comparison of Floating Point Numbers . . . . . . . . . 19
ii
5 Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . 21
5.1 Representation of complex numbers . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.2 Properties of complex numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.3 Complex arithmetic operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.4 Elementary Complex Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.5 Complex Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.6 Inverse Complex Trigonometric Functions . . . . . . . . . . . . . . . . . . . . 24
5.7 Complex Hyperbolic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.8 Inverse Complex Hyperbolic Functions . . . . . . . . . . . . . . . . . . . . . . . 26
5.9 References and Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6 Polynomials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.1 Polynomial E valuation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
6.2 Divided Difference Representation of Polynomials . . . . . . . . . . . . . 28
6.3 Quadratic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.4 Cubic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
6.5 General Polynomial Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
6.6 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.7 References and Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7 Special Functions . . . . . . . . . . . . . . . . . . . . . . . . . 33
7.1 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
7.2 The gsl
sf result struct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
7.3 Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.4 Airy Functions and Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.4.1 Airy Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
7.4.2 Derivatives of Airy Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
7.4.3 Zeros of Airy Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
7.4.4 Zeros of Derivatives of Airy Fu nctions . . . . . . . . . . . . . . . . . . . 36
7.5 Bessel Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
7.5.1 Regular Cylindrical Bessel Functions . . . . . . . . . . . . . . . . . . . . 36
7.5.2 Irregular Cylindrical Bessel Functions . . . . . . . . . . . . . . . . . . . 36
7.5.3 Regular Modified Cylindrical Bessel Functions . . . . . . . . . . . 37
7.5.4 Irregular Modified Cylindrical Bessel Functions . . . . . . . . . . 38
7.5.5 Regular Spherical Bessel Functions . . . . . . . . . . . . . . . . . . . . . . 39
7.5.6 Irregular Spherical Bessel Functions . . . . . . . . . . . . . . . . . . . . . 40
7.5.7 Regular Modified Spherical Bessel Functions . . . . . . . . . . . . . 40
7.5.8 Irregular Modified Spherical Bessel Functions . . . . . . . . . . . . 41
7.5.9 Regular Bessel Function—Fractional Order . . . . . . . . . . . . . . 41
7.5.10 Irregular Bessel Functions—Fractional Order. . . . . . . . . . . . 42
7.5.11 Regular Modified Bessel Functions—Fractional Order . . . . 42
7.5.12 Irregular Mo dified Bessel Functions—Fractional Or d er . . . 42
7.5.13 Zeros of Regular Bessel Functions . . . . . . . . . . . . . . . . . . . . . . 43
7.6 Clausen Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
7.7 Coulomb Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
7.7.1 Normalized Hydrogenic Bound States . . . . . . . . . . . . . . . . . . . 43
7.7.2 Coulomb Wave Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
iii
7.7.3 Coulomb Wave Function Normalization Constant . . . . . . . . 45
7.8 Coupling Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7.8.1 3-j Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7.8.2 6-j Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7.8.3 9-j Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7.9 Dawson Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7.10 Debye Fun ctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
7.11 Dilogarithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.11.1 Real Argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.11.2 Complex Argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.12 Elementary Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.13 Elliptic Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.13.1 Definition of Legendre Forms . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.13.2 Definition of Carlson Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
7.13.3 Legendre Form of Complete Elliptic I ntegrals . . . . . . . . . . . 49
7.13.4 Legendre Form of Incomplete Elliptic Integrals . . . . . . . . . . 49
7.13.5 Carlson Forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
7.14 Elliptic Functions (Jacobi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
7.15 Error Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.15.1 Error Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.15.2 Complementary E rror Function . . . . . . . . . . . . . . . . . . . . . . . . 51
7.15.3 Log Complementary Error Function . . . . . . . . . . . . . . . . . . . . 51
7.15.4 Probability functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.16 Exponential Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.16.1 Exponential Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.16.2 Relative Exponential Functions . . . . . . . . . . . . . . . . . . . . . . . . 52
7.16.3 Exponentiation With Error Estimate . . . . . . . . . . . . . . . . . . . 53
7.17 Exponential Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.17.1 Exponential Integral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.17.2 Ei(x) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.17.3 Hyperbolic Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.17.4 Ei
3(x) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.17.5 Trigonometric Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.17.6 Arctangent Integral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.18 Fermi-Dirac Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.18.1 Complete Fermi-Dirac Integrals . . . . . . . . . . . . . . . . . . . . . . . . 55
7.18.2 Incomplete Fermi-Dir ac Integrals . . . . . . . . . . . . . . . . . . . . . . 56
7.19 Gamma and Beta Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.19.1 Gamma Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.19.2 Factorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
7.19.3 Pochhammer Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.19.4 Incomplete Gamma Functions . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.19.5 Beta Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.19.6 Incomplete Beta Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.20 Gegenbauer Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.21 Hypergeometric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.22 Laguerre Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.23 Lambert W Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
- 1
- 2
- 3
- 4
- 5
- 6
前往页