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_exp_complex (s01ea)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_specfun_exp_complex (s01ea) evaluates the exponential function ez, for complex z.

Syntax

[result, ifail] = s01ea(z)
[result, ifail] = nag_specfun_exp_complex(z)

Description

nag_specfun_exp_complex (s01ea) evaluates the exponential function ez, taking care to avoid machine overflow, and giving a warning if the result cannot be computed to more than half precision. The function is evaluated as ez=excosy+isiny, where x and y are the real and imaginary parts respectively of z.
Since cosy and siny are less than or equal to 1 in magnitude, it is possible that ex may overflow although excosy or exsiny does not. In this case the alternative formula signcosyex+lncosy is used for the real part of the result, and signsinyex+lnsiny for the imaginary part. If either part of the result still overflows, a warning is returned through argument ifail.
If Imz is too large, precision may be lost in the evaluation of siny and cosy. Again, a warning is returned through ifail.

References

None.

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 computed result is accurate to less than half precision, due to the size of Imz.
   ifail=5
The computed result has no precision, due to the size of Imz, 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

Accuracy is limited in general only by the accuracy of the standard functions in the computation of siny, cosy and ex, where x=Rez, y=Imz. As y gets larger, precision will probably be lost due to argument reduction in the evaluation of the sine and cosine functions, until the warning error ifail=4 occurs when y gets larger than 1/ε, where ε is the machine precision. Note that on some machines, the intrinsic functions SIN and COS will not operate on arguments larger than about 1/ε, and so ifail can never return as 4.
In the comparatively rare event that the result is computed by the formulae signcosyex+lncosy and signsinyex+lnsiny, a further small loss of accuracy may be expected due to rounding errors in the logarithmic function.

Further Comments

None.

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 s01ea_example


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

n = 4;
z(1:n) = [1 + 1.e-9i    -0.5 + 2i     0.0 - 2i    -2.5 - 1.5i];
result = z;

for j=1:n
  [result(j), ifail] = s01ea(z(j));
end

disp('         z                 exp(z)');
disp([z; result]');


s01ea example results

         z                 exp(z)
   1.0000 - 0.0000i   2.7183 - 0.0000i
  -0.5000 - 2.0000i  -0.2524 - 0.5515i
   0.0000 + 2.0000i  -0.4161 + 0.9093i
  -2.5000 + 1.5000i   0.0058 + 0.0819i


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