PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_complex_divide (a02ac)
Purpose
nag_complex_divide (a02ac) divides one complex number, , by a second complex number, , returning the result in .
Syntax
Description
The result
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:
– double scalar
- 2:
– double scalar
-
and , the real and imaginary parts of , respectively.
- 3:
– double scalar
- 4:
– double scalar
-
and , the real and imaginary parts of , respectively.
Optional Input Parameters
None.
Output Parameters
- 1:
– double scalar
- 2:
– double scalar
-
and , the real and imaginary parts of , 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 and .
Example
This example finds the value of .
Open in the MATLAB editor:
a02ac_example
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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015