C05BBF (PDF version)
C05 Chapter Contents
C05 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

C05BBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

C05BBF computes the values of Lambert's W function Wz.

2  Specification

SUBROUTINE C05BBF ( BRANCH, OFFSET, Z, W, RESID, IFAIL)
INTEGER  BRANCH, IFAIL
REAL (KIND=nag_wp)  RESID
COMPLEX (KIND=nag_wp)  Z, W
LOGICAL  OFFSET

3  Description

C05BBF 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   wC .
The function f is many-to-one, and so, except at 0, W is multivalued. C05BBF allows you to specify the branch of W on which you would like the results to lie by using the parameter 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.
Ranges of the branches of Wz
Figure 1: Ranges of the branches of Wz
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 π.
The precise method used to approximate W is as described in Corless et al. (1996). For z close to -exp-1 greater accuracy comes from evaluating W-exp-1+Δz rather than Wz: by setting OFFSET=.TRUE. on entry you inform C05BBF that you are providing Δz, not z, in Z.

4  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

5  Parameters

1:     BRANCH – INTEGERInput
On entry: the branch required.
2:     OFFSET – LOGICALInput
On entry: controls whether or not Z is being specified as an offset from -exp-1.
3:     Z – COMPLEX (KIND=nag_wp)Input
On entry: if OFFSET=.TRUE., Z is the offset Δz from -exp-1 of the intended argument to W; that is, Wβ is computed, where β=-exp-1+Δz.
If OFFSET=.FALSE., Z is the argument z of the function; that is, Wβ is computed, where β=z.
4:     W – COMPLEX (KIND=nag_wp)Output
On exit: the value Wβ: see also the description of Z.
5:     RESID – REAL (KIND=nag_wp)Output
On exit: the residual WβexpWβ-β: see also the description of Z.
6:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if IFAIL0 on exit, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: C05BBF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
IFAIL=1
Warning: the actual argument to W was very close to -exp-1. If IFAIL=0 or -1 on entry, the output message provides more details of the nature of the warning.
IFAIL=2
Warning: the iterative procedure used internally did not appear to be converging. Check the value of RESID for the accuracy of W.

7  Accuracy

For a high percentage of Z, C05BBF is accurate to the number of decimal digits of precision on the host machine (see X02BEF). An extra digit may be lost on some platforms and for a small proportion of Z. This depends on the accuracy of the base-10 logarithm on your system.

8  Further Comments

The following figures show the principal branch of W.
realW0z
Figure 2: realW0z
W0z
Figure 3: ImW0z
W0z
Figure 4: absW0z

9  Example

This example reads from a file the value of the required branch, whether or not the arguments to W are to be considered as offsets to -exp-1, and the arguments Z themselves. It then evaluates the function for these sets of input data Z and prints the results.

9.1  Program Text

Program Text (c05bbfe.f90)

9.2  Program Data

Program Data (c05bbfe.d)

9.3  Program Results

Program Results (c05bbfe.r)


C05BBF (PDF version)
C05 Chapter Contents
C05 Chapter Introduction
NAG Library Manual

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