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_complex_abs (a02ab)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_complex_abs (a02ab) returns the value of the modulus of the complex number x=xr,xi.

Syntax

[result] = a02ab(xr, xi)
[result] = nag_complex_abs(xr, xi)

Description

The function evaluates xr2+xi2 by using a1+ ba 2 where a is the larger of xr and xi, and b is the smaller of xr and xi. This ensures against unnecessary overflow and loss of accuracy when calculating xr2+xi2.

References

Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

Parameters

Compulsory Input Parameters

1:     xr – double scalar
2:     xi – double scalar
xr and xi, the real and imaginary parts of x, respectively.

Optional Input Parameters

None.

Output Parameters

1:     result – double scalar
The result of the function.

Error Indicators and Warnings

None.

Accuracy

The result should be correct to machine precision.

Further Comments

None.

Example

This example finds the modulus of -1.7+2.6i.
function a02ab_example


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

xr = -1.7;
xi = 2.6;
x = xr + i*xi;

[absx] = a02ab(xr, xi);

fprintf('The modulus of ');
disp(x);
fprintf('            is ');
disp(absx);


a02ab example results

The modulus of   -1.7000 + 2.6000i

            is     3.1064


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