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

NAG Library Routine Document

C05BAF

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

C05BAF returns the real values of Lambert's W function Wx, via the routine name.

2  Specification

FUNCTION C05BAF ( X, BRANCH, OFFSET, IFAIL)
REAL (KIND=nag_wp) C05BAF
INTEGER  BRANCH, IFAIL
REAL (KIND=nag_wp)  X
LOGICAL  OFFSET

3  Description

C05BAF calculates an approximate value for the real branches of 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. C05BAF restricts W and its argument x to be real, resulting in a function defined for x-exp-1 and which is double valued on the interval -exp-1,0. This double-valued function is split into two real-valued branches according to the sign of Wx+1. We denote by W0 the branch satisfying W0x-1 for all real x, and by W-1 the branch satisfying W-1x-1 for all real x. You may select your branch of interest using the parameter BRANCH.
The precise method used to approximate W is described fully in Barry et al. (1995). For x close to -exp-1 greater accuracy comes from evaluating W-exp-1+Δx rather than Wx: by setting OFFSET=.TRUE. on entry you inform C05BAF that you are providing Δx, not x, in X.

4  References

Barry D J, Culligan–Hensley P J, and Barry S J (1995) Real values of the W-function ACM Trans. Math. Software 21(2) 161–171

5  Parameters

1:     X – REAL (KIND=nag_wp)Input
On entry: if OFFSET=.TRUE., X is the offset Δx from -exp-1 of the intended argument to W; that is, Wβ is computed, where β=-exp-1+Δx.
If OFFSET=.FALSE., X is the argument x of the function; that is, Wβ is computed, where β=x.
Constraints:
  • if BRANCH=0, -exp-1β;
  • if BRANCH=-1, -exp-1β<0.0.
2:     BRANCH – INTEGERInput
On entry: the real branch required.
BRANCH=0
The branch W0 is selected.
BRANCH=-1
The branch W-1 is selected.
Constraint: BRANCH=0 or -1.
3:     OFFSET – LOGICALInput
On entry: controls whether or not X is being specified as an offset from -exp-1.
4:     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: C05BAF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
IFAIL=1
On entry, BRANCH=value.
Constraint: BRANCH=0 or -1.
On entry, BRANCH=-1, OFFSET=.FALSE. and X=value.
Constraint: if BRANCH=-1 and OFFSET=.FALSE. then X<0.0.
On entry, BRANCH=-1, OFFSET=.TRUE. and X=value.
Constraint: if BRANCH=-1 and OFFSET=.TRUE. then X<exp-1.0.
On entry, OFFSET=.FALSE. and X=value.
Constraint: if OFFSET=.FALSE. then X-exp-1.0.
On entry, OFFSET=.TRUE. and X=value.
Constraint: if OFFSET=.TRUE. then X0.0.
IFAIL=2
For the given offset X, W is negligibly different from -1: X=value.
X is close to -exp-1. Enter X as an offset to -exp-1 for greater accuracy: X=value.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

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

8  Parallelism and Performance

Not applicable.

9  Further Comments

None.

10  Example

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

10.1  Program Text

Program Text (c05bafe.f90)

10.2  Program Data

Program Data (c05bafe.d)

10.3  Program Results

Program Results (c05bafe.r)


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

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