Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting rid of ProductLog

714 views
Skip to first unread message

Robert Hulme

unread,
Jul 8, 2004, 3:16:10 AM7/8/04
to
Hi,

Could someone please help me?

I'm not a mathematician, but rather a programmer - I'm trying to use
Mathematica to rearrange a formula for me.

I'm trying:

Solve[a^b - b == c, b]

Which gives me:

Out[3]//TextForm=
Log[a]
ProductLog[-(------)]
c
a
{{b -> -c - ---------------------}}
Log[a]

The problem with this is that I need the solution to use normal
'primitive' (if thats the right word) math functions as I need the
formula for a computer program.

With ProductLog being an internal Mathematica function I cant
therefore use this rearrangement.

What can I do so that there is no ProductLog in there? Please go easy
on me as I'm not a math major :0) or that au fait with Mathematica.

If it helps both a and b are always positive.

Many thanks
-Rob

Sseziwa Mukasa

unread,
Jul 9, 2004, 2:35:37 AM7/9/04
to

ProductLog is also known as the Lambert W function. You can find a
description of it here
http://mathworld.wolfram.com/LambertW-Function.html. There are a
couple of asymptotic series and an approximation of W(x) for x>=3
given. Knuth and Robert Corless published a few papers on the function
which a listed here
http://www.apmaths.uwo.ca/~rcorless/frames/PAPERS/LambertW/. Algorithm
443 of the Communications of the ACM is supposed to evaluate Lambert's
W for the principle branch and positive real arguments. For a > e
however your argument is going to be negative, apparently Algorithm 443
can be extended to account for this according to Corless. Note that
W(z) is complex valued for z<0.

Regards,

Ssezi

John Doty

unread,
Jul 9, 2004, 2:42:59 AM7/9/04
to
You might take a look at http://en.wikipedia.org/wiki/Lambert's_W_function

ProductLog, or W, *is* elementary, in the sense that it cannot be
expressed in terms of more common elementary functions.

If all you want is a numerical solution, it may be easier and faster to
apply a numerical root finding algorithm to your original equation
rather than attempt to numerically evaluate a symbolic solution.

Jens-Peer Kuska

unread,
Jul 9, 2004, 2:48:03 AM7/9/04
to
Hi,

if you are a programmer you may
a) implement a root search that solve the equation numerical
b) implement the ProductLog[] function

Regards
Jens

Alan

unread,
Jul 9, 2004, 2:53:06 AM7/9/04
to
> The problem with this is that I need the solution to use normal
> 'primitive' (if thats the right word) math functions as I need the
> formula for a computer program.
>
> With ProductLog being an internal Mathematica function I cant
> therefore use this rearrangement.


Mathematica didn't invent this function; it's just one that you didn't
personally recognize. It's often called the LambertW -- see
http://mathworld.wolfram.com/LambertW-Function.html

Here are some of your alternatives:
(1) A Newton's method iteration will work just about anywhere.
(2) Perhaps your target system does have the LambertW function.
(3) You could code the LambertW on the target system,
although it would probably amount again to just coding Newton's
method if the target system is a (non-symbolic) system like
C/C++/Fortan/Basic etc.

regards,
alan


Bill Rowe

unread,
Jul 9, 2004, 2:58:09 AM7/9/04
to
On 7/8/04 at 2:51 AM, robert...@gmail.com (Robert Hulme) wrote:

>Solve[a^b - b == c, b]

>Which gives me:

>Out[3]//TextForm=
> Log[a]
> ProductLog[-(------)]
> c
> a
>{{b -> -c - ---------------------}}
> Log[a]

>The problem with this is that I need the solution to use normal


>'primitive' (if thats the right word) math functions as I need the
>formula for a computer program.

>With ProductLog being an internal Mathematica function I cant
>therefore use this rearrangement.

>What can I do so that there is no ProductLog in there?

You can't. There is no closed form solution without the ProductLog function or the equivalent with a different name. If you are trying to write program that doesn't depend on Mathematica at runtime and need the solution to a^b - b == c, you will have to either write your own numeric solver or a routine to implement the ProductLog function.
--
To reply via email subtract one hundred and four

Dana

unread,
Jul 11, 2004, 2:19:24 AM7/11/04
to
Here is my attempt using Excel vba. You need to supply a good initial
guess. Here, you enter a=3,c=4, and a guess of -1, I get...

Debug.Print MyFunction(3, 4, -1)
-3.98748338411597

and in Mathematica, I get the same answer:

{-c - ProductLog[(-a^(-c))*Log[a]]/Log[a]} /. {a -> 3, c -> 4.}
-3.9874833841159707


Function MyFunction(a, c, guess)
Dim b As Double
Dim LastGuess As Double
Dim Counter As Long

b = guess
LastGuess = b + 1 ' Just make it different

Do While LastGuess <> b And Counter <= 10
LastGuess = b
b = (c + a ^ b * (-1 + b * Log(a))) / (-1 + a ^ b * Log(a))
Counter = Counter + 1
Loop
MyFunction = b
End Function


Some functions will return an answer that alternates in the last digit.
Therefore, in some problems, the last guess will never equal the new
guess.(they will be different in the last digit). Therefore, you need to
account for this. I just limited the loops to 10. Adjust to your own
situation.

HTH
Dana DeLouis


"Robert Hulme" <robert...@gmail.com> wrote in message
news:ccisbq$4de$1...@smc.vnet.net...

David W. Cantrell

unread,
Jul 12, 2004, 2:19:24 AM7/12/04
to
"Dana" <del...@bellsouth.net> wrote:
> Here is my attempt using Excel vba. You need to supply a good initial
> guess. Here, you enter a=3,c=4, and a guess of -1, I get...
>
> Debug.Print MyFunction(3, 4, -1)
> -3.98748338411597
>
> and in Mathematica, I get the same answer:
>
> {-c - ProductLog[(-a^(-c))*Log[a]]/Log[a]} /. {a -> 3, c -> 4.}
> -3.9874833841159707

But note that there is also a positive solution for b, given by using the
other real branch (i.e., the -1 branch) of ProductLog:

In[1]:= -c - ProductLog[-1,(-a^(-c))*Log[a]]/Log[a] /. {a -> 3, c -> 4.}

Out[1]= 1.56192

I would guess it's at least as likely that that would be the desired
solution in the application at hand.

In any event, to get rid of ProductLog, one can of course approximate it
using a truncated version of an appropriate series expansion. For example,
rather than doing what you've shown below to approximate the negative root
in your sample case, we can approximate ProductLog (a.k.a. Lambert W) using
z - z^2 + 3/2 z^3 +-... Using just the three terms shown, we get

In[2]:= ApproxW[z_]:= z - z^2 + 3/2 z^3

In[3]:= -c - ApproxW[-Log[a]/a^c]/Log[a] /. {a -> 3, c -> 4.}

Out[3]= -3.98748

See the Lambert W entry at MathWorld or the ProductLog entry at the Wolfram
Functions site for more information on appropriate series.

David

0 new messages