Urban Maths: How to W!

Urban Maths: How to W!


urban mathsRain, storms, floods, overflowing drains; we cannot get away from them be it summer or winter. Trying, unsuccessfully, to avoid an overflowing drain recently, I started to wonder what sort of calculations, if any, are done to determine the pressure drops and flow rates through the network of drainage pipes.

Commonly, for steady internal flows through a rough pipe, the frictional pressure drop, \Delta p, along a section of length, L, is obtained from

    \[ \Delta p = f\frac{L}{D}\frac{1}{2}\rho v^2, \]

where D is diameter, \rho is fluid density, and v is fluid velocity. The dimensionless constant of proportionality, f, is known as the friction factor. For laminar flow the friction factor is inversely proportional to Reynolds number, Re, a measure of the relative importance of inertial forces to viscous forces (given by \text{Re} = {\rho v D}/{\mu}, where \mu is the fluid dynamic viscosity). The constant of proportionality simply depends on the cross-sectional shape of the pipe. For turbulent flow, on the other hand, the friction factor is more complicated, being a function of not only the Reynolds number, but also the relative roughness, rr, of the pipe, and is generally calculated from an empirically derived correlation. A commonly used such correlation is the Colebrook–White equation (see [1] for example):

(1)   \begin{equation*} \frac{1}{\sqrt{f}} = -2 \log_{10} \left( \frac{2.51}{\text{Re} \times \sqrt{f}} + \frac{rr}{3.71} \right). \end{equation*}

You will notice that this is an implicit equation for f, which occurs on both the left- and right-hand sides. To find f we therefore need to use an iterative method, or obtain an approximate explicit representation (of which there are several) as there is no way of rearranging equation (1) to get an exact explicit formulation for f in terms of elementary functions \dots or is there?

It turns out that by making use of a not so well-known function, called the LambertW function (see [2], for example), we can, in fact, do just that, as I will demonstrate below. First though, let’s have a look at the LambertW function itself.

The LambertW function is defined via the following equation:

(2a)   \begin{align*} w {\rm e}^w = x. \end{align*}

It is the value of w that satisfies equation (2a) for a given value of x; i.e.\ x is the input and w is the output: w = \operatorname{LambertW}(x). By taking logs of both sides we can also express the equation as:

(2b)   \begin{align*} \ln w + w = \ln x. \end{align*}

The function is defined for complex numbers, but we will only consider real numbers here. For real numbers the function is defined for values of x from -{\rm e}^{-1} to \infty. For x > 0 there is a unique value of w for each x. However, between -{\rm e}^{-1} and 0 there are two real values of w for each x. We therefore consider the function to have two real branches, conventionally labelled w_0 (the higher branch) and w_{-1}. These are plotted in Figure 1.

We will only deal with the upper branch here.

The function was first considered by Euler (who else!) when studying an equation developed by J.H. Lambert (1728–1777); though it was not named until the 1990s, and Lambert himself knew nothing of it! There is a great introduction to the function written at an elementary level by Brian Hayes [3].

So how do we use it to rewrite the Colebrook–White correlation exactly in explicit form? It is not immediately obvious, as equation (1) looks nothing like equation (2a), and not too much like equation (2b). We need to do some manipulation.

Figure 1: Real number branches of the LambertW function

Let’s start by defining:

(3a)   \begin{align*} u = \frac{2.51}{\text{Re} \times \sqrt{f}} + \frac{rr}{3.71} \end{align*}

so that:

(3b)   \begin{align*} \frac{1}{\sqrt{f}} = \left( u - \frac{rr}{3.71} \right) \frac{\text{Re}}{2.51}. \end{align*}

We now rewrite equation (1) in terms of log to the base \rm e, rather than log to the base 10; replace the left-hand side by equation (3b); use equation (3a) on the right-hand side, and do a little rearranging to get:

    \begin{equation*} \frac{\text{Re} \times \ln 10}{5.02}u + \ln u = \frac{rr}{3.71} \frac{\text{Re} \times \ln 10}{5.02}. \end{equation*}

This is beginning to look a little like equation (2b), but is not quite there yet, so let’s add \ln(\text{Re} \times \ln 10 / 5.02) to both sides of this equation and make use of the addition property of logarithms to get:

(4)   \begin{multline*} \frac{\text{Re} \times \ln 10}{5.02}u + \ln \left( \frac{\text{Re} \times \ln 10}{5.02}u \right) = \frac{rr}{3.71}\frac{\text{Re} \times \ln 10}{5.02} + \ln \left( \frac{\text{Re} \times \ln 10}{5.02} \right). \end{multline*}

We now define

(5)   \begin{equation*} w = \frac{\text{Re} \times \ln 10}{5.02}u \end{equation*}


(6a)   \begin{align*} \ln x = \frac{rr}{3.71}\frac{\text{Re} \times \ln 10}{5.02} + \ln \left( \frac{\text{Re} \times \ln 10}{5.02} \right), \end{align*}

so that:

(6b)   \begin{align*} x = \frac{\text{Re} \times \ln 10}{5.02} \exp \left( {\frac{rr}{3.71}\frac{\text{Re} \times \ln 10}{5.02}} \right), \end{align*}

which enables us to write equation (4) as: w + \ln w = \ln x; namely, the same as equation (2b).

Making use of equation (5) in equation (3b) and doing a little manipulation we can now write an exact explicit form of the Colebrook–White equation as:

(7)   \begin{equation*} \frac{1}{\sqrt{f}} = \frac{2}{\ln 10}w(x) - \frac{rr}{3.71} \times \frac{\text{Re}}{2.51}, \end{equation*}

where I have explicitly recognised that w is a function (the LambertW function) of x, and x (a function of Reynolds number and relative roughness) is as defined in equation (6b).

Now there has been a lot of manipulation to get from equation (1) to equation (7). Do the two equations really produce the same value friction factors for given values of Reynolds number and relative roughness? I’m never happy until I have done some numerical comparisons to check, so Figure 2 shows a graph of friction factor against a range of turbulent Reynolds numbers for three different relative roughnesses, calculated from an iterative technique for equation (1) and using the LambertW function for equation (7). The figure speaks for itself!

Figure 2: Friction factor comparisons

‘Hold your horses,’ I hear you cry, ‘you’ve just pulled off a sleight of hand – you still have to calculate the value of w(x), possibly using an iterative method, so you have not really gained anything over the original implicit equation!’ Oh really? I did not hear you complain when I used the logarithmic function earlier; nor would you have complained at the use of other elementary functions, such as trigonometric or hyperbolic ones, nor indeed at such simple expressions as \sqrt{2}! These also have to be calculated one way or another when we want numerical results. It does not devalue their use as symbolic placeholders (and, anyway, numerical analysts are always looking for ways to make numerical evaluation of important functions speedier and more efficient).

The reality is that we tend to feel slightly uncomfortable with the above simply because we are not so familiar with the LambertW function. I have no doubt many people are uncomfortable with the logarithmic function when they first meet it. The more we use something the happier we are with it, so I think we should be looking to make much greater use of the LambertW function until it becomes commonplace and we all treat it like an old friend!

That said, I very much doubt it will do much to improve the situation with regard to overflowing drains!

Alan Stevens CMath FIMA


‘Urban Maths’ cartoonist: Adrian Metcalfe –  www.thisisfruittree.com


  1. en.wikipedia.org/wiki/Darcy_friction_factor_formulae
  2. Weisstein, E.W. Lambert W-Function from MathWorld; mathworld.wolfram.com/LambertW-Function.html
  3. Hayes, B. (2005) Why W?, American Scientist, vol. 93, no. 2, p. 104, DOI:  10.1511/2005.2.104.

Reproduced from Mathematics Today, February 2017

Download the article, Urban Maths:  How to W! (pdf)

Image credit: Close Up of legs with boots due to the high water in Venice. by © Antonio Gravante / Dreamstime.com

Leave a Reply

Your email address will not be published. Required fields are marked *