PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_specfun_exp_complex (s01ea)
Purpose
nag_specfun_exp_complex (s01ea) evaluates the exponential function , for complex .
Syntax
Description
nag_specfun_exp_complex (s01ea) evaluates the exponential function , 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 , where and are the real and imaginary parts respectively of .
Since
and
are less than or equal to
in magnitude, it is possible that
may overflow although
or
does not. In this case the alternative formula
is used for the real part of the result, and
for the imaginary part. If either part of the result still overflows, a warning is returned through argument
ifail.
If
is too large, precision may be lost in the evaluation of
and
. Again, a warning is returned through
ifail.
References
None.
Parameters
Compulsory Input Parameters
- 1:
– complex scalar
-
The argument of the function.
Optional Input Parameters
None.
Output Parameters
- 1:
– complex scalar
The result of the function.
- 2:
– int64int32nag_int scalar
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
-
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
-
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
-
Both real and imaginary parts of the result overflow, and are set to the largest safe number with the correct signs.
- W
-
The computed result is accurate to less than half precision, due to the size of .
-
-
The computed result has no precision, due to the size of , and is set to zero.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Accuracy is limited in general only by the accuracy of the standard functions in the computation of
,
and
, where
,
. As
gets larger, precision will probably be lost due to argument reduction in the evaluation of the sine and cosine functions, until the warning error
occurs when
gets larger than
, where
is the
machine precision. Note that on some machines, the intrinsic functions SIN and COS will not operate on arguments larger than about
, and so
ifail can never return as
.
In the comparatively rare event that the result is computed by the formulae and , 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 from a file, evaluates the function at each value of and prints the results.
Open in the MATLAB editor:
s01ea_example
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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015