From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solving an equation with no close analytical solution
Date: Sun, 21 Dec 2008 05:09:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 19
Message-ID: <gikj1e$4cv$>
References: <gifvtb$6tp$> <gihaei$pim$> <giihj1$ije$> <gikasr$a4q$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1229836142 4511 (21 Dec 2008 05:09:02 GMT)
NNTP-Posting-Date: Sun, 21 Dec 2008 05:09:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:508169

"Roger Stafford" <> wrote in message <gikasr$a4q$>...
> ........
>  As I mentioned earlier, to get around this you will have to use Pascal Getreuer's second input argument which is called 'b' to force 'lambertw' onto another branch.  I do not know what value of 'b' this will require, but I suspect it is b = 1 and if not that then b = -1.
> ........

  I just tried out 'lambertw'.  For your stuff you need to set the "branch" input equal to -1 in order to stay off the principal branch.

  Its output may have a very tiny imaginary part due to round off error and you can take its real part to get rid of that:

  w = real(lambertw(-1,z));

where z is all the stuff that should go inside the Lambert W function.

  However, you should always check that your results satisfy the original equation.  It is possible to have 'a' set so large that for the given 'b' and 'c' values there are no real-valued solutions except the one at x = b.

  As I mentioned earlier, you can use a vector form of z for your 5000 points and avoid for-loops altogether.

Roger Stafford