⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 integration.texi

📁 The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers.
💻 TEXI
📖 第 1 页 / 共 2 页
字号:
@cindex quadrature@cindex numerical integration (quadrature)@cindex integration, numerical (quadrature)@cindex QUADPACKThis chapter describes routines for performing numerical integration(quadrature) of a function in one dimension.  There are routines foradaptive and non-adaptive integration of general functions, withspecialised routines for specific cases.  These include integration overinfinite and semi-infinite ranges, singular integrals, includinglogarithmic singularities, computation of Cauchy principal values andoscillatory integrals.  The library reimplements the algorithms used in@sc{quadpack}, a numerical integration package written by Piessens,Doncker-Kapenga, Uberhuber and Kahaner.  Fortran code for @sc{quadpack} isavailable on Netlib.The functions described in this chapter are declared in the header file@file{gsl_integration.h}.@menu* Numerical Integration Introduction::  * QNG non-adaptive Gauss-Kronrod integration::  * QAG adaptive integration::    * QAGS adaptive integration with singularities::  * QAGP adaptive integration with known singular points::  * QAGI adaptive integration on infinite intervals::  * QAWC adaptive integration for Cauchy principal values::  * QAWS adaptive integration for singular functions::  * QAWO adaptive integration for oscillatory functions::  * QAWF adaptive integration for Fourier integrals::  * Numerical integration error codes::  * Numerical integration examples::  * Numerical integration References and Further Reading::  @end menu@node Numerical Integration Introduction@section IntroductionEach algorithm computes an approximation to a definite integral of theform,@tex\beforedisplay$$I = \int_a^b f(x) w(x) \,dx$$\afterdisplay@end tex@ifinfo@exampleI = \int_a^b f(x) w(x) dx@end example@end ifinfo@noindentwhere @math{w(x)} is a weight function (for general integrands @math{w(x)=1}).The user provides absolute and relative error bounds @c{$(\hbox{\it epsabs}, \hbox{\it epsrel}\,)$}@math{(epsabs, epsrel)} which specify the following accuracy requirement,@tex\beforedisplay$$|\hbox{\it RESULT} - I|  \leq \max(\hbox{\it epsabs}, \hbox{\it epsrel}\, |I|)$$\afterdisplay@end tex@ifinfo@example|RESULT - I|  <= max(epsabs, epsrel |I|)@end example@end ifinfo@noindentwhere @c{$\hbox{\it RESULT}$}@math{RESULT} is the numerical approximation obtained by thealgorithm.  The algorithms attempt to estimate the absolute error@c{$\hbox{\it ABSERR} = |\hbox{\it RESULT} - I|$}@math{ABSERR = |RESULT - I|} in such a way that the following inequalityholds,@tex\beforedisplay$$|\hbox{\it RESULT} - I| \leq \hbox{\it ABSERR} \leq \max(\hbox{\it epsabs}, \hbox{\it epsrel}\,|I|)$$\afterdisplay@end tex@ifinfo@example|RESULT - I| <= ABSERR <= max(epsabs, epsrel |I|)@end example@end ifinfo@noindentThe routines will fail to converge if the error bounds are toostringent, but always return the best approximation obtained up to thatstage.The algorithms in @sc{quadpack} use a naming convention based on thefollowing letters,@display @code{Q} - quadrature routine@code{N} - non-adaptive integrator@code{A} - adaptive integrator@code{G} - general integrand (user-defined)@code{W} - weight function with integrand@code{S} - singularities can be more readily integrated@code{P} - points of special difficulty can be supplied@code{I} - infinite range of integration@code{O} - oscillatory weight function, cos or sin@code{F} - Fourier integral@code{C} - Cauchy principal value@end display@noindentThe algorithms are built on pairs of quadrature rules, a higher orderrule and a lower order rule.  The higher order rule is used to computethe best approximation to an integral over a small range.  Thedifference between the results of the higher order rule and the lowerorder rule gives an estimate of the error in the approximation.@cindex Gauss-Kronrod quadratureThe algorithms for general functions (without a weight function) arebased on Gauss-Kronrod rules. A Gauss-Kronrod rule begins with aclassical Gaussian quadrature rule of order @math{m}.  This is extendedwith additional points between each of the abscissae to give a higherorder Kronrod rule of order @math{2m+1}.  The Kronrod rule is efficientbecause it reuses existing function evaluations from the Gaussian rule.The higher order Kronrod rule is used as the best approximation to theintegral, and the difference between the two rules is used as anestimate of the error in the approximation.@cindex Clenshaw-Curtis quadrature@cindex Modified Clenshaw-Curtis quadratureFor integrands with weight functions the algorithms use Clenshaw-Curtisquadrature rules.  A Clenshaw-Curtis rule begins with an @math{n}-thorder Chebyshev polynomial approximation to the integrand.  Thispolynomial can be integrated exactly to give an approximation to theintegral of the original function.  The Chebyshev expansion can beextended to higher orders to improve the approximation.  The presence ofsingularities (or other behavior) in the integrand can cause slowconvergence in the Chebyshev approximation.  The modifiedClenshaw-Curtis rules used in @sc{quadpack} separate out several commonweight functions which cause slow convergence.  These weight functionsare integrated analytically against the Chebyshev polynomials toprecompute @dfn{modified Chebyshev moments}.  Combining the moments withthe Chebyshev approximation to the function gives the desiredintegral.  The use of analytic integration for the singular part of thefunction allows exact cancellations and substantially improves theoverall convergence behavior of the integration.@node QNG non-adaptive Gauss-Kronrod integration@section QNG non-adaptive Gauss-Kronrod integrationThe QNG algorithm is a non-adaptive procedure which uses fixedGauss-Kronrod abscissae to sample the integrand at a maximum of 87points.  It is provided for fast integration of smooth functions.@deftypefun int gsl_integration_qng (const gsl_function *@var{f}, double @var{a}, double @var{b}, double @var{epsabs}, double @var{epsrel}, double * @var{result}, double * @var{abserr}, size_t * @var{neval})This function applies the Gauss-Kronrod 10-point, 21-point, 43-point and87-point integration rules in succession until an estimate of theintegral of @math{f} over @math{(a,b)} is achieved within the desiredabsolute and relative error limits, @var{epsabs} and @var{epsrel}.  Thefunction returns the final approximation, @var{result}, an estimate ofthe absolute error, @var{abserr} and the number of function evaluationsused, @var{neval}.  The Gauss-Kronrod rules are designed in such a waythat each rule uses all the results of its predecessors, in order tominimize the total number of function evaluations.@end deftypefun@node QAG adaptive integration@section QAG adaptive integrationThe QAG algorithm is a simple adaptive integration procedure.  Theintegration region is divided into subintervals, and on each iterationthe subinterval with the largest estimated error is bisected.  Thisreduces the overall error rapidly, as the subintervals becomeconcentrated around local difficulties in the integrand.  Thesesubintervals are managed by a @code{gsl_integration_workspace} struct,which handles the memory for the subinterval ranges, results and errorestimates.@deftypefun {gsl_integration_workspace *} gsl_integration_workspace_alloc (size_t @var{n}) This function allocates a workspace sufficient to hold @var{n} doubleprecision intervals, their integration results and error estimates.@end deftypefun@deftypefun void gsl_integration_workspace_free (gsl_integration_workspace * @var{w})This function frees the memory associated with the workspace @var{w}.@end deftypefun@deftypefun int gsl_integration_qag (const gsl_function *@var{f}, double @var{a}, double @var{b}, double @var{epsabs}, double @var{epsrel}, size_t @var{limit}, int @var{key}, gsl_integration_workspace * @var{workspace},  double * @var{result}, double * @var{abserr})This function applies an integration rule adaptively until an estimateof the integral of @math{f} over @math{(a,b)} is achieved within thedesired absolute and relative error limits, @var{epsabs} and@var{epsrel}.  The function returns the final approximation,@var{result}, and an estimate of the absolute error, @var{abserr}.  Theintegration rule is determined by the value of @var{key}, which shouldbe chosen from the following symbolic names,@exampleGSL_INTEG_GAUSS15  (key = 1)GSL_INTEG_GAUSS21  (key = 2)GSL_INTEG_GAUSS31  (key = 3)GSL_INTEG_GAUSS41  (key = 4)GSL_INTEG_GAUSS51  (key = 5)GSL_INTEG_GAUSS61  (key = 6)@end example@noindentcorresponding to the 15, 21, 31, 41, 51 and 61 point Gauss-Kronrodrules.  The higher-order rules give better accuracy for smooth functions,while lower-order rules save time when the function contains localdifficulties, such as discontinuities.On each iteration the adaptive integration strategy bisects the intervalwith the largest error estimate.  The subintervals and their results arestored in the memory provided by @var{workspace}.  The maximum number ofsubintervals is given by @var{limit}, which may not exceed the allocatedsize of the workspace.@end deftypefun@node QAGS adaptive integration with singularities@section QAGS adaptive integration with singularitiesThe presence of an integrable singularity in the integration regioncauses an adaptive routine to concentrate new subintervals around thesingularity.  As the subintervals decrease in size the successiveapproximations to the integral converge in a limiting fashion.  Thisapproach to the limit can be accelerated using an extrapolationprocedure.  The QAGS algorithm combines adaptive bisection with the Wynnepsilon-algorithm to speed up the integration of many types ofintegrable singularities.@deftypefun int gsl_integration_qags (const gsl_function * @var{f}, double @var{a}, double @var{b}, double @var{epsabs}, double @var{epsrel}, size_t @var{limit}, gsl_integration_workspace * @var{workspace}, double *@var{result}, double *@var{abserr})This function applies the Gauss-Kronrod 21-point integration ruleadaptively until an estimate of the integral of @math{f} over@math{(a,b)} is achieved within the desired absolute and relative errorlimits, @var{epsabs} and @var{epsrel}.  The results are extrapolatedusing the epsilon-algorithm, which accelerates the convergence of theintegral in the presence of discontinuities and integrablesingularities.  The function returns the final approximation from theextrapolation, @var{result}, and an estimate of the absolute error,@var{abserr}.  The subintervals and their results are stored in thememory provided by @var{workspace}.  The maximum number of subintervalsis given by @var{limit}, which may not exceed the allocated size of theworkspace.@end deftypefun@node QAGP adaptive integration with known singular points@section QAGP adaptive integration with known singular points@cindex singular points, specifying positions in quadrature@deftypefun int gsl_integration_qagp (const gsl_function * @var{f}, double *@var{pts}, size_t @var{npts}, double @var{epsabs}, double @var{epsrel}, size_t @var{limit}, gsl_integration_workspace * @var{workspace}, double *@var{result}, double *@var{abserr})This function applies the adaptive integration algorithm QAGS takingaccount of the user-supplied locations of singular points.  The array@var{pts} of length @var{npts} should contain the endpoints of theintegration ranges defined by the integration region and locations ofthe singularities.  For example, to integrate over the region@math{(a,b)} with break-points at @math{x_1, x_2, x_3} (where @math{a < x_1 < x_2 < x_3 < b}) the following @var{pts} array should be used@examplepts[0] = apts[1] = x_1pts[2] = x_2pts[3] = x_3pts[4] = b@end example@noindentwith @var{npts} = 5.@noindentIf you know the locations of the singular points in the integrationregion then this routine will be faster than @code{QAGS}.@end deftypefun@node QAGI adaptive integration on infinite intervals@section QAGI adaptive integration on infinite intervals@deftypefun int gsl_integration_qagi (gsl_function * @var{f}, double @var{epsabs}, double @var{epsrel}, size_t @var{limit}, gsl_integration_workspace * @var{workspace}, double *@var{result}, double *@var{abserr})This function computes the integral of the function @var{f} over theinfinite interval @math{(-\infty,+\infty)}.  The integral is mapped onto theinterval @math{(0,1]} using the transformation @math{x = (1-t)/t},@tex\beforedisplay$$\int_{-\infty}^{+\infty} dx \, f(x)   = \int_0^1 dt \, (f((1-t)/t) + f(-(1-t)/t))/t^2.$$\afterdisplay@end tex@ifinfo@example\int_@{-\infty@}^@{+\infty@} dx f(x) =      \int_0^1 dt (f((1-t)/t) + f((-1+t)/t))/t^2.@end example@end ifinfo@noindentIt is then integrated using the QAGS algorithm.  The normal 21-pointGauss-Kronrod rule of QAGS is replaced by a 15-point rule, because thetransformation can generate an integrable singularity at the origin.  Inthis case a lower-order rule is more efficient.@end deftypefun@deftypefun int gsl_integration_qagiu (gsl_function * @var{f}, double @var{a}, double @var{epsabs}, double @var{epsrel}, size_t @var{limit}, gsl_integration_workspace * @var{workspace}, double *@var{result}, double *@var{abserr})This function computes the integral of the function @var{f} over thesemi-infinite interval @math{(a,+\infty)}.  The integral is mapped onto theinterval @math{(0,1]} using the transformation @math{x = a + (1-t)/t},@tex\beforedisplay$$\int_{a}^{+\infty} dx \, f(x)   = \int_0^1 dt \, f(a + (1-t)/t)/t^2$$\afterdisplay@end tex@ifinfo@example\int_@{a@}^@{+\infty@} dx f(x) =      \int_0^1 dt f(a + (1-t)/t)/t^2@end example@end ifinfo@noindentand then integrated using the QAGS algorithm.@end deftypefun@deftypefun int gsl_integration_qagil (gsl_function * @var{f}, double @var{b}, double @var{epsabs}, double @var{epsrel}, size_t @var{limit}, gsl_integration_workspace * @var{workspace}, double *@var{result}, double *@var{abserr})This function computes the integral of the function @var{f} over thesemi-infinite interval @math{(-\infty,b)}.  The integral is mapped onto theregion @math{(0,1]} using the transformation @math{x = b - (1-t)/t},@tex\beforedisplay$$\int_{-\infty}^{b} dx \, f(x)   = \int_0^1 dt \, f(b - (1-t)/t)/t^2$$\afterdisplay@end tex@ifinfo@example\int_@{+\infty@}^@{b@} dx f(x) =      \int_0^1 dt f(b - (1-t)/t)/t^2@end example@end ifinfo@noindentand then integrated using the QAGS algorithm.@end deftypefun@node  QAWC adaptive integration for Cauchy principal values@section QAWC adaptive integration for Cauchy principal values@cindex Cauchy principal value, by numerical quadrature@deftypefun int gsl_integration_qawc (gsl_function *@var{f}, double @var{a}, double @var{b}, double @var{c}, double @var{epsabs}, double @var{epsrel}, size_t @var{limit}, gsl_integration_workspace * @var{workspace}, double * @var{result}, double * @var{abserr})This function computes the Cauchy principal value of the integral of@math{f} over @math{(a,b)}, with a singularity at @var{c},@tex\beforedisplay$$I = \int_a^b dx\, {f(x) \over x - c}  = \lim_{\epsilon \to 0} \left\{\int_a^{c-\epsilon} dx\, {f(x) \over x - c}+\int_{c+\epsilon}^b dx\, {f(x) \over x - c}\right\}$$\afterdisplay@end tex@ifinfo@exampleI = \int_a^b dx f(x) / (x - c)@end example@end ifinfo@noindentThe adaptive bisection algorithm of QAG is used, with modifications toensure that subdivisions do not occur at the singular point @math{x = c}.When a subinterval contains the point @math{x = c} or is close toit then a special 25-point modified Clenshaw-Curtis rule is used to controlthe singularity.  Further away from thesingularity the algorithm uses an ordinary 15-point Gauss-Kronrodintegration rule.@end deftypefun@node  QAWS adaptive integration for singular functions@section QAWS adaptive integration for singular functions

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -