Finding values of Lambert's W function for x>0

I have been struggling with this question and I think I have found an answer but I am not %100 sure. Can you check it please? First, I tried to define a Lambert function
function W = myLambert(a)
syms x;
f (x) = x*exp(x);
g = finverse(f);
double(g(a))
end
In the second part, it gives output for values greater than 0
clc;
clear all;
prompt = 'Enter the x value that is greater than 0 ';
q=input(prompt);
myLambert(q)

1 Comment

finverse(f) will be MATLAB'S Lambert's W function, not yours ...

Sign in to comment.

Answers (1)

Solve this the same way you solved the Bessel function, this time without the loop.
Think of it this way: You want to find:
x = y.*exp(y)
for any ‘x’. Define ‘x’ and solve for ‘y’, using fzero.

4 Comments

I think I did it this time :)
function W = lambert(x)
f=@(y)y.*exp(y)-x % the root of this function at x is value of
% the inverse of x*exp(x)
W=fzero(f,1e-6);
end
>> lambert(12)
f =
function_handle with value:
@(y)y.*exp(y)-x
ans =
1.8628
You did.
That was the same result I got with this:
x = 12;
LW = lambertw(x);
f = @(y) y.*exp(y) - x;
y = fzero(f, 10);
for both ‘LW’ and ‘y’.

Sign in to comment.

Categories

Find more on Mathematics in Help Center and File Exchange

Asked:

on 12 Jun 2018

Commented:

on 12 Jun 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!