Solving 'a = b ln [ max (11, b) ]' for b

70 Views Asked by At

Given:

a = b ln [ max (11, b) ]

If a is known, how can one compute b? (Do I need to use an iterative approximation method?)

2

There are 2 best solutions below

0
On

Here is a graph of your function, where we have x and y rather than b and a.

enter image description here

Note that there is a "corner" at the point (11, 11 ln(11)). This is because your function can be re-written as:

a = b ln 11 if b <= 11
    b ln b  if b > 11

(I wish I could MathJax here as in some other StackExchange sites!)

Note that the solution to the second version is b = exp(W(a)) where W() is the Lambert W function. Many programming languages have packages that implement the Lambert W function. In Python, for example, the common scipy package calls it lambertw().

So a full solution in Python, after importing the lambertw function from the scipy module and exp and log (equivalent to ln) from the math module, is

b = (a / log(11) if a <= 11 * log(11)
        else exp(lambertw(a)))

This is easier than reinventing the wheel. Note that scipy's lambertw function uses continued fractions to get an approximate value then uses one or two rounds of the Newton-Raphson method to get a final result. This is faster than using only Newton-Raphson.

1
On

If a / ln(11) <= 11, then this is your solution and you don't need any iteration. Otherwise solve b * ln(b) - a = 0 e.g. with Newton-Raphson.