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_roots_lambertw_complex (c05bb)

## Purpose

nag_roots_lambertw_complex (c05bb) computes the values of Lambert's $W$ function $W\left(z\right)$.

## Syntax

[w, resid, ifail] = c05bb(branch, offset, z)
[w, resid, ifail] = nag_roots_lambertw_complex(branch, offset, z)

## Description

nag_roots_lambertw_complex (c05bb) calculates an approximate value for Lambert's $W$ function (sometimes known as the ‘product log’ or ‘Omega’ function), which is the inverse function of
 $fw = wew for w∈C .$
The function $f$ is many-to-one, and so, except at $0$, $W$ is multivalued. nag_roots_lambertw_complex (c05bb) allows you to specify the branch of $W$ on which you would like the results to lie by using the argument branch. Our choice of branch cuts is as in Corless et al. (1996), and the ranges of the branches of $W$ are summarised in Figure 1.
Figure 1: Ranges of the branches of $W\left(z\right)$
For more information about the closure of each branch, which is not displayed in Figure 1, see Corless et al. (1996). The dotted lines in the Figure denote the asymptotic boundaries of the branches, at multiples of $\pi$.
The precise method used to approximate $W$ is as described in Corless et al. (1996). For $z$ close to $-\mathrm{exp}\left(-1\right)$ greater accuracy comes from evaluating $W\left(-\mathrm{exp}\left(-1\right)+\Delta z\right)$ rather than $W\left(z\right)$: by setting on entry you inform nag_roots_lambertw_complex (c05bb) that you are providing $\Delta z$, not $z$, in z.

## References

Corless R M, Gonnet G H, Hare D E G, Jeffrey D J and Knuth D E (1996) On the Lambert $W$ function Advances in Comp. Math. 3 329–359

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{branch}$int64int32nag_int scalar
The branch required.
2:     $\mathrm{offset}$ – logical scalar
Controls whether or not z is being specified as an offset from $-\mathrm{exp}\left(-1\right)$.
3:     $\mathrm{z}$ – complex scalar
If , z is the offset $\Delta z$ from $-\mathrm{exp}\left(-1\right)$ of the intended argument to $W$; that is, $W\left(\beta \right)$ is computed, where $\beta =-\mathrm{exp}\left(-1\right)+\Delta z$.
If , z is the argument $z$ of the function; that is, $W\left(\beta \right)$ is computed, where $\beta =z$.

None.

### Output Parameters

1:     $\mathrm{w}$ – complex scalar
The value $W\left(\beta \right)$: see also the description of z.
2:     $\mathrm{resid}$ – double scalar
The residual $\left|W\left(\beta \right)\mathrm{exp}\left(W\left(\beta \right)\right)-\beta \right|$: see also the description of z.
3:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Note: nag_roots_lambertw_complex (c05bb) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

W  ${\mathbf{ifail}}=1$
For the given offset ${\mathbf{z}}$, $W$ is negligibly different from $-1$.
${\mathbf{z}}$ is close to $-\mathrm{exp}\left(-1\right)$.
W  ${\mathbf{ifail}}=2$
The iterative procedure used internally did not converge in $_$ iterations. Check the value of resid for the accuracy of w.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
${\mathbf{ifail}}=-999$
For a high percentage of ${\mathbf{z}}$, nag_roots_lambertw_complex (c05bb) is accurate to the number of decimal digits of precision on the host machine (see nag_machine_decimal_digits (x02be)). An extra digit may be lost on some platforms and for a small proportion of ${\mathbf{z}}$. This depends on the accuracy of the base-$10$ logarithm on your system.
The following figures show the principal branch of $W$.
Figure 2: $\mathrm{real}\left({W}_{0}\left(z\right)\right)$