# NAG Library Routine Document

## 1Purpose

a02acf divides one complex number, $x=\left({x}_{r},{x}_{i}\right)$, by a second complex number, $y=\left({y}_{r},{y}_{i}\right)$, returning the result in $z=\left({z}_{r},{z}_{i}\right)$.

## 2Specification

Fortran Interface
 Subroutine a02acf ( xr, xi, yr, yi, zr, zi)
 Real (Kind=nag_wp), Intent (In) :: xr, xi, yr, yi Real (Kind=nag_wp), Intent (Out) :: zr, zi
#include nagmk26.h
 void a02acf_ (const double *xr, const double *xi, const double *yr, const double *yi, double *zr, double *zi)

## 3Description

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.
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

## 5Arguments

1:     $\mathbf{xr}$ – Real (Kind=nag_wp)Input
2:     $\mathbf{xi}$ – Real (Kind=nag_wp)Input
On entry: ${x}_{r}$ and ${x}_{i}$, the real and imaginary parts of $x$, respectively.
3:     $\mathbf{yr}$ – Real (Kind=nag_wp)Input
4:     $\mathbf{yi}$ – Real (Kind=nag_wp)Input
On entry: ${y}_{r}$ and ${y}_{i}$, the real and imaginary parts of $y$, respectively.
5:     $\mathbf{zr}$ – Real (Kind=nag_wp)Output
6:     $\mathbf{zi}$ – Real (Kind=nag_wp)Output
On exit: ${z}_{r}$ and ${z}_{i}$, the real and imaginary parts of $z$, respectively.

None.

## 7Accuracy

The result should be correct to machine precision.

## 8Parallelism and Performance

a02acf is not threaded in any implementation.

The time taken by a02acf is negligible.
This routine must not be called with ${\mathbf{yr}}=0.0$ and ${\mathbf{yi}}=0.0$.

## 10Example

This example finds the value of $\left(-1.7+2.6i\right)/\left(-3.1-0.9i\right)$.

### 10.1Program Text

Program Text (a02acfe.f90)

### 10.2Program Data

Program Data (a02acfe.d)

### 10.3Program Results

Program Results (a02acfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017