hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_specfun_erfc_complex (s15dd)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_specfun_erfc_complex (s15dd) computes values of the function wz=e-z2erfc-iz, for complex z.

Syntax

[result, ifail] = s15dd(z)
[result, ifail] = nag_specfun_erfc_complex(z)

Description

nag_specfun_erfc_complex (s15dd) computes values of the function wz=e-z2erfc-iz, where erfcz is the complementary error function
erfcz=2πze-t2dt,  
for complex z. The method used is that in Gautschi (1970) for z in the first quadrant of the complex plane, and is extended for z in other quadrants via the relations w-z=2e-z2-wz and wz¯=w-z¯. Following advice in Gautschi (1970) and van der Laan and Temme (1984), the code in Gautschi (1969) has been adapted to work in various precisions up to 18 decimal places. The real part of wz is sometimes known as the Voigt function.

References

Gautschi W (1969) Algorithm 363: Complex error function Comm. ACM 12 635
Gautschi W (1970) Efficient computation of the complex error function SIAM J. Numer. Anal. 7 187–198
van der Laan C G and Temme N M (1984) Calculation of special functions: the gamma function, the exponential integrals and error-like functions CWI Tract 10 Centre for Mathematics and Computer Science, Amsterdam

Parameters

Compulsory Input Parameters

1:     z – complex scalar
The argument z of the function.

Optional Input Parameters

None.

Output Parameters

1:     result – complex scalar
The result of the function.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

W  ifail=1
The real part of the result overflows, and is set to the largest safe number with the correct sign. The imaginary part of the result is meaningful.
W  ifail=2
The imaginary part of the result overflows, and is set to the largest safe number with the correct sign. The real part of the result is meaningful.
W  ifail=3
Both real and imaginary parts of the result overflow, and are set to the largest safe number with the correct signs.
W  ifail=4
The result returned is accurate to less than half precision, due to the size of an intermediate result.
   ifail=5
The result returned has no precision, due to the size of an intermediate result, and is set to zero.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

The accuracy of the returned result depends on the argument z. If z lies in the first or second quadrant of the complex plane (i.e., Imz is greater than or equal to zero), the result should be accurate almost to machine precision, except that there is a limit of about 18 decimal places on the achievable accuracy because constants in the function are given to this precision. With such arguments, ifail can only return as ifail=0.
If however Imz is less than zero, accuracy may be lost in two ways; firstly, in the evaluation of e-z2, if Im-z2 is large, in which case a warning will be issued through ifail=4 or 5; and secondly, near the zeros of the required function, where precision is lost due to cancellation, in which case no warning is given – the result has absolute accuracy rather than relative accuracy. Note also that in this half-plane, one or both parts of the result may overflow – this is signalled through ifail=1, 2 or 3.

Further Comments

The time taken for a call of nag_specfun_erfc_complex (s15dd) depends on the argument z, the time increasing as z0.0.
nag_specfun_erfc_complex (s15dd) may be used to compute values of erfcz and erfz for complex z by the relations erfcz=e-z2wiz, erfz=1-erfcz. (For double arguments, nag_specfun_erfc_real (s15ad) and nag_specfun_erf_real (s15ae) should be used.)

Example

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


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

z = [ 1    + 1e-9i;
     -3.01 + 0.75i;
      2.75 - 1.52i;
     -1.33 - 0.54i];
n = size(z,1);
w = z;

for j=1:n
  [w(j), ifail] = s15dd(z(j));
end

disp('         z                w(z)');
disp([z w]);


s15dd example results

         z                w(z)
   1.0000 + 0.0000i   0.3679 + 0.6072i
  -3.0100 + 0.7500i   0.0522 - 0.1838i
   2.7500 - 1.5200i  -0.1015 + 0.1654i
  -1.3300 - 0.5400i  -0.1839 - 0.7891i


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015