Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

## Purpose

nag_quad_1d_fin_smooth (d01bd) 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]$.

## Syntax

[result, abserr] = d01bd(f, a, b, epsabs, epsrel)
[result, abserr] = nag_quad_1d_fin_smooth(f, a, b, epsabs, epsrel)

## Description

nag_quad_1d_fin_smooth (d01bd) 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.

## References

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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{f}$ – function handle or string containing name of m-file
f must return the value of the integrand $f$ at a given point.
[result] = f(x)

Input Parameters

1:     $\mathrm{x}$ – double scalar
The point at which the integrand $f$ must be evaluated.

Output Parameters

1:     $\mathrm{result}$ – double scalar
The value of $f\left(x\right)$ evaluated at x.
2:     $\mathrm{a}$ – double scalar
$a$, the lower limit of integration.
3:     $\mathrm{b}$ – double scalar
$b$, the upper limit of integration. It is not necessary that $a.
4:     $\mathrm{epsabs}$ – double scalar
The absolute accuracy required. If epsabs is negative, the absolute value is used. See Accuracy.
5:     $\mathrm{epsrel}$ – double scalar
The relative accuracy required. If epsrel is negative, the absolute value is used. See Accuracy.

None.

### Output Parameters

1:     $\mathrm{result}$ – double scalar
The approximation to the integral $I$.
2:     $\mathrm{abserr}$ – double scalar
An estimate of the modulus of the absolute error, which should be an upper bound for $\left|I-{\mathbf{result}}\right|$.

## Error Indicators and Warnings

There are no specific errors detected by nag_quad_1d_fin_smooth (d01bd). 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.

## Accuracy

nag_quad_1d_fin_smooth (d01bd) 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|$.

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

## Example

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

fprintf('d01bd example results\n\n');

f = @(x) x^2*sin(10*pi*x);
a = 0;
b = 1;
epsabs = 0;
epsrel = 0.0001;

[result, abserr] = d01bd( ...
f, a, b, epsabs, epsrel);

fprintf('Result = %13.5f,  Standard error = %10.2e\n', result, abserr);

```
```d01bd example results

Result =      -0.03183,  Standard error =   1.34e-11
```