Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

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=\left({x}_{r},{x}_{i}\right)$, by a second complex number, y = (yr,yi)$y=\left({y}_{r},{y}_{i}\right)$, returning the result in z = (zr,zi)$z=\left({z}_{r},{z}_{i}\right)$.

## Syntax

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

## Description

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

None.

None.

### Output Parameters

1:     zr – double scalar
2:     zi – double scalar
zr${z}_{r}$ and zi${z}_{i}$, the real and imaginary parts of z$z$, respectively.

None.

## Accuracy

The result should be correct to machine precision.

The time taken by nag_complex_divide (a02ac) is negligible.
This function must not be called with yr = 0.0${\mathbf{yr}}=0.0$ and yi = 0.0${\mathbf{yi}}=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

```