# NAG C Library Function Document

## 1Purpose

nag_quad_1d_fin_smooth (d01bdc) calculates an approximation to the integral of a function over a finite interval $\left[a,b\right]$:
 $I= ∫ab fx dx .$
It is non-adaptive and as such is recommended for the integration of ‘smooth’ functions. These exclude integrands with singularities, derivative singularities or high peaks on $\left[a,b\right]$, or which oscillate too strongly on $\left[a,b\right]$.

## 2Specification

 #include #include
 double (*f)(double x, Nag_Comm *comm),
double a, double b, double epsabs, double epsrel, double *result, double *abserr, Nag_Comm *comm)

## 3Description

nag_quad_1d_fin_smooth (d01bdc) is based on the QUADPACK routine QNG (see Piessens et al. (1983)). It is a non-adaptive function which uses as its basic rules, the Gauss $10$-point and $21$-point formulae. If the accuracy criterion is not met, formulae using $43$ and $87$ points are used successively, stopping whenever the accuracy criterion is satisfied.
This function is designed for smooth integrands only.

## 4References

Patterson T N L (1968) The Optimum addition of points to quadrature formulae Math. Comput. 22 847–856
Piessens R, de Doncker–Kapenga E, Überhuber C and Kahaner D (1983) QUADPACK, A Subroutine Package for Automatic Integration Springer–Verlag

## 5Arguments

1:    $\mathbf{f}$function, supplied by the userExternal Function
f must return the value of the integrand $f$ at a given point.
The specification of f is:
 double f (double x, Nag_Comm *comm)
1:    $\mathbf{x}$doubleInput
On entry: the point at which the integrand $f$ must be evaluated.
2:    $\mathbf{comm}$Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to f.
userdouble *
iuserInteger *
pPointer
The type Pointer will be void *. Before calling nag_quad_1d_fin_smooth (d01bdc) you may allocate memory and initialize these pointers with various quantities for use by f when called from nag_quad_1d_fin_smooth (d01bdc) (see Section 3.3.1.1 in How to Use the NAG Library and its Documentation).
Note: f should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by nag_quad_1d_fin_smooth (d01bdc). If your code inadvertently does return any NaNs or infinities, nag_quad_1d_fin_smooth (d01bdc) is likely to produce unexpected results.
2:    $\mathbf{a}$doubleInput
On entry: $a$, the lower limit of integration.
3:    $\mathbf{b}$doubleInput
On entry: $b$, the upper limit of integration. It is not necessary that $a.
4:    $\mathbf{epsabs}$doubleInput
On entry: the absolute accuracy required. If epsabs is negative, the absolute value is used. See Section 7.
5:    $\mathbf{epsrel}$doubleInput
On entry: the relative accuracy required. If epsrel is negative, the absolute value is used. See Section 7.
6:    $\mathbf{result}$double *Output
On exit: the approximation to the integral $I$.
7:    $\mathbf{abserr}$double *Output
On exit: an estimate of the modulus of the absolute error, which should be an upper bound for $\left|I-{\mathbf{result}}\right|$.
8:    $\mathbf{comm}$Nag_Comm *
The NAG communication argument (see Section 3.3.1.1 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

There are no specific errors detected by nag_quad_1d_fin_smooth (d01bdc). However, if abserr is greater than
 $maxepsabs,epsrel×result$
this indicates that the function has probably failed to achieve the requested accuracy within $87$ function evaluations.

## 7Accuracy

nag_quad_1d_fin_smooth (d01bdc) attempts to compute an approximation, result, such that:
 $I-result ≤ tol ,$
where
 $tol = max epsabs , epsrel × I ,$
and epsabs and epsrel are user-specified absolute and relative error tolerances. There can be no guarantee that this is achieved, and you are advised to subdivide the interval if you have any doubts about the accuracy obtained. Note that abserr contains an estimated bound on $\left|I-{\mathbf{result}}\right|$.

## 8Parallelism and Performance

The time taken by nag_quad_1d_fin_smooth (d01bdc) depends on the integrand and the accuracy required.

## 10Example

This example computes
 $∫ 0 1 x2 sin10πx dx .$

### 10.1Program Text

Program Text (d01bdce.c)

### 10.2Program Data

Program Data (d01bdce.d)

### 10.3Program Results

Program Results (d01bdce.r)