7.7
GNU GSL Numerical Integration
Link to this document with
@other-doc['(lib "gsl-integration/scribblings/gsl-integration.scrbl")]
Link to this document with
@other-doc['(lib "gsl-integration/scribblings/gsl-integration.scrbl")]
Interface to GNU GSL Numerical Integration.
Library hides memory allocation and other low level C stuff.
GNU GSL has to be installed separately.
Tested for version 2.5.
Naming of functions and keywords follow GNU GSL documentation
https://www.gnu.org/software/gsl/doc/html/integration.html
The source code is distributed under the GNU General Public License.
1 Example
Link to this section with
@secref["Example"
#:doc '(lib "gsl-integration/scribblings/gsl-integration.scrbl")]
Link to this section with
@secref["Example"
#:doc '(lib "gsl-integration/scribblings/gsl-integration.scrbl")]
; result = -4.000000000000085 |
; exact result = -4.0 |
; result = -4.000000000000085 |
; estimated error = 1.354472090042691e-13 |
; actual error = -8.526512829121202e-1 |
For more examples look at test.rkt source file.
Tip: When working with math formulas it is recommended to use a infix library, for better readability.
For example: https://pkgs.racket-lang.org/package/infix
2 Reference
Link to this section with
@secref["Reference"
#:doc '(lib "gsl-integration/scribblings/gsl-integration.scrbl")]
Link to this section with
@secref["Reference"
#:doc '(lib "gsl-integration/scribblings/gsl-integration.scrbl")]
The functions will always return a list.
First element is status code. Success when code = 0, otherwise error.
Success list: 0, result. Thereafter one or both (see GNU GSL documentation): abserr , neveal.
Error list: codenr, gsl-symbol, message.
The QNG algorithm is a non-adaptive procedure which uses fixed
Gauss-Kronrod-Patterson abscissae to sample the integrand at a maximum of 87 points.
It is provided for fast integration of smooth functions.
When success, returns:
When error, returns:
(codenr gsl-symbol message)
The QAG algorithm is a simple adaptive integration procedure.
The integration region is divided into subintervals,
and on each iteration the subinterval with the largest estimated error is bisected.
This reduces the overall error rapidly, as the subintervals become concentrated around local difficulties in the integrand.
QAGS adaptive integration with singularities
QAGP adaptive integration with known singular points
QAGI adaptive integration on infinite interval (-\infty,+\infty)
QAGIU adaptive integration on semi-infinite interval (a,+\infty)
QAGIL adaptive integration on semi-infinite interval (-\infty,b)
QAWC adaptive integration for Cauchy principal values
CQUAD is a doubly-adaptive general-purpose quadrature routine which can handle most types of singularities,
non-numerical function values such as Inf or NaN, as well as some divergent integrals.
It generally requires more function evaluations than the integration routines in QUADPACK,
yet fails less often for difficult integrands.
Romberg integration
3 Troubleshooting
Link to this section with
@secref["Troubleshooting"
#:doc '(lib "gsl-integration/scribblings/gsl-integration.scrbl")]
Link to this section with
@secref["Troubleshooting"
#:doc '(lib "gsl-integration/scribblings/gsl-integration.scrbl")]
Some linux systems have precompiled package for GNU GSL library. Howeever this package can be of an older version.
It is recommended to compile and install GNU GSL library from source.
Beware that installation directory from source can be different that from precompiled package.
If you get an error that it can not find Romberg, but not error on the other functions: You have and older version of GNU GSL on our system.
Romberg was added at version 2.5
If you get error: ffi-lib: couldn’t open "libgslcblas.so" (libgslcblas.so: cannot open shared object file: No such file or directory)
Solution: Edit ~/.bashrc
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH