NuMFor 9f2ab49 (2024-04-08)
Numerical (Modern) Fortran. Library for Simple Numerical computing
qags Interface Reference

Subroutine qags is a globally adaptive, automatic interval subdivisions with epsilon extrapolation without weights. More...

Detailed Description

Subroutine qags is a globally adaptive, automatic interval subdivisions with epsilon extrapolation without weights.

The routine calculates an approximation $J$ to a definite integral applying adaptively the Gauss-Kronrod 21-point integration rule.

Parameters
[in]fThe function to integrate
[in]a(real) lower limit of integration
[in]b(real) upper limit of integration
[in]args(real, array, optional) extra arguments (if needed) to be passed to the function f
[out]IntVal(same kind as f) Approximation to integral
[in]epsabs(real, optional) Absolute accuracy requested. Default = 1.e-7
[in]epsrel(real, optional) Relative accuracy requested. Default = 1.e-5
[in]gkrule(char(len=4), optional) Choice of integration rule Possible values are: 'qk15', 'qk21', 'qk31', 'qk41', 'qk51', 'qk61'. Default = 'qk21'.
[out]abserr(real, optional) Estimation of absolute error achieved
[out]neval(integer, optional) Number of function evaluations performed
[out]ier(integer, optional) Error code
[in,out]info(optional) Information and workspace. Must be of type d_qp_extra for integration of real functions and of type c_qp_extra for integration of complex functions
Remarks
(from gsl) The presence of an integrable singularity in the integration region causes an adaptive routine to concentrate new subintervals around the singularity. As the subintervals decrease in size the successive approximations to the integral converge in a limiting fashion. This approach to the limit can be accelerated using an extrapolation procedure. The QAGS algorithm combines adaptive bisection with the Wynn epsilon-algorithm to speed-up the integration of many types of integrable singularities.

Either or both limits of integration may be infinite. By default it uses a Gauss-Kronrod rule of 21 points for finite limits.

For infinite limits use nf_minf for "minus infinite" and nf_inf for "plus infinite". A 15-points Gauss-Kronrod rule will be used by default but it will be overriden by the argument gkrule.

The integration over the semi-infinite interval $(a,+\infty)$ is performed by means of the mapping $x = a + (1-t)/t$, onto the semi-open interval $(0,1]$.

\[
 \int_{a}^{+\infty} dx f(x) = \int_0^1 dt f(a + (1-t)/t)/t^2
 \]

The integration over the semi-infinite interval $(-\infty, b)$ is performed by means of the mapping $x = b - (1-t)/t$, onto the semi-open interval $(0,1]$.

\[
 \int_{-\infty}^{b} dx f(x) = \int_0^1 dt f(b - (1-t)/t)/t^2
 \]

The integral over the infinite interval $(-\infty,+\infty)$ is performed combining the two methods before, i.e: mapping $x = (1-t)/t$ onto the semi-open interval $(0,1]$

\[\int_{-\infty}^{+\infty}dx f(x)=\int_0^1 dt\Big(f((1 - t) / t) + f(-(1 - t) / t) \Big) / t^2.\]

Example:

real(dp) :: Integ1
intrinsic dsin
print "(A)", center(" Integrate sin(x) between 0 and pi ", 70, '-')
call qags(dsin, zero, m_pi, integ1)
print "(A)", 'integrate(sin(x), 0, pi) = '//str(integ1)//" (Difference="//str(abs(2 - integ1))//")"
! that prints:
!------------------ Integrate sin(x) between 0 and pi -----------------
! integrate(sin(x), 0, pi) = 1.9999999827467 (Difference=1.725330678326e-08)

The documentation for this interface was generated from the following file: