hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_roots_lambertw_complex (c05bb)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


nag_roots_lambertw_complex (c05bb) computes the values of Lambert's W function Wz.


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


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   wC .  
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.
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 −3p −2p -p 0 π 2p 3p −10 −5 0 5 10 Branch −3 Branch −2 Branch −1 Principal Branch / Branch 0 Branch 1 Branch 2 Branch 3 gnuplot_plot_1 gnuplot_plot_2 gnuplot_plot_3 gnuplot_plot_4 gnuplot_plot_5 gnuplot_plot_6 gnuplot_plot_7 gnuplot_plot_8 gnuplot_plot_9 gnuplot_plot_10 gnuplot_plot_11 gnuplot_plot_12 gnuplot_plot_13 gnuplot_plot_14
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 on entry you inform nag_roots_lambertw_complex (c05bb) that you are providing Δz, not z, in z.


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


Compulsory Input Parameters

1:     branch int64int32nag_int scalar
The branch required.
2:     offset – logical scalar
Controls whether or not z is being specified as an offset from -exp-1.
3:     z – complex scalar
If , z is the offset Δz from -exp-1 of the intended argument to W; that is, Wβ is computed, where β=-exp-1+Δz.
If , z is the argument z of the function; that is, Wβ is computed, where β=z.

Optional Input Parameters


Output Parameters

1:     w – complex scalar
The value Wβ: see also the description of z.
2:     resid – double scalar
The residual WβexpWβ-β: see also the description of z.
3:     ifail int64int32nag_int scalar
ifail=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  ifail=1
For the given offset z, W is negligibly different from -1.
z is close to -exp-1.
W  ifail=2
The iterative procedure used internally did not converge in _ iterations. Check the value of resid for the accuracy of w.
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


For a high percentage of 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 z. This depends on the accuracy of the base-10 logarithm on your system.

Further Comments

The following figures show the principal branch of W.
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 gnuplot_plot_1 gnuplot_plot_2 −6 −4 −2 0 2 4 6 −6 −4 −2 0 2 4 6 −1 −0.5 0 0.5 1 1.5 2
Figure 2: realW0z
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 gnuplot_plot_1