LambertW
The Lambert function (Wolfram's ProductLog), the inverse of . compute-engine's native LambertW already covers the principal () and lower-real () branches numerically; extended here with exact values at algebraically nice points and every other integer branch.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wikipedia
Lambert W functionMathWorldLambertW-FunctionWikidataQ429331nLabLambert W-functionDLMF4.13.E1FungrimLambertW✓Fungrim entryWolfram LanguageProductLog✓LambertW(z)the principal branch — native, extended with exact values.SageMath
lambert_w(z)mpmathlambertw(z)LambertW(z, k)the -th branch , by Halley's iteration from the standard log-log seed (Corless et al. 1996). and stay on compute-engine's own native handler.SageMath
lambert_w(k, z)mpmathlambertw(z, k)Typed signatures
| Type | Package | Applies |
|---|---|---|
(z: complex | infinity, branch: integer?) -> number | analyticreplaces compute-engine | always |
(z: complex | infinity, branch: integer?) -> number | compute-engine | always |
Details
- Differs from Wolfram: the branch is the second argument, , in compute-engine's order. Wolfram's
ProductLog[k, z]and Sage'slambert_w(k, z)take ; mpmath'slambertw(z, k)takes , like ours. Keep this order in mind when pasting a call across systems: the same branch isLambertW(-0.2, -1)here,ProductLog[-1, -0.2]in Wolfram,lambert_w(-1, -0.2)in Sage andlambertw(-0.2, -1)in mpmath. Swapped,ProductLog[-0.2, -1]is an error in Wolfram (the branch must be an integer), andLambertW(-1, -0.2)declines here. The Wolfram transpiler reverses the arguments at the boundary. - Checked directly:
LambertW(-0.14, -1)is the branch. The Sage form is documented prior art, not run here. - Exact values are recognized structurally at , (giving ), (giving ), for small integer , and for small integer (giving , since ) — even under plain
evaluate(), not justN(). - Every other branch is solved by Halley's method in the complex plane; checked against
wolframscript'sN[ProductLog[k, z], 16]at several points (real and complex , several ) to full double precision.
Plot
Examples
4 more kept as data, checked against the oraclesScope #
A branch other than 0 or -1, checked against N[ProductLog[-3, -0.14], 16]
InOut
Known value · Wolfram 15.0.0 ProductLog
The real branch on , written as here; Wolfram's ProductLog[-1, -0.2] and mpmath's lambertw(-0.2, -1) give the same value
InOut
About
| Examples | 12 |
|---|---|
| Checked against | Wolfram Language 12 agreeSageMath 12 agreempmath 12 agree |
| Crosswalk | WikipediaMathWorldWikidatanLabDLMFFungrimFungrim entry ×20Wolfram LanguageSageMath ×2mpmath ×2 |
Implementation
primitive · kernela kernel — an algorithm over mutable state that would not be readable as a tree
nativeengine
typescriptpackages/symbols/analysis/analytic/src/lambert-w.tsHalley's iteration in the complex plane for k ∉ {0, -1}; structural pattern matching for the exact cases.
mapped
mpmathpackages/oracle/src/mappings.tsmapped
mpmathpackages/oracle/src/mappings.tsmpmath takes the branch second: lambertw(z, k).
mapped
sagepackages/oracle/src/mappings.tsmapped
sagepackages/oracle/src/mappings.ts