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_divide (a02ac)

Purpose

nag_complex_divide (a02ac) divides one complex number, x = (xr,xi)x=(xr,xi), by a second complex number, y = (yr,yi)y=(yr,yi), returning the result in z = (zr,zi)z=(zr,zi).

Syntax

[zr, zi] = a02ac(xr, xi, yr, yi)
[zr, zi] = nag_complex_divide(xr, xi, yr, yi)

Description

The result zz is calculated using Smith's algorithm with scaling, from Li et al. (2002), which ensures that no unnecessary overflow or underflow occurs at intermediate stages of the computation.

References

Li X S, Demmel J W, Bailey D H, Henry G, Hida Y, Iskandar J, Kahan W, Kapur A, Martin M C, Tung T and Yoo D J (2002) Design, implementation and testing of extended and mixed precision BLAS ACM Trans. Math. Soft. 28(2) 152–205

Parameters

Compulsory Input Parameters

1:     xr – double scalar
2:     xi – double scalar
xrxr and xixi, the real and imaginary parts of xx, respectively.
3:     yr – double scalar
4:     yi – double scalar
yryr and yiyi, the real and imaginary parts of yy, respectively.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     zr – double scalar
2:     zi – double scalar
zrzr and zizi, the real and imaginary parts of zz, respectively.

Error Indicators and Warnings

None.

Accuracy

The result should be correct to machine precision.

Further Comments

The time taken by nag_complex_divide (a02ac) is negligible.
This function must not be called with yr = 0.0yr=0.0 and yi = 0.0yi=0.0.

Example

function nag_complex_divide_example
xr = -1.7;
xi = 2.6;
yr = -3.1;
yi = -0.9;
[zr, zi] = nag_complex_divide(xr, xi, yr, yi)
 

zr =

    0.2812


zi =

   -0.9203


function a02ac_example
xr = -1.7;
xi = 2.6;
yr = -3.1;
yi = -0.9;
[zr, zi] = a02ac(xr, xi, yr, yi)
 

zr =

    0.2812


zi =

   -0.9203



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