s15ag returns the value of the scaled complementary error function erfcxx.

Syntax

C#
public static double s15ag(
	double x,
	out int ifail
)
Visual Basic
Public Shared Function s15ag ( _
	x As Double, _
	<OutAttribute> ByRef ifail As Integer _
) As Double
Visual C++
public:
static double s15ag(
	double x, 
	[OutAttribute] int% ifail
)
F#
static member s15ag : 
        x : float * 
        ifail : int byref -> float 

Parameters

x
Type: System..::..Double
On entry: the argument x of the function.
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]).

Return Value

s15ag returns the value of the scaled complementary error function erfcxx.

Description

s15ag calculates an approximate value for the scaled complementary error function
erfcxx=ex2erfcx=2πex2xe-t2dt=ex21-erfx.
Let x^ be the root of the equation erfcx-erfx=0 (then x^0.46875). For xx^ the value of erfcxx is based on the following rational Chebyshev expansion for erfx:
erfxxR,mx2,
where R,m denotes a rational function of degree  in the numerator and m in the denominator.
For x>x^ the value of erfcxx is based on a rational Chebyshev expansion for erfcx: for x^<x4 the value is based on the expansion
erfcxex2R,mx;
and for x>4 it is based on the expansion
erfcxex2x1π+1x2R,m1/x2.
For each expansion, the specific values of  and m are selected to be minimal such that the maximum relative error in the expansion is of the order 10-d, where d is the maximum number of decimal digits that can be accurately represented for the particular implementation (see x02be).
Asymptotically, erfcxx1/πx. There is a danger of setting underflow in erfcxx whenever xxhi=minxhuge,1/πxtiny, where xhuge is the largest positive model number (see x02al) and xtiny is the smallest positive model number (see x02ak). In this case s15ag exits with ifail=1 and returns erfcxx=0. For x in the range 1/2εx<xhi, where ε is the machine precision, the asymptotic value 1/πx is returned for erfcxx and s15ag exits with ifail=2.
There is a danger of setting overflow in ex2 whenever x<xneg=-logxhuge/2. In this case s15ag exits with ifail=3 and returns erfcxx=xhuge.
The values of xhi, 1/2ε and xneg are given in the Users' Note for your implementation.

References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Cody W J (1969) Rational Chebyshev approximations for the error function Math.Comp. 23 631–637

Error Indicators and Warnings

Note: s15ag may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
ifail=1
On entry, xxhi (see [Description]). On failure the function value returned is 0.
ifail=2
On entry, 1/2εx<xhi (see [Description]). On failure the function value returned is 1/πabsx.
ifail=3
On entry, x<xneg (see [Description]). On failure the function value returned is the largest positive model number.
ifail=-9000
An error occured, see message report.

Accuracy

The relative error in computing erfcxx may be estimated by evaluating
E=erfcxx-ex2n=1Inerfcxerfcxx,
where In denotes repeated integration. Empirical results suggest that on the interval x^,2 the loss in base b significant digits for maximum relative error is around 3.3, while for root-mean-square relative error on that interval it is 1.2 (see x02bh for the definition of the model parameter b). On the interval 2,20 the values are around 3.5 for maximum and 0.45 for root-mean-square relative errors; note that on these two intervals erfcx is the primary computation. See also [Accuracy] in s15ad.

Parallelism and Performance

None.

Further Comments

None.

Example

This example reads values of the argument x from a file, evaluates the function at each value of x and prints the results.

Example program (C#): s15age.cs

Example program data: s15age.d

Example program results: s15age.r

See Also