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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

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

Syntax

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

Description

The result z 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
xr and xi, the real and imaginary parts of x, respectively.
3:     yr – double scalar
4:     yi – double scalar
yr and yi, the real and imaginary parts of y, respectively.

Optional Input Parameters

None.

Output Parameters

1:     zr – double scalar
2:     zi – double scalar
zr and zi, the real and imaginary parts of z, 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.0 and yi=0.0.

Example

This example finds the value of -1.7+2.6i/-3.1-0.9i.
function a02ac_example


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

xr = -1.7;
xi = 2.6;
yr = -3.1;
yi = -0.9;
x = xr+i*xi;
y = yr+i*yi;

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

z = zr+i*zi;

fprintf('The value of x/y, where\n');
fprintf('    x = ');
disp(x);
fprintf('and y = ');
disp(y);
fprintf('     is ');
disp(z);


a02ac example results

The value of x/y, where
    x =   -1.7000 + 2.6000i

and y =   -3.1000 - 0.9000i

     is    0.2812 - 0.9203i


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