Rational Approximation for Solving an Implicitly Given Colebrook Flow Friction Equation

The empirical logarithmic Colebrook equation for hydraulic resistance in pipes implicitly considers the unknown flow friction factor. Its explicit approximations, used to avoid iterative computations, should be accurate but also computationally efficient. We present a rational approximate procedure that completely avoids the use of transcendental functions, such as logarithm or non-integer power, which require execution of the additional number of floating-point operations in computer processor units. Instead of these, we use only rational expressions that are executed directly in the processor unit. The rational approximation was found using a combination of a Padé approximant and artificial intelligence (symbolic regression). Numerical experiments in Matlab using 2 million quasi-Monte Carlo samples indicate that the relative error of this new rational approximation does not exceed 0.866%. Moreover, these numerical experiments show that the novel rational approximation is approximately two times faster than the exact solution given by the Wright omega function.


Introduction
The Colebrook equation [1] for turbulent flow friction is implicitly given with respect to the unknown Darcy flow friction λ, as shown in Equation (1): where: -Darcy flow friction factor (dimensionless) -Reynolds number, 4000 < Re < 10 8 (dimensionless) -relative roughness of inner pipe surface, 0 < ε < 0.05 (dimensionless) As a PhD student at the Imperial College in London, Colebrook developed his empirical equation based on the data from his joint experiment with his supervisor, Prof. White [2]. They experimented with flow of air through pipes with different roughness of the inner pipe surface. The experiment by Colebrook and White was described in a scientific journal and published in 1937 [2], while the related empirical equation by Colebrook was published in 1939 [1].
Compared with some other experimental findings [3], the Colebrook equation fits the friction factor within a few dozen percent of error [4]. The Colebrook equation over the last 80 years has been seen by the industry as an informal standard for flow friction calculation and has been very well accepted in everyday engineering practice. Based on the Colebrook equation, Moody developed a diagram that was used before the era of computers for graphical determination of turbulent flow friction [5]. Today, such nomograms have been replaced by explicit approximations, which introduce some value of error [6,7], or by iterative methods [8][9][10].
In a central computer processor (CPU), transcendental functions such as logarithmic, exponential, or functions with non-integer terms require execution of numerous floating-point operations, and therefore they should be avoided whenever possible [11][12][13][14][15][16][17][18]. Praks and Brkić [19] recently developed a one-log call iterative method, which uses only one computationally demanding function, and even then only in the first iteration (for all succeeding iterations, cheap Padé approximants are used [20,21]). Based on that approach, few very accurate and efficient explicit approximations suitable for coding and for engineering practice have been constructed [22]. In addition, the same authors developed few approximations of the Colebrook equation based on the Wright ω-function, which are among the most accurate to date [23][24][25]. On the other hand, they contain one or two logarithmic functions, depending on the chosen version [23,24] (these procedures are based on the previous efforts by Praks and Brkić for symbolic regression [26] and by Brkić with Lambert W-function [27][28][29]).
In this communication, we make a step forward and we offer for the first time a procedure for the approximate solution of the Colebrook equation based only on rational functions. The presented novel rational approximation procedure introduces a relative error of no more than 0.866% for 0 < ε < 0.05 and 4000 < Re < 10 8 (as used in engineering practice). The rational approximation procedure is suitable for computer codes (open-source code in commercial Matlab 2019a is given in this communication, and in addition, it is compatible with freeware GNU Octave, version 5.1.0).
After introductory Section 1, Section 2 of this communication gives a short overview of mathematical methods used for the proposed rational approximation procedure. Section 3 describes the rational approximation procedure in detail (including error analysis), Section 4 provides software code along with the algorithm to be followed for the rational approximation approach, while Section 5 contains concluding remarks.

Mathematics Behind the Proposed Approximation
Our rational approximation approach is based on Padé approximants [20,21], symbolic regression [30,31] and although not used directly, it is inspired by the Wright ω-function, a cognate of the Lambert W-function [32]. To avoid detailed explanations about the Lambert W-function [33], here it should be noted that in this context it is used to transform the Colebrook equation from the shape implicitly given in respect to the unknown flow friction factor to the explicit form [23,24,[27][28][29]34,35].

Padé Approximants
The ratio of two power series with properly chosen coefficients of the numerator and denominator can approximate very accurately various functions in a narrow zone around the chosen expanding point. For the expressions in the numerator and denominator, Padé approximants [20,21] use rational functions of given order instead of serial expansions. So, in other words, the Padé approximants can estimate functions usually in a narrow zone as the quotient of two polynomials, often has better approximation properties compared with its truncated Taylor series. Being a quotient, the Padé approximants are composed of lower-degree polynomials, where the degree of polynomials can be chosen according to needs. We use Matlab 2019a in order to generate the needed Padé approximants as replacements of the logarithmic function in our rational approximation approach. We do not use expressions with non-integer exponents, because according to Clamond [10], in the software interpretation it is evaluated through one exponential and one logarithmic function (for example = · ( ) , where is in most cases a non-integer). The computational complexity of an algorithm describes the amount of resources required to run it, for example the execution time. Winning and Coole [13] performed 100 million calculations for each mathematical operation using random inputs, with each repeated five times, and found that the most efficient operation for addition requires 23.4 s. According to them, relative effort for computation referred to addition-1 as a reference for the following values: logarithm to base, 10-3.37; fractional exponential, 3

Symbolic Regression
Symbolic regression is a machine learning approach for finding approximate functions based on evolutionary or genetic algorithms [36]. To avoid imposing prior assumptions on the model, symbolic regression has the ability to search through the space of mathematical expressions to look for an approximate function that best fits a given dataset [31].
We used Eureqa [30], a symbolic regression engine, to obtain our final model. HeuristicLab [37], a software environment for heuristic and evolutionary algorithms, including symbolic regression, can be used instead.

Replacement of Logarithmic Function
The Colebrook equation can be accurately approximated using a rational approximation procedure, as shown in Equation (2): where: . Variable precision arithmetic (VPA) at 4 decimal digit accuracy is assumed for 1 and for 0 . The Padé approximant ( ) is given in Horner nested polynomial form generated in Matlab 2019a. It is of order /2,3/, which means that the polynomial in numerator contains a monomial of highest degree 2, while the denominator of degree 3. Any other suitable Padé polynomial of any other degree in any other form that can substitute the natural logarithm around the needed expansion point can be used, but in such cases, the rational approximation procedure should be tested again, because these changes can affect the value of the final relative error and its distribution.

Error Analysis
Distribution of the relative error for the proposed rational approximation procedure, Equation (2), is given in Figure 1. The maximal relative error goes up to 0.866% for 0 < ε < 0.05 and 4000 < Re < 10 8 (as used in engineering practice). The highest error using 2 million input pairs found by the Sobol quasi-Monte Carlo method is for Re = 71987 and ε = 3.1711·10 −7 [38]. The Colebrook equation is empirical and it follows logarithmic law, so for the procedure with only rational functions, this level of error is acceptable [39]. For example, Pimenta et al. [7] classify the approximation of Sonnad and Goudar [40] with relative error of up to 3.17%. With two logarithms and one non-integer power, this method [40] belongs to the group of approximations with higher performance indexes and precision. Brkić [6] estimates the relative error of Sonnad and Goudar [40] to be up to 0.8%, which is similar error compared with the rational approximation approach presented here; the same methodology as in Brkić [6] is used for Figure 1. The error in the proposed rational approximation can be possibly reduced by optimizing numerical values of parameters using a genetic algorithms [41] approach with the methodology described by Brkić and Ćojbašić [42]. However, the presented rational approximation approach has too many numerical parameters, meaning such an optimization would be very complex. Further simplifications rather should go in the direction of simplification of 0 , 1 and 2 , but keeping the same or increasing accuracy.

Computational Costs
The efficiency of the proposed procedure is tested using 2 million input pairs found by the Sobol quasi-Monte Carlo method [38]. The tests were performed using Matlab R2019a. The tests revealed that Equation (2) needs 0.56 s to calculate the friction factor λ for 2 million input pairs, or for the Reynolds number Re and the roughness of the inner pipe surface ε. On the other hand, the exact solution given by the Wright ω-function [23] implemented by the Matlab library "wrightOmegaq" [43] took 1.1 s for the same 2 million the tested pairs.
Our novel rational approximation of the Colebrook equation given with Equation (2) is approximately two times faster than the exact approach using the Wright ω-function [23], as the speed ratio is 1.1/0.56-1.96. On the other hand, the approach with the Wright ω-function [23] gives the exact solution, which requires two logarithms and one Wright ω-function, while this communication presents a rational approximation.

Software Description
The presented rational approximation approach for solving Colebrook's equation for flow friction was thoroughly tested at IT4Innovations, National Supercomputing Center, VŠB-Technical University of Ostrava, Czech Republic.

Algorithm
The simple algorithm of the rational approximation of the Colebrook equation is presented in Figure 2. The algorithm contains only one branch and is without loops.

Open-Source Software Code
The code is given in Matlab format, which is compatible with the freeware GNU Octave, but it can be easily transposed in any programming language (input parameters: R is the Reynolds number Re, K is the relative roughness of inner pipe surface ε; output parameter; L is the Darcy flow friction factor λ):

Conclusions
We provide a novel rational approximation procedure for solving the logarithmic Colebrook equation for flow friction. Instead of transcendental functions (logarithms, non-integer power) that are used in the classical approach, in this communication, we replace the logarithm with its Padé approximant and a simple rational function, which was found using artificial intelligence (symbolic regression), in order to minimize the error. Although the new rational approximation may seem unintelligible to human eyes, results of 2 million input pairs found by the quasi-Monte Carlo method [38] confirm that the relative error of this new approximation does not exceed 0.866%, which is acceptable for the empirical Colebrook law [44] (trade-off between model complexity and accuracy [45,46]). Consequently, numerical experiments on 2 million of quasi-Monte Carlo pairs indicates that the rational approximation presented here provides for Colebrook's flow friction model a useful combination of Padé approximants and artificial intelligence (symbolic regression).
Author Contributions: P.P. got the idea for the presented rational approximation approach and developed its first version. D.B. put the rational approximation approach into a form suitable for everyday engineering use. D.B. made a draft of this short note and prepared figures. P.P. wrote the software code in consultations with D.B. and tested it. All authors have read and agreed to the published version of the manuscript.
Funding: The work of P.P. has been partially supported by the Technology Agency of the Czech Republic under the project "National Centre for Energy" TN01000007 and "Energy System for Grids" TK02030039. The work of D.B. has been partially supported by the Ministry of Education, Youth, and Sports of the Czech Republic through the National Programme of Sustainability II (NPS II), IT4Innovations Excellence in Science project LQ1602, and by the Ministry of Education, Science, and Technological Development of the Republic of Serbia under the project "Development of new information and communication technologies, based on advanced mathematical methods, with applications in medicine, telecommunications, power systems, protection of national heritage, and education" iii44006.

Conflicts of Interest:
The authors declare no conflict of interest. Neither the European Commission, the VŠB, Technical University of Ostrava, the research and development Center "Alfatec", nor any person acting on their behalf is responsible for any use of this publication.