nag_quad_1d_fin_gonnet_vec (d01rgc) (PDF version)
d01 Chapter Contents
d01 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_quad_1d_fin_gonnet_vec (d01rgc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_quad_1d_fin_gonnet_vec (d01rgc) is a general purpose integrator which calculates an approximation to the integral of a function fx over a finite interval a,b:
I= ab fx dx .
The function is suitable as a general purpose integrator, and can be used when the integrand has singularities and infinities. In particular, the function can continue if the function f explicitly returns a quiet or signalling NaN or a signed infinity.

2  Specification

#include <nag.h>
#include <nagd01.h>
void  nag_quad_1d_fin_gonnet_vec (double a, double b,
void (*f)(const double x[], Integer nx, double fv[], Integer *iflag, Nag_Comm *comm),
double epsabs, double epsrel, double *dinest, double *errest, Integer *nevals, Nag_Comm *comm, NagError *fail)

3  Description

nag_quad_1d_fin_gonnet_vec (d01rgc) uses the algorithm described in Gonnet (2010). It is an adaptive algorithm, similar to the QUADPACK routine QAGS (see Piessens et al. (1983), see also nag_quad_1d_gen_vec_multi_rcomm (d01rac)) but includes significant differences regarding how the integrand is represented, how the integration error is estimated and how singularities and divergent integrals are treated. The local error estimation is described in Gonnet (2010).
nag_quad_1d_fin_gonnet_vec (d01rgc) requires a function to evaluate the integrand at an array of different points and is therefore amenable to parallel execution.

4  References

Gonnet P (2010) Increasing the reliability of adaptive quadrature using explicit interpolants ACM Trans. Math. software 37 26
Piessens R, de Doncker–Kapenga E, Überhuber C and Kahaner D (1983) QUADPACK, A Subroutine Package for Automatic Integration Springer–Verlag

5  Arguments

1:     adoubleInput
On entry: a, the lower limit of integration.
2:     bdoubleInput
On entry: b, the upper limit of integration. It is not necessary that a<b.
Note: if a=b, the function will immediately return dinest=0.0, errest=0.0 and nevals=0.
3:     ffunction, supplied by the userExternal Function
f must return the value of the integrand f at a set of points.
The specification of f is:
void  f (const double x[], Integer nx, double fv[], Integer *iflag, Nag_Comm *comm)
1:     x[nx]const doubleInput
On entry: the abscissae, xi, for i=1,2,,nx, at which function values are required.
2:     nxIntegerInput
On entry: the number of abscissae at which a function value is required.
3:     fv[nx]doubleOutput
On exit: fv must contain the values of the integrand f. fv[i-1]=fxi for all i=1,2,,nx.
4:     iflagInteger *Input/Output
On entry: iflag=0.
On exit: set iflag<0 to force an immediate exit with fail.code= NE_USER_STOP.
5:     commNag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to f.
userdouble *
iuserInteger *
The type Pointer will be void *. Before calling nag_quad_1d_fin_gonnet_vec (d01rgc) you may allocate memory and initialize these pointers with various quantities for use by f when called from nag_quad_1d_fin_gonnet_vec (d01rgc) (see Section in the Essential Introduction).
4:     epsabsdoubleInput
On entry: the absolute accuracy required.
If epsabs is negative, epsabs is used. See Section 7.
If epsabs=0.0, only the relative error will be used.
5:     epsreldoubleInput
On entry: the relative accuracy required.
If epsrel is negative, epsrel is used. See Section 7.
If epsrel=0.0, only the absolute error will be used otherwise the actual value of epsrel used by nag_quad_1d_fin_gonnet_vec (d01rgc) is maxmachine precision,epsrel.
Constraint: at least one of epsabs and epsrel must be nonzero.
6:     dinestdouble *Output
On exit: the estimate of the definite integral f.
7:     errestdouble *Output
On exit: the error estimate of the definite integral f.
8:     nevalsInteger *Output
On exit: the total number of points at which the integrand, f, has been evaluated.
9:     commNag_Comm *Communication Structure
The NAG communication argument (see Section in the Essential Introduction).
10:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

The requested accuracy was not achieved. Consider using larger values of epsabs and epsrel.
Dynamic memory allocation failed.
On entry, argument value had an illegal value.
The integral is probably divergent or slowly convergent.
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
Both epsabs=0.0 and epsrel=0.0.
Exit requested from f with iflag=value.

7  Accuracy

nag_quad_1d_fin_gonnet_vec (d01rgc) cannot guarantee, but in practice usually achieves, the following accuracy:
I-dinest tol ,
tol = max epsabs , epsrel × I ,
and epsabs and epsrel are user-specified absolute and relative error tolerances. Moreover, it returns the quantity errest which, in normal circumstances, satisfies
I-dinest errest tol .

8  Parallelism and Performance

nag_quad_1d_fin_gonnet_vec (d01rgc) is currently neither directly nor indirectly threaded. In particular, the user-supplied function f is not called from within a parallel region initialized inside nag_quad_1d_fin_gonnet_vec (d01rgc).
The user-supplied function f uses a vectorized interface, allowing for the required vector of function values to be evaluated in parallel; for example by placing appropriate OpenMP directives in the code for the user-supplied function f.

9  Further Comments

The time taken by nag_quad_1d_fin_gonnet_vec (d01rgc) depends on the integrand and the accuracy required.
nag_quad_1d_fin_gonnet_vec (d01rgc) is suitable for evaluating integrals that have singularities within the requested interval.
In particular, nag_quad_1d_fin_gonnet_vec (d01rgc) accepts non-finite values on return from the user-supplied function f, and will adapt the integration rule accordingly to eliminate such points. Non-finite values include NaNs and infinities.

10  Example

This example computes
-1 1 sinx x ln101 - x .

10.1  Program Text

Program Text (d01rgce.c)

10.2  Program Data


10.3  Program Results

Program Results (d01rgce.r)

nag_quad_1d_fin_gonnet_vec (d01rgc) (PDF version)
d01 Chapter Contents
d01 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2014