d01as calculates an approximation to the sine or the cosine transform of a function $g$ over $\left[a,\infty \right)$:
 $I=∫a∞gxsinωxdx or I=∫a∞gxcosωxdx$
(for a user-specified value of $\omega$).

# Syntax

C#
```public static void d01as(
D01..::..D01AS_G g,
double a,
double omega,
int key,
double epsabs,
out double result,
out double abserr,
int limlst,
out int lst,
double[] erlst,
double[] rslst,
int[] ierlst,
out int subintvls,
out int ifail
)```
Visual Basic
```Public Shared Sub d01as ( _
g As D01..::..D01AS_G, _
a As Double, _
omega As Double, _
key As Integer, _
epsabs As Double, _
<OutAttribute> ByRef result As Double, _
<OutAttribute> ByRef abserr As Double, _
limlst As Integer, _
<OutAttribute> ByRef lst As Integer, _
erlst As Double(), _
rslst As Double(), _
ierlst As Integer(), _
<OutAttribute> ByRef subintvls As Integer, _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void d01as(
D01..::..D01AS_G^ g,
double a,
double omega,
int key,
double epsabs,
[OutAttribute] double% result,
[OutAttribute] double% abserr,
int limlst,
[OutAttribute] int% lst,
array<double>^ erlst,
array<double>^ rslst,
array<int>^ ierlst,
[OutAttribute] int% subintvls,
[OutAttribute] int% ifail
)```
F#
```static member d01as :
g : D01..::..D01AS_G *
a : float *
omega : float *
key : int *
epsabs : float *
result : float byref *
abserr : float byref *
limlst : int *
lst : int byref *
erlst : float[] *
rslst : float[] *
ierlst : int[] *
subintvls : int byref *
ifail : int byref -> unit
```

#### Parameters

g
Type: NagLibrary..::..D01..::..D01AS_G
g must return the value of the function $g$ at a given point x.

A delegate of type D01AS_G.

a
Type: System..::..Double
On entry: $a$, the lower limit of integration.
omega
Type: System..::..Double
On entry: the parameter $\omega$ in the weight function of the transform.
key
Type: System..::..Int32
On entry: indicates which integral is to be computed.
${\mathbf{key}}=1$
$w\left(x\right)=\mathrm{cos}\left(\omega x\right)$.
${\mathbf{key}}=2$
$w\left(x\right)=\mathrm{sin}\left(\omega x\right)$.
Constraint: ${\mathbf{key}}=1$ or $2$.
epsabs
Type: System..::..Double
On entry: the absolute accuracy required. If epsabs is negative, the absolute value is used. See [Accuracy].
result
Type: System..::..Double%
On exit: the approximation to the integral $I$.
abserr
Type: System..::..Double%
On exit: an estimate of the modulus of the absolute error, which should be an upper bound for $\left|I-{\mathbf{result}}\right|$.
limlst
Type: System..::..Int32
On entry: an upper bound on the number of intervals ${C}_{k}$ needed for the integration.
Suggested value: ${\mathbf{limlst}}=50$ is adequate for most problems.
Constraint: ${\mathbf{limlst}}\ge 3$.
lst
Type: System..::..Int32%
On exit: the number of intervals ${C}_{k}$ actually used for the integration.
erlst
Type: array<System..::..Double>[]()[][]
An array of size [limlst]
On exit: ${\mathbf{erlst}}\left[\mathit{k}-1\right]$ contains the error estimate corresponding to the integral contribution over the interval ${C}_{\mathit{k}}$, for $\mathit{k}=1,2,\dots ,{\mathbf{lst}}$.
rslst
Type: array<System..::..Double>[]()[][]
An array of size [limlst]
On exit: ${\mathbf{rslst}}\left[\mathit{k}-1\right]$ contains the integral contribution over the interval ${C}_{\mathit{k}}$, for $\mathit{k}=1,2,\dots ,{\mathbf{lst}}$.
ierlst
Type: array<System..::..Int32>[]()[][]
An array of size [limlst]
On exit: ${\mathbf{ierlst}}\left[\mathit{k}-1\right]$ contains the error flag corresponding to ${\mathbf{rslst}}\left[\mathit{k}-1\right]$, for $\mathit{k}=1,2,\dots ,{\mathbf{lst}}$. See [Error Indicators and Warnings].
subintvls
Type: System..::..Int32%
On exit: subintvls contains the actual number of sub-intervals used.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

d01as is based on the QUADPACK routine QAWFE (see Piessens et al. (1983)). It is an adaptive method, designed to integrate a function of the form $g\left(x\right)w\left(x\right)$ over a semi-infinite interval, where $w\left(x\right)$ is either $\mathrm{sin}\left(\omega x\right)$ or $\mathrm{cos}\left(\omega x\right)$.
Over successive intervals
 $Ck=a+k-1c,a+kc, k=1,2,…,lst$
integration is performed by the same algorithm as is used by d01an. The intervals ${C}_{k}$ are of constant length
 $c=2ω+1π/ω, ω≠0,$
where $\left[\left|\omega \right|\right]$ represents the largest integer less than or equal to $\left|\omega \right|$. Since $c$ equals an odd number of half periods, the integral contributions over succeeding intervals will alternate in sign when the function $g$ is positive and monotonically decreasing over $\left[a,\infty \right)$. The algorithm, described in Piessens et al. (1983), incorporates a global acceptance criterion (as defined by Malcolm and Simpson (1976)) together with the $\epsilon$-algorithm (see Wynn (1956)) to perform extrapolation. The local error estimation is described by Piessens et al. (1983).
If $\omega =0$ and ${\mathbf{key}}=1$, the method uses the same algorithm as d01am (with ${\mathbf{epsrel}}=0.0$).
In contrast to the other methods in D01 class, d01as works only with an absolute error tolerance (epsabs). Over the interval ${C}_{k}$ it attempts to satisfy the absolute accuracy requirement
 $EPSAk=Uk×epsabs,$
where ${U}_{\mathit{k}}=\left(1-p\right){p}^{\mathit{k}-1}$, for $\mathit{k}=1,2,\dots$ and $p=0.9$.
However, when difficulties occur during the integration over the $k$th sub-interval ${C}_{k}$ such that the error flag ${\mathbf{ierlst}}\left[k-1\right]$ is nonzero, the accuracy requirement over subsequent intervals is relaxed. See Piessens et al. (1983) for more details.

# 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
Wynn P (1956) On a device for computing the ${e}_{m}\left({S}_{n}\right)$ transformation Math. Tables Aids Comput. 10 91–96

# Error Indicators and Warnings

Note: d01as may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (W, LW, IW) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
${\mathbf{ifail}}=1$
The maximum number of subdivisions allowed with the given workspace has been reached without the accuracy requirements being achieved. Look at the integrand in order to determine the integration difficulties. If the position of a local difficulty within the interval can be determined (e.g., a singularity of the integrand or its derivative, a peak, a discontinuity, etc.) you will probably gain from splitting up the interval at this point and calling d01as on the infinite subrange and an appropriate integrator on the finite subrange. Alternatively, consider relaxing the accuracy requirements specified by epsabs or increasing the amount of workspace.
${\mathbf{ifail}}=2$
Round-off error prevents the requested tolerance from being achieved. Consider requesting less accuracy.
${\mathbf{ifail}}=3$
Extremely bad local integrand behaviour causes a very strong subdivision around one (or more) points of the interval. The same advice applies as in the case of ${\mathbf{ifail}}={1}$.
${\mathbf{ifail}}=4$
The requested tolerance cannot be achieved because the extrapolation does not increase the accuracy satisfactorily; the returned result is the best which can be obtained. The same advice applies as in the case of ${\mathbf{ifail}}={1}$.
Look at the integrand in order to determine the integration difficulties. If the position of a local difficulty within the interval can be determined (e.g., a singularity of the integrand or its derivative, a peak, a discontinuity etc.) you will probably gain from splitting up the interval at this point and calling d01as on the infinite subrange and an appropriate integrator on the finite subrange. Alternatively, consider relaxing the accuracy requirements specified by epsabs or increasing the amount of workspace.
Please note that divergence can occur with any nonzero value of ifail.
${\mathbf{ifail}}=5$
The integral is probably divergent, or slowly convergent. Please note that divergence can occur with any nonzero value of ifail.
${\mathbf{ifail}}=6$
 On entry, ${\mathbf{key}}\ne 1$ or $2$, or ${\mathbf{limlst}}<3$.
${\mathbf{ifail}}=7$
Bad integration behaviour occurs within one or more of the intervals ${C}_{k}$. Location and type of the difficulty involved can be determined from the vector ierlst.
${\mathbf{ifail}}=8$
Maximum number of intervals ${C}_{k}$ ($\text{}={\mathbf{limlst}}$) allowed has been achieved. Increase the value of limlst to allow more cycles.
${\mathbf{ifail}}=9$
The extrapolation table constructed for convergence acceleration of the series formed by the integral contribution over the intervals ${C}_{k}$, does not converge to the required accuracy.
${\mathbf{ifail}}=10$
 On entry, ${\mathbf{liw}}<2$.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$
In the cases ${\mathbf{ifail}}={7}$${8}$ or ${9}$, additional information about the cause of the error can be obtained from the array ierlst, as follows:
${\mathbf{ierlst}}\left[k-1\right]=1$
The maximum number of $\text{subdivisions}=\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(\mathbf{_lw}/4,{\mathbf{liw}}/2\right)$ has been achieved on the $k$th interval.
${\mathbf{ierlst}}\left[k-1\right]=2$
Occurrence of round-off error is detected and prevents the tolerance imposed on the $k$th interval from being achieved.
${\mathbf{ierlst}}\left[k-1\right]=3$
Extremely bad integrand behaviour occurs at some points of the $k$th interval.
${\mathbf{ierlst}}\left[k-1\right]=4$
The integration procedure over the $k$th interval does not converge (to within the required accuracy) due to round-off in the extrapolation procedure invoked on this interval. It is assumed that the result on this interval is the best which can be obtained.
${\mathbf{ierlst}}\left[k-1\right]=5$
The integral over the $k$th interval is probably divergent or slowly convergent. It must be noted that divergence can occur with any other value of ${\mathbf{ierlst}}\left[k-1\right]$.

# Accuracy

d01as cannot guarantee, but in practice usually achieves, the following accuracy:
 $I-result≤epsabs,$
where epsabs is the user-specified absolute error tolerance. Moreover, it returns the quantity abserr, which, in normal circumstances, satisfies
 $I-result≤abserr≤epsabs.$

# Parallelism and Performance

None.

 $∫0∞1xcosπx/2dx.$