Matlab: Solving a logarithmic equation
Another option is based on the simpler Wright ω function:
a = b - x.*wrightOmega(log(-(c-d)./x) - (c-d)./x);
provided that d ~= c + x.*wrightOmega(log(-(c-d)./x) - (c-d)./x)
(i.e., d ~= c+b-a
, x
is 0/0
in this case). This is equivalent to the principal branch of the Lambert W function, W0, which I think is the solution branch you want.
Just as with lambertW
, there's a wrightOmega
function in the Symbolic Math toolbox. Unfortunately, this will probably also be slow for a large number of inputs. However, you can use my wrightOmegaq
on GitHub for complex-valued floating-point (double- or single-precison) inputs. The function is more accurate, fully-vectorized, and can be three to four orders of magnitude faster than using the built-in wrightOmega
for floating-point inputs.
For those interested, wrightOmegaq
is based on this excellent paper:
Piers W. Lawrence, Robert M. Corless, and David J. Jeffrey, "Algorithm 917: Complex Double-Precision Evaluation of the Wright omega Function," ACM Transactions on Mathematical Software, Vol. 38, No. 3, Article 20, pp. 1-17, Apr. 2012.
This algorithm goes beyond the cubic convergence of the Halley's method used in Cleve Moler's Lambert_W
and uses a root-finding method with fourth-order convergence (Fritsch, Shafer, & Crowley, 1973) to converge in no more than two iterations.
Also, to further speed up Moler's Lambert_W
using series expansions, see my answer at Math.StackExchange.