Lambert W Function Calculator

Both real branches, residuals and worked uses.

  • Both real branches
  • Residual shown
  • Iterated powers
A small rounded clay table with a soft clay curve shaped like a leaning hook, two clay beads resting on it at the same height, and a few loose beads.

The guide

A hook with two arms: why w e^w = x has two real answers, and why the turn needs care

Where the two real branches of the Lambert W function meet, why an iteration struggles at the join, and how x^x = c and an infinite tower of powers reduce to W.

  • -1/e lowest x with a real W; the two branches meet there at w = -1
  • 0.567143 omega constant, W0(1), the solution of w e^w = 1
  • -2.54264 second real root of w e^w = -0.2, on the lower branch
  • 3.597285 the one real solution of x^x = 100
  • 1.4447 top of the range where z^z^z... settles
Read the full guide Fold the guide 8 min · 12 sources

Ask for the number w that makes w times e to the power w equal to minus 0.2, and the usual answer is minus 0.2592. It is correct. It is also half the story, because the same equation has a second real solution, minus 2.5426, and a program that returns only the first has quietly dropped an answer. The function behind both numbers is the Lambert W function, the inverse of w e^w. It has no closed form in elementary functions, so every value comes from an iteration. This page returns both real roots, puts each back into the equation, and says plainly when there is no real solution at all.

Two answers where one is expected

Plot w e^w and the reason is visible. For w above 0 the product climbs without limit. For w below 0 it is negative: it falls from 0 to a lowest point and then creeps back toward 0 from below as w runs off to minus infinity. The lowest point is at w = -1, where the product is -1/e, about -0.3679. Any value the curve reaches below zero, it reaches twice, once on each side of that dip. So the inverse is not a single curve but a hook, and the hook has an upper arm and a lower arm.

Wikipedia calls W a multivalued function, the branches of the converse relation of f(w) = w e^w. For real numbers the equation y e^y = x can be solved only if x is at least -1/e. It gives y = W0(x) when x is 0 or more, and two values, W0(x) and W-1(x), when x runs from -1/e up to but not including 0. W0 is the principal branch, with values at least -1. W-1 holds the values at most -1. The NIST Digital Library of Mathematical Functions counts the same way: one real solution on the interval from 0 upward, and two on the open interval between -1/e and 0, one increasing and the other decreasing.

Take x = -0.2. The principal branch gives w = -0.2591711018 and the lower branch gives w = -2.5426413578. Substitute either one into w e^w and you get -0.2 to the last digit a double can hold. A chatbot that shows only the first number has answered a different question.

Where the arms meet

The two branches join at x = -1/e, and both give w = -1 there. In complex analysis this is a branch point. The DLMF states that W0 has a square root branch point at that value, and the Wikipedia article on branch points explains the pattern with the simplest case, solving w squared equal to z for w: two values that merge where z reaches 0.

Near the join the hook looks like a parabola lying on its side. With p equal to the square root of 2(e x + 1), the branches are w = -1 + p - p^2/3 + 11 p^3/72 and the same with p replaced by -p, and more terms follow. At x = -0.36787944117 the value of p is about 0.0000028, and the two roots are -0.9999972 and -1.0000028, mirror images across -1 to a first approximation.

That square root has a price. Near x = -0.36787944117 a step of 1e-10 in x changes w by about 1e-4. A double stores x with a relative rounding error of about 1.1e-16, which Wikipedia lists as 2^-53 for double precision, with the gap above 1 being twice that, 2^-52 or about 2.22e-16. So even a perfect program cannot know w better than about 1.1e-16 divided by |1 + w|. At w = -0.9999972 that is roughly 4e-11.

The most famous single value sits on the principal branch: W0(1) = 0.5671432904, the omega constant, the real solution of w e^w = 1, which also satisfies w = e^-w. The OEIS lists its decimal expansion. Iterating w to e^-w from any start reaches it, Wikipedia notes, but slowly; the iteration (1 + w) / (1 + e^w) has a vanishing slope at the answer and is much faster.

Why the iteration needs care at the turn

The usual way to compute W treats f(w) = w e^w - x as a function of w and looks for its zero. Newton’s method uses the slope. Halley’s method adds the curvature and converges cubically, which means the number of correct digits roughly triples at each step. Wikipedia gives the step as x minus f f’ divided by the quantity f’ squared minus half of f f”.

For this f the slope is e^w (w + 1) and the curvature is e^w (w + 2), so the step becomes w minus f, divided by e^w (w + 1) minus (w + 2) f / (2w + 2). From a sensible start, three or four steps reach the last digit. The page picks the start by region: a rational guess for moderate x, the first terms ln x - ln ln x + ln ln x / ln x of the large-x expansion for big x, and a few terms of the branch-point series just above -1/e.

A sweep of 119,880 points between 1e-300 and 1e300, plus the stretch before -1/e, needed at most 4 steps and every point converged. At 45 fixed points on both branches, the largest relative error against 50-digit values was 3.3e-16. The trouble is the denominator. The slope e^w (w + 1) vanishes at w = -1, so near the branch point each step is a small number divided by a small number. The residual f is the difference of two nearly equal values, each carrying a rounding error near 4e-17, so the computed step is noise of about 1e-16 divided by |1 + w|. Once that noise exceeds the stopping tolerance, the rule can never be met.

In a trial made for this page, a plain Halley loop at x = -0.36787944117 finished about 3e-11 from the 50-digit value on both branches, and on the principal branch it used all 60 allowed steps without meeting its own stopping rule. That agrees with the 4e-11 predicted above.

The cure on this page is not a better loop. When p is at most 0.25, which means x within about 0.011 of -1/e, it sums the branch-point series to 22 terms, with e x + 1 computed with a correction for the rounding of e and of the product. The coefficients 1, -1/3, 11/72, -43/540 and so on come from reversing (1 - u) e^u = 1 - p^2/2 with u = w + 1, in exact fractions. The page marks that path as needing no Halley steps, so you can see which method answered.

Two equations and a tower that hide a W

Some equations that do not look like w e^w = x are exactly that in disguise. The equation x e^x = y has the answer x = W(y), branch and all, so for y between -1/e and 0 it has two real solutions and for y of 0 or more it has one.

The equation x^x = c needs one step more. Take logarithms: x ln x = ln c. Put x = e^u, so that u e^u = ln c, and then u = W(ln c) and x = exp(W(ln c)), on each real branch. Wikipedia works x^x = 2 with the formula x = ln(y) / W0(ln y), which is the same number, since w e^w = ln c means e^w = ln c / w. That form explains a common slip. Putting c into W where ln c belongs gives the wrong answer. For c = 100 the right solution is x = 3.5972850235, and the shortcut ln c / W(c) gives 1.3602, whose own x^x is only 1.520.

The number of real solutions follows from the argument ln c, which must be at least -1/e. That means c must be at least exp(-1/e), about 0.6922, the minimum of x^x, reached at x = 1/e. Between 0.6922 and 1 the argument is negative and there are two solutions: for c = 0.7 they are 0.4623375275 and 0.2809012251, one on each side of 1/e. From c = 1 upward there is one. Below 0.6922, for example c = 0.5, there is none.

The infinite tower z^z^z^… is the limit of the iteration t becomes z^t, starting from z. Wikipedia’s page on tetration credits Euler with the result that it converges for z from exp(-e) to exp(1/e), roughly 0.066 to 1.44. If a limit y exists then y = z^y. Write y = e^s and this is s e^s = -ln z, so the limit is W0(-ln z) / (-ln z), the form given on the Lambert W page. For z = sqrt 2 the limit is 2, and the page shows the iterates within 1e-9 of it after 56 steps. The top of the range, exp(1/e), is about 1.4447.

Why those two ends? A fixed-point iteration settles on a fixed point only when the slope of the map there has absolute value below 1; Wikipedia calls such a point attracting. For t becomes z^t the slope at the limit works out to minus W0(-ln z). The absolute value of W0 is below 1 exactly when -ln z lies between -1/e and e, which is the range above. At either end the slope is 1 in size and convergence becomes extremely slow.

Outside the range the picture changes. For z = 1.5 the iterates grow without bound and overflow a double within twenty steps, and t = z^t has no real solution. For z = 0.05 the iterates stop settling and bounce between two values near 0.6627 and 0.1374, although t = 0.3502 still satisfies t = z^t: it is a solution that repels the iteration rather than attracting it.

What the residual can and cannot say

The residual is w e^w - x for the w that came back. It is the quickest honest check and the page shows it for every root. A residual near 1e-16 times the size of x says that w solves the equation for the typed x to within the rounding of a double.

It does not say how close w is to the true root. Near the branch point a tiny residual can go with an error in w that is large by the factor 1 / |1 + w|, as computed above. Far out the opposite happens: e^w carries about |w| rounding errors, so at x = 9.2e248 the sweep measured a relative residual of 5.7e-14 even though w itself was correct to about 1e-16.

So the page also compares itself with 50-digit values computed outside it, with a multiprecision library and a separate solver written with exact decimal arithmetic, in which decimal numbers are represented exactly, as the Python documentation describes. The worst relative error it measured on this run was 3.3e-16, at x = -0.35 on the lower branch where 1 / |1 + w| is 2.9. Measured is not guaranteed: the figures hold for those points on that run.

The page cannot do some things. It handles real numbers only, not complex arguments or the branches W1, W2 and beyond. It stops at 20 characters per number and at sizes between 1e-300 and 1e300, so a pasted wall of digits cannot stall it. The longer measurements run in a web worker, which MDN describes as a script run in a background thread apart from the main one, and the digits shown are formatted by the browser’s number formatter, Intl.NumberFormat.

Sources

Every source consulted for this guide. Links checked November 11, 2026.

  1. Lambert W function Wikipedia (CC BY-SA)
  2. Tetration Wikipedia (CC BY-SA)
  3. Halley's method Wikipedia (CC BY-SA)
  4. Omega constant Wikipedia (CC BY-SA)
  5. Branch point Wikipedia (CC BY-SA)
  6. Fixed-point iteration Wikipedia (CC BY-SA)
  7. Machine epsilon Wikipedia (CC BY-SA)
  8. DLMF: 4.13 Lambert W-Function National Institute of Standards and Technology
  9. A030178 Decimal expansion of LambertW(1) OEIS Foundation (CC BY-SA)
  10. decimal - Decimal fixed-point and floating-point arithmetic Python Software Foundation
  11. Web Workers API MDN Web Docs (CC BY-SA)
  12. Intl.NumberFormat - JavaScript MDN Web Docs (CC BY-SA)