nag_1d_quad_wt_cauchy (d01aqc) (PDF version)
d01 Chapter Contents
d01 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_1d_quad_wt_cauchy (d01aqc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_1d_quad_wt_cauchy (d01aqc) calculates an approximation to the Hilbert transform of a function g x  over a,b :
I = a b g x x-c dx
for user-specified values of a , b  and c .

2  Specification

#include <nag.h>
#include <nagd01.h>
void  nag_1d_quad_wt_cauchy (
double (*g)(double x),
double a, double b, double c, double epsabs, double epsrel, Integer max_num_subint, double *result, double *abserr, Nag_QuadProgress *qp, NagError *fail)

3  Description

nag_1d_quad_wt_cauchy (d01aqc) is based upon the QUADPACK routine QAWC (Piessens et al. (1983)) and integrates a function of the form g x w x , where the weight function
w x = 1 x-c
is that of the Hilbert transform. (If a < c < b  the integral has to be interpreted in the sense of a Cauchy principal value.) It is an adaptive function which employs a ‘global’ acceptance criterion (as defined by Malcolm and Simpson (1976)). Special care is taken to ensure that c  is never the end-point of a sub-interval (Piessens et al. (1976)). On each sub-interval c 1 , c 2  modified Clenshaw–Curtis integration of orders 12 and 24 is performed if c 1 - d c c 2 + d  where d = c 2 - c 1 / 20 . Otherwise the Gauss 7-point and Kronrod 15-point rules are used. The local error estimation is described by Piessens et al. (1983).

4  References

Malcolm M A and Simpson R B (1976) Local versus global strategies for adaptive quadrature ACM Trans. Math. Software 1 129–146
Piessens R, de Doncker–Kapenga E, Überhuber C and Kahaner D (1983) QUADPACK, A Subroutine Package for Automatic Integration Springer–Verlag
Piessens R, van Roy–Branders M and Mertens I (1976) The automatic evaluation of Cauchy principal value integrals Angew. Inf. 18 31–35

5  Arguments

1:     gfunction, supplied by the userExternal Function
g must return the value of the function g  at a given point.
The specification of g is:
double  g (double x)
1:     xdoubleInput
On entry: the point at which the function g  must be evaluated.
2:     adoubleInput
On entry: the lower limit of integration, a .
3:     bdoubleInput
On entry: the upper limit of integration, b . It is not necessary that a<b .
4:     cdoubleInput
On entry: the argument c  in the weight function.
Constraint: ca ​ or ​ b .
5:     epsabsdoubleInput
On entry: the absolute accuracy required. If epsabs is negative, the absolute value is used. See Section 7.
6:     epsreldoubleInput
On entry: the relative accuracy required. If epsrel is negative, the absolute value is used. See Section 7.
7:     max_num_subintIntegerInput
On entry: the upper bound on the number of sub-intervals into which the interval of integration may be divided by the function. The more difficult the integrand, the larger max_num_subint should be.
Constraint: max_num_subint1 .
8:     resultdouble *Output
On exit: the approximation to the integral I .
9:     abserrdouble *Output
On exit: an estimate of the modulus of the absolute error, which should be an upper bound for I - result .
10:   qpNag_QuadProgress *
Pointer to structure of type Nag_QuadProgress with the following members:
num_subintIntegerOutput
On exit: the actual number of sub-intervals used.
fun_countIntegerOutput
On exit: the number of function evaluations performed by nag_1d_quad_wt_cauchy (d01aqc).
sub_int_beg_ptsdouble *Output
sub_int_end_ptsdouble *Output
sub_int_resultdouble *Output
sub_int_errordouble *Output
On exit: these pointers are allocated memory internally with max_num_subint elements. If an error exit other than NE_INT_ARG_LT, NE_2_REAL_ARG_EQ or NE_ALLOC_FAIL occurs, these arrays will contain information which may be useful. For details, see Section 8.
Before a subsequent call to nag_1d_quad_wt_cauchy (d01aqc) is made, or when the information contained in these arrays is no longer useful, you should free the storage allocated by these pointers using the NAG macro NAG_FREE.
11:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_2_REAL_ARG_EQ
On entry, c=value  while a=value . These arguments must satisfy ca .
On entry, c=value  while b=value . These arguments must satisfy cb .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_INT_ARG_LT
On entry, max_num_subint must not be less than 1: max_num_subint=value .
NE_QUAD_BAD_SUBDIV
Extremely bad integrand behaviour occurs around the sub-interval value,value .
The same advice applies as in the case of NE_QUAD_MAX_SUBDIV.
NE_QUAD_MAX_SUBDIV
The maximum number of subdivisions has been reached: max_num_subint=value .
The maximum number of subdivisions has been reached without the accuracy requirements being achieved. Look at the integrand in order to determine the integration difficulties. Another integrator, which is designed for handling the type of difficulty involved, must be used. Alternatively, consider relaxing the accuracy requirements specified by epsabs and epsrel, or increasing the value of max_num_subint.
NE_QUAD_ROUNDOFF_TOL
Round-off error prevents the requested tolerance from being achieved: epsabs=value , epsrel=value .
The error may be underestimated. Consider relaxing the accuracy requirements specified by epsabs and epsrel.

7  Accuracy

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

8  Further Comments

The time taken by nag_1d_quad_wt_cauchy (d01aqc) depends on the integrand and the accuracy required.
If the function fails with an error exit other than NE_INT_ARG_LT, NE_2_REAL_ARG_EQ or NE_ALLOC_FAIL, then you may wish to examine the contents of the structure qp. These contain the end-points of the sub-intervals used by nag_1d_quad_wt_cauchy (d01aqc) along with the integral contributions and error estimates over the sub-intervals.
Specifically, for i=1,2,,n, let r i  denote the approximation to the value of the integral over the sub-interval a i , b i  in the partition of a,b  and e i  be the corresponding absolute error estimate.
Then, a i b i g x w x dx r i  and result = i=1 n r i . The value of n  is returned in qpnum_subint, and the values a i , b i , r i  and e i  are stored in the structure qp as

9  Example

This example computes
-1 1 dx x 2 + 0.01 2 x - 1 2 .

9.1  Program Text

Program Text (d01aqce.c)

9.2  Program Data

None.

9.3  Program Results

Program Results (d01aqce.r)


nag_1d_quad_wt_cauchy (d01aqc) (PDF version)
d01 Chapter Contents
d01 Chapter Introduction
NAG C Library Manual

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