d01as calculates an approximation to the sine or the cosine transform of a function g over a,:
I=agxsinωxdx  or  I=agxcosωxdx
(for a user-specified value of ω).

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 ω in the weight function of the transform.
key
Type: System..::..Int32
On entry: indicates which integral is to be computed.
key=1
wx=cosωx.
key=2
wx=sinωx.
Constraint: 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 I-result.
limlst
Type: System..::..Int32
On entry: an upper bound on the number of intervals Ck needed for the integration.
Suggested value: limlst=50 is adequate for most problems.
Constraint: limlst3.
lst
Type: System..::..Int32%
On exit: the number of intervals Ck actually used for the integration.
erlst
Type: array<System..::..Double>[]()[][]
An array of size [limlst]
On exit: erlst[k-1] contains the error estimate corresponding to the integral contribution over the interval Ck, for k=1,2,,lst.
rslst
Type: array<System..::..Double>[]()[][]
An array of size [limlst]
On exit: rslst[k-1] contains the integral contribution over the interval Ck, for k=1,2,,lst.
ierlst
Type: array<System..::..Int32>[]()[][]
An array of size [limlst]
On exit: ierlst[k-1] contains the error flag corresponding to rslst[k-1], for k=1,2,,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: 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 gxwx over a semi-infinite interval, where wx is either sinωx or cosωx.
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 Ck are of constant length
c=2ω+1π/ω,  ω0,
where ω represents the largest integer less than or equal to ω. 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 a,. The algorithm, described in Piessens et al. (1983), incorporates a global acceptance criterion (as defined by Malcolm and Simpson (1976)) together with the ε-algorithm (see Wynn (1956)) to perform extrapolation. The local error estimation is described by Piessens et al. (1983).
If ω=0 and key=1, the method uses the same algorithm as d01am (with epsrel=0.0).
In contrast to the other methods in D01 class, d01as works only with an absolute error tolerance (epsabs). Over the interval Ck it attempts to satisfy the absolute accuracy requirement
EPSAk=Uk×epsabs,
where Uk=1-ppk-1, for k=1,2, and p=0.9.
However, when difficulties occur during the integration over the kth sub-interval Ck such that the error flag ierlst[k-1] 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 emSn 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.
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.
ifail=2
Round-off error prevents the requested tolerance from being achieved. Consider requesting less accuracy.
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 ifail=1.
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 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.
ifail=5
The integral is probably divergent, or slowly convergent. Please note that divergence can occur with any nonzero value of ifail.
ifail=6
On entry,key1 or 2,
orlimlst<3.
ifail=7
Bad integration behaviour occurs within one or more of the intervals Ck. Location and type of the difficulty involved can be determined from the vector ierlst.
ifail=8
Maximum number of intervals Ck (=limlst) allowed has been achieved. Increase the value of limlst to allow more cycles.
ifail=9
The extrapolation table constructed for convergence acceleration of the series formed by the integral contribution over the intervals Ck, does not converge to the required accuracy.
ifail=10
On entry,liw<2.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value
In the cases ifail=78 or 9, additional information about the cause of the error can be obtained from the array ierlst, as follows:
ierlst[k-1]=1
The maximum number of subdivisions=min_lw/4,liw/2 has been achieved on the kth interval.
ierlst[k-1]=2
Occurrence of round-off error is detected and prevents the tolerance imposed on the kth interval from being achieved.
ierlst[k-1]=3
Extremely bad integrand behaviour occurs at some points of the kth interval.
ierlst[k-1]=4
The integration procedure over the kth 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.
ierlst[k-1]=5
The integral over the kth interval is probably divergent or slowly convergent. It must be noted that divergence can occur with any other value of ierlst[k-1].

Accuracy

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

Parallelism and Performance

None.

Further Comments

None.

Example

This example computes
01xcosπx/2dx.

Example program (C#): d01ase.cs

Example program results: d01ase.r

See Also