# NAG CL Interfaced01ubc (dim1_​inf_​exp_​wt)

Settings help

CL Name Style:

## 1Purpose

d01ubc returns the Gaussian quadrature approximation for the specific problem . The degrees of precision catered for are: $1$, $3$, $5$, $7$, $9$, $19$, $29$, $39$ and $49$, corresponding to values of $n=1$, $2$, $3$, $4$, $5$, $10$, $15$, $20$ and $25$, where $n$ is the number of weights.

## 2Specification

 #include
void  d01ubc (
 void (*f)(const double x[], double fv[], Integer n, Nag_Comm *comm, Integer *istop),
Integer n, double *ans, Nag_Comm *comm, NagError *fail)
The function may be called by the names: d01ubc, nag_quad_dim1_inf_exp_wt or nag_quad_1d_inf_exp_wt.

## 3Description

d01ubc uses the weights ${w}_{i}$ and the abscissae ${x}_{i}$ such that $\underset{0}{\overset{\infty }{\int }}\mathrm{exp}\left({-x}^{2}\right)f\left(x\right)$ is approximated by $\sum _{\mathit{i}=1}^{n}{w}_{i}f\left({x}_{i}\right)$ to maximum precision i.e., it is exact when $f\left(x\right)$ is a polynomial of degree $2n-1$.

## 4References

Golub G H and Welsch J H (1969) Calculation of Gauss quadrature rules Math. Comput. 23 221–230

## 5Arguments

1: $\mathbf{f}$function, supplied by the user External Function
f must return the integrand function values $f\left({x}_{i}\right)$ for the given ${x}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
The specification of f is:
 void f (const double x[], double fv[], Integer n, Nag_Comm *comm, Integer *istop)
1: $\mathbf{x}\left[{\mathbf{n}}\right]$const double Input
On entry: the points at which the integrand function $f$ must be evaluated.
2: $\mathbf{fv}\left[{\mathbf{n}}\right]$double Output
On exit: ${\mathbf{fv}}\left[\mathit{i}-1\right]$ must contain the value of the integrand $f\left({x}_{i}\right)$ evaluated at the point ${\mathbf{x}}\left[\mathit{i}-1\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{n}}$.
3: $\mathbf{n}$Integer Input
On entry: n specifies the number of weights and abscissae to be used.
4: $\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 d01ubc you may allocate memory and initialize these pointers with various quantities for use by f when called from d01ubc (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
5: $\mathbf{istop}$Integer * Input/Output
On entry: ${\mathbf{istop}}=0$.
On exit: you may set istop to a negative number if at any time it is impossible to evaluate the function $f\left(x\right)$. In this case d01ubc halts with fail set to the value of istop and the value returned in ans will be that of a non-signalling NaN.
2: $\mathbf{n}$Integer Input
On entry: n specifies the number of weights and abscissae to be used.
Constraint: ${\mathbf{n}}=1$, $2$, $3$, $4$, $5$, $10$, $15$, $20$ or $25$.
3: $\mathbf{ans}$double * Output
On exit: if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, ans contains an approximation to the integral. Otherwise, ans will be a non-signalling NaN.
4: $\mathbf{comm}$Nag_Comm *
The NAG communication argument (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
5: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: $1\le {\mathbf{n}}\le 25$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
n is not one of the allowed values.
NE_INTERNAL_ERROR
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_USER_STOP
The user has halted the calculation.

## 7Accuracy

The weights and abscissae have been calculated using quadruple precision arithmetic.

## 8Parallelism and Performance

d01ubc is not threaded in any implementation.

None.

## 10Example

This example computes an approximation to .

### 10.1Program Text

Program Text (d01ubce.c)

None.

### 10.3Program Results

Program Results (d01ubce.r)