File:LambertWplotT.png

Explicit plot of the LambertW function, in compare to its inverse function zex.

$y=\mathrm{zex}(x)=x\, \exp(x)$, light green curve

$y=\mathrm{LambertW}(x)=\mathrm{zex}^{-1}(x)$, dark brown curve

C++ Generator of curves
// Files ado.cin, tania.cin, LambertWoCoe.inc, LambertWeCoe.cin should be loaded to the working directory in order to compile the code below

using namespace std; typedef complex z_type;
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) define DB double
 * 5) define DO(x,y) for(x=0;x0;n--){ s+=LambertWoCoe[n]; s*=d;} return z*(1.+s); }
 * 1) include "LambertWoCoe.inc"

z_type LambertWe(z_type z){ int n,m=100; z_type t=1./M_E+z; t*=2*M_E; t=sqrt(t); z_type s=LambertWeCoe[m]*t; for(n=m-1; n>0; n--) { s+=LambertWeCoe[n]; s*=t;} return -1.+s;}
 * 1) include "LambertWeCoe.cin"

z_type LambertW(z_type z){ if( abs(z)<.2 ) return LambertWo(z); if( abs(1./M_E+z)<.2 ) return LambertWe(z); return Tania(log(z)-1.);} // Except the negative part of the real axis, Tania does the LambertW well.

main{ int j,k,m,n; DB x,y, a; z_type z; FILE *o;o=fopen("LambertWplot.eps","w");ado(o,610,410); fprintf(o,"204 104 translate\n 100 100 scale\n"); for(m=-2;m<5;m++){ M(m,-1)L(m,3)} for(n=-1;n<4;n++){ M(-2,n)L(4,n)} fprintf(o,"2 setlinecap 1 setlinejoin .01 W 0 0 0 RGB S 1 setlinecap\n"); for(n=0;n<310;n+=2){x=-2.02+.01*n; y=x*exp(x); if(n==0)M(x,y) else L(x,y) } fprintf(o,".03 W 0 .8 0 RGB S\n"); DO(n,500){ x=-1./M_E+.01*n; y=Re(LambertW(x)); if(n==0)M(x,y) else L(x,y) if(x>4.04) break; } fprintf(o,".03 W .5 0 0 RGB S\n"); M( 1,   M_E) L(0,    M_E) M(-1,-1./M_E) L(0,-1./M_E) M(  M_E,1)   L( M_E,0) M(-1./M_E,-1) L(-1./M_E,0) fprintf(o,"0 setlinecap .005 W 0 0 0 RGB S\n"); fprintf(o,"showpage\n%cTrailer",'%'); fclose(o); system("epstopdf LambertWplot.eps"); system(   "open LambertWplot.pdf"); //these 2 commands may be specific for macintosh getchar; system("killall Preview");// if run at another operational sysetm, may need to modify }

Generator of lables
% % Copyleft 2012 by Dmitrii Kouznetsov% \documentclass[12pt]{article} % \usepackage{geometry} % \usepackage{graphicx} % \usepackage{rotating} % \paperwidth 610pt % \paperheight 404pt % \topmargin -102pt % \oddsidemargin -92pt % \textwidth 1200pt % \textheight 600pt % \pagestyle {empty} % \newcommand \sx {\scalebox} % \newcommand \rot {\begin{rotate}} % \newcommand \ero {\end{rotate}} % \newcommand \ing {\includegraphics} % \begin{document} % { \begin{picture}(508,408) % %\put(1,9){\ing{arclambertw}} % \put(1,9){\ing{LambertWplot}} % \put(187,398){\sx{2.9}{$y$}} % \put(209,378){\sx{3.1}{$\mathrm e$}} % \put(186,304){\sx{2.8}{$2$}} % \put(186,204){\sx{2.8}{$1$}} % \put(184,103){\sx{2.8}{$0$}} % \put(209,70){\sx{2.6}{$-\!1/\mathrm e$}} % \put( 86, 90){\sx{2.5}{$-\!1$}} % \put(200,90){\sx{2.5}{$0$}} % \put(300,90){\sx{2.5}{$1$}} % \put(400,90){\sx{2.5}{$2$}} % \put(471,96){\sx{2.9}{$\mathrm e$}} % \put(500,90){\sx{2.5}{$3$}} % % \put(300,-9){\sx{2.5}{$0$}} % \put(590,90){\sx{2.6}{$x$}} % \put(282,270){\sx{3.4}{$y\!=\!x\, \mathrm e^{x}$}} % \put(312,190){\sx{3.4}{\rot{11}$y\!=\!\mathrm{LambertW}(x)$\ero}} % \end{picture} % } % \end{document}