lambertw
Lambert W function, the inverse of w*exp(w).
Category: Mathematics > Mathematical Functions
Syntax
W = lambertw(x)
Principal branch W0(x).
W = lambertw(k, x)
Branch number k (an integer).
Description
The equation w*exp(w) = x has infinitely many complex solutions. lambertw picks one per branch. For real x >= -1/e the principal branch is real, and for -1/e <= x < 0 the branch k = -1 gives a second real solution that is <= -1.
At the branch point x = -1/e both real branches meet at w = -1. The function solves equations where an unknown appears both as a factor and inside an exponential.
Input arguments
k- Branch index, an integer.
0is the principal branch;-1is the other real branch. x- Argument, real or complex, scalar or array.
Output arguments
W- Solution
wofw*exp(w) = xon the chosen branch.
Example
Both real branches
lambertw(1)
lambertw(0, -0.2)
lambertw(-1, -0.2)
w = lambertw(1);
w*exp(w)
Output
ans = 0.5671
ans = -0.2592
ans = -0.2592
ans = 1