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)

Purpose

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

Syntax

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

Description

The function evaluates sqrt(xr2 + xi2)xr2+xi2 by using a×sqrt(1 + (b/a)2)a1+ (ba) 2 where aa is the larger of |xr||xr| and |xi||xi|, and bb is the smaller of |xr||xr| and |xi||xi|. This ensures against unnecessary overflow and loss of accuracy when calculating (xr2 + xi2)(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
xrxr and xixi, the real and imaginary parts of xx, respectively.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

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

function nag_complex_abs_example
xr = -1.7;
xi = 2.6;
[result] = nag_complex_abs(xr, xi)
 

result =

    3.1064


function a02ab_example
xr = -1.7;
xi = 2.6;
[result] = a02ab(xr, xi)
 

result =

    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–2013