NAG CL Interface
c05bac (lambertw_​real)

Settings help

CL Name Style:


1 Purpose

c05bac returns the real values of Lambert's W function W(x).

2 Specification

#include <nag.h>
double  c05bac (double x, Integer branch, Nag_Boolean offset, NagError *fail)
The function may be called by the names: c05bac, nag_roots_lambertw_real or nag_lambertw.

3 Description

c05bac 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
f(w) = wew   for   wC .  
The function f is many-to-one, and so, except at 0, W is multivalued. c05bac 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 W(x)+1. We denote by W0 the branch satisfying W0(x)−1 for all real x, and by W−1 the branch satisfying W−1(x)−1 for all real x. You may select your branch of interest using the argument 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 W(x): by setting offset=Nag_TRUE on entry you inform c05bac 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 Arguments

1: x double Input
On entry: if offset=Nag_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=Nag_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 Integer Input
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 Nag_Boolean Input
On entry: controls whether or not x is being specified as an offset from -exp(−1).
4: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_INT
On entry, branch=value.
Constraint: branch=0 or −1.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_REAL
On entry, branch=−1, offset=Nag_FALSE and x=value.
Constraint: if branch=−1 and offset=Nag_FALSE then x<0.0.
On entry, branch=−1, offset=Nag_TRUE and x=value.
Constraint: if branch=−1 and offset=Nag_TRUE then x<exp(-1.0).
On entry, offset=Nag_TRUE and x=value.
Constraint: if offset=Nag_TRUE then x0.0.
On entry, offset=Nag_FALSE and x=value.
Constraint: if offset=Nag_FALSE then x-exp(-1.0).
NW_REAL
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.

7 Accuracy

For a high percentage of legal x on input, c05bac is accurate to the number of decimal digits of precision on the host machine (see X02BEC). 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

c05bac is not threaded in any implementation.

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 (c05bace.c)

10.2 Program Data

Program Data (c05bace.d)

10.3 Program Results

Program Results (c05bace.r)