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)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

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

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   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.

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:     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

None.

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.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

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 gnuplot_plot_2 −6 −4 −2 0 2 4 6 −6 −4 −2 0 2 4 6 −2.5 −2 −1.5 −1 −0.5 0 0.5 1 1.5 2 2.5
Figure 3: ImW0z
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 0 0.5 1 1.5 2 2.5
Figure 4: absW0z

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.
function c05bb_example


fprintf('c05bb example results\n\n');

branch = int64(0);
offset = false;
z = [0.5-i; 1+2.3*i; 4.5-0.1*i; 6+6*i];
fprintf('\nBranch = %d\n', branch);
if offset
  fprintf('Offset = true\n');
else
  fprintf('Offset = false\n');
end
fprintf('\n%12s%16s%18s%9s\n','z','w','resid','ifail');
for j =1:4
  [w, resid, ifail] = c05bb(branch, offset, z(j));
  fprintf('%10.1f %4.1fi', real(z(j)), imag(z(j)))
  fprintf('%10.5f %8.5fi %12.5e %3d\n', real(w), imag(w), resid, ifail);
end


c05bb example results


Branch = 0
Offset = false

           z               w             resid    ifail
       0.5 -1.0i   0.51651 -0.42205i  5.55112e-17   0
       1.0  2.3i   0.87361  0.57698i  1.11022e-16   0
       4.5 -0.1i   1.26735 -0.01242i  0.00000e+00   0
       6.0  6.0i   1.61492  0.49051i  1.25607e-15   0

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

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