# NAG FL Interfacea02abf (abs)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

a02abf returns the value of the modulus of the complex number $x=\left({x}_{r},{x}_{i}\right)$.

## 2Specification

Fortran Interface
 Function a02abf ( xr, xi)
 Real (Kind=nag_wp) :: a02abf Real (Kind=nag_wp), Intent (In) :: xr, xi
#include <nag.h>
 double a02abf_ (const double *xr, const double *xi)
The routine may be called by the names a02abf or nagf_complex_abs.

## 3Description

The function evaluates $\sqrt{{x}_{r}^{2}+{x}_{i}^{2}}$ by using $a\sqrt{1+{\left(\frac{b}{a}\right)}^{2}}$ where $a$ is the larger of $|{x}_{r}|$ and $|{x}_{i}|$, and $b$ is the smaller of $|{x}_{r}|$ and $|{x}_{i}|$. This ensures against unnecessary overflow and loss of accuracy when calculating $\left({x}_{r}^{2}+{x}_{i}^{2}\right)$.
Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

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

None.

## 7Accuracy

The result should be correct to machine precision.

## 8Parallelism and Performance

a02abf is not threaded in any implementation.

None.

## 10Example

This example finds the modulus of $-1.7+2.6i$.

### 10.1Program Text

Program Text (a02abfe.f90)

### 10.2Program Data

Program Data (a02abfe.d)

### 10.3Program Results

Program Results (a02abfe.r)