scieee AI-readable full text Open interactive document viewer

High-precision computation of uniform asymptotic expansions for special functions

Navas Palencia, Guillermo

Abstract

In this dissertation, we investigate new methods to obtain uniform asymptotic expansions for the numerical evaluation of special functions to high-precision. We shall first present the theoretical and computational fundamental aspects required for the development and ultimately implementation of such methods. Applying some of these methods, we obtain efficient new convergent and uniform expansions for numerically evaluating the confluent hypergeometric functions and the Lerch transcendent at high-precision. In addition, we also investigate a new scheme of computation for the generalized exponential integral, obtaining on the fastest and most robust implementations in double-precision floating-point arithmetic. In this work, we aim to combine new developments in asymptotic analysis with fast and effective open-source implementations. These implementations are comparable and often faster than current open-source and commercial stateof-the-art software for the evaluation of special functions.

Full text

UNIVERSITAT POLITÈCNICA DE CATALUNYA Department of Computer Science High-precision Computation of Uniform Asymptotic Expansions for Special Functions Guillermo Navas-Palencia Supervisor: Argimiro Arratia Quesada A dissertation submitted in fulfillment of the requirements for the degree of Doctor of Philosophy in Computing May 7, 2019 i Abstract In this dissertation, we investigate new methods to obtain uniform asymptotic expansions for the numerical evaluation of special functions to high-precision. We shall first present the theoretical and computational fundamental aspects required for the development and ultimately implementation of such methods. Applying some of these methods, we obtain efficient new convergent and uniform expansions for numerically evaluating the confluent hypergeometric functions 1F1(a;b;z) and U(a,b,z), and the Lerch transcendent Φ(z,s,a)at high-precision. In addition, we also investigate a new scheme of computation for the generalized exponential integral Eν(z), obtaining one of the fastest and most robust implementations in double-precision arithmetic. In this work, we aim to combine new developments in asymptotic analysis with fast and effective open-source implementations. These implementations are comparable and often faster than current open-source and commercial state-of-the-art software for the evaluation of special functions. ii Acknowledgements First, I would like to express my gratitude to my supervisor Argimiro Arratia for his support, encourage and guidance throughout this work, and for letting me choose my research path with full freedom. I also thank his assistance with administrative matters, especially in periods abroad. I am grateful to Javier Segura and Amparo Gil from Universidad de Cantabria for inviting me for a research stay and for their inspirational work in special functions, and the Ministerio de Economía, Industria y Competitividad for the financial support, project APCOM (TIN2014-57226-P), during the stay. Special thanks go to my colleges at Numerical Algorithms Group from whom I learned many important aspects in the development of numerical software, and to Fredrik Johansson for fruitful and interesting discussions, and for his remarkable work developing tools for arbitrary-precision arithmetic. Finally, I would like to thank my mother for her patience and support, and Regina for her encouragement, appreciation and understanding of the effort required to complete this work. iii Contents Abstract i Acknowledgements ii List of Figures v List of Tables vi Introduction 1 1 Analytic and Numerical Methods for Special Functions 4 1.1 Analytic methods and asymptotic expansions . . . . . . . . . . . . . . 4 1.1.1 Introduction............................. 4 1.1.2 Asymptotic methods for integrals . . . . . . . . . . . . . . . . 5 Watson’slemma .......................... 5 Laplace’s method and saddle point method . . . . . . . . . . . 6 1.1.3 Uniform expansions for Laplace-type integrals . . . . . . . . . 7 1.2 NumericalMethods............................. 7 1.2.1 Quadrature methods . . . . . . . . . . . . . . . . . . . . . . . . 8 1.2.2 Continued fractions . . . . . . . . . . . . . . . . . . . . . . . . 8 1.2.3 Sequence acceleration techniques . . . . . . . . . . . . . . . . . 9 1.2.4 Othermethods ........................... 10 2 Software Development for the Numerical Evaluation of Special Functions 11 2.1 Arbitrary-precision arithmetic . . . . . . . . . . . . . . . . . . . . . . . 11 2.1.1 Algorithms ............................. 11 2.1.2 Libraries............................... 12 2.2 Floating-point arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.2.1 Definitions and basic notation . . . . . . . . . . . . . . . . . . 13 2.2.2 Floating-point expansions and error-free transformation . . . 16 Basicalgorithms .......................... 16 2.2.3 DD vs MPFR for the evaluation of Riemann zeta function . . 17 Borwein’salgorithms........................ 18 Implementation and benchmarks . . . . . . . . . . . . . . . . . 19 2.3 Development of numerical libraries in floating-point precision . . . . 21 2.3.1 Numerical libraries and compilers . . . . . . . . . . . . . . . . 21 2.3.2 Design of software for computing special functions . . . . . . 23 2.3.3 Testing methodologies . . . . . . . . . . . . . . . . . . . . . . . 26 2.3.4 Benchmarking methodologies . . . . . . . . . . . . . . . . . . 28 2.4 GNSTLIBproject .............................. 29 iv 2.4.1 Introduction............................. 29 2.4.2 Efficient vectorization via generalized power series . . . . . . 30 2.4.3 Benchmarks............................. 32 Vectorized exponential integral E1(x).............. 32 Exponential integral E1(x)..................... 33 Exponential integral Ei(x)..................... 34 3 Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 36 3.1 Introduction................................. 36 3.2 Methods of computation . . . . . . . . . . . . . . . . . . . . . . . . . . 38 3.2.1 Specialvalues............................ 38 3.2.2 Seriesexpansions.......................... 38 Series in terms of the confluent hypergeometric function . . . 39 Laguerreseries ........................... 40 Taylor series for 1 ≤x<2..................... 42 Series expansions: special cases . . . . . . . . . . . . . . . . . . 44 3.2.3 Asymptotic expansions . . . . . . . . . . . . . . . . . . . . . . 46 Large xand fixed ν......................... 46 Large ν................................ 46 Large νand fixed x......................... 48 3.3 Other numerical methods . . . . . . . . . . . . . . . . . . . . . . . . . 51 3.3.1 Factorialseries ........................... 51 3.3.2 Continued fractions . . . . . . . . . . . . . . . . . . . . . . . . 51 3.3.3 Numerical integration . . . . . . . . . . . . . . . . . . . . . . . 52 Otherintegrals ........................... 53 3.4 Algorithm and implementation . . . . . . . . . . . . . . . . . . . . . . 53 3.4.1 Algorithm for integer order . . . . . . . . . . . . . . . . . . . . 55 3.4.2 Algorithm for real order . . . . . . . . . . . . . . . . . . . . . . 56 3.5 Benchmarks ................................. 56 3.5.1 Arbitrary-precision floating-point libraries . . . . . . . . . . . 59 3.6 Conclusions ................................. 60 4 Confluent Hypergeometric Functions 62 4.1 Background and Previous Work . . . . . . . . . . . . . . . . . . . . . . 62 4.1.1 Confluent hypergeometric function of the first and second kind 63 4.1.2 Computational methods and available software . . . . . . . . 64 4.1.3 Applications............................. 70 4.2 On the Computation of Confluent Hypergeometric Functions for Large Imaginary Part of Parameters b and z . . . . . . . . . . . . . . . . . . 77 4.2.1 Introduction............................. 77 4.2.2 Algorithm.............................. 78 Path of steepest descent . . . . . . . . . . . . . . . . . . . . . . 78 Case U(a,b,z),=(z)→∞.................... 79 Case U(a,b,z),=(b)→∞.................... 79 Case 1F1(a,b,z),=(z)→∞................... 80 Case 1F1(a,b,z),=(b)→∞................... 80 4.2.3 Numerical quadrature schemes . . . . . . . . . . . . . . . . . . 80 v Adaptive quadrature for oscillatory integrals . . . . . . . . . . 80 Gauss-Laguerre quadrature . . . . . . . . . . . . . . . . . . . . 81 4.2.4 Numerical examples . . . . . . . . . . . . . . . . . . . . . . . . 82 4.2.5 Applications............................. 83 4.2.6 Conclusions............................. 85 4.3 High-precision Computation of the Confluent Hypergeometric Functions via Franklin-Friedman Expansion . . . . . . . . . . . . . . . . . 86 4.3.1 Introduction............................. 86 4.3.2 The Franklin-Friedman expansion . . . . . . . . . . . . . . . . 87 4.3.3 The expansion for U(a,b,z).................... 89 4.3.4 The Franklin-Friedman expansion coefficients . . . . . . . . . 90 Analysis of the coefficients ck(z)................. 92 4.3.5 Efficient computation of U(a,b,z)................ 97 4.3.6 Numerical experiments . . . . . . . . . . . . . . . . . . . . . . 99 4.3.7 Discussion..............................101 5 The Lerch Transcendent and Other Special Functions in Analytic Number Theory 103 5.1 Background .................................103 5.1.1 Special number and polynomials . . . . . . . . . . . . . . . . . 103 Bernoulli numbers and polynomials . . . . . . . . . . . . . . . 103 Euler numbers and polynomials . . . . . . . . . . . . . . . . . 106 Stirling numbers and polynomials . . . . . . . . . . . . . . . . 106 Other special numbers and polynomials . . . . . . . . . . . . . 108 5.1.2 The Lerch transcendent and related functions . . . . . . . . . 110 5.1.3 Software...............................112 5.1.4 Applications.............................112 5.2 Numerical Methods and Arbitrary-Precision Computation of the Lerch Transcendent.................................114 5.2.1 Introduction.............................114 5.2.2 Numerical methods . . . . . . . . . . . . . . . . . . . . . . . . 115 Euler-Maclaurin formula . . . . . . . . . . . . . . . . . . . . . 115 Uniform asymptotic expansion for Φ(z,s,a)..........119 Asymptotic expansion for large z . . . . . . . . . . . . . . . . . 122 5.2.3 Algorithmic details and implementation . . . . . . . . . . . . 125 Evaluation of L-series . . . . . . . . . . . . . . . . . . . . . . . 126 Evaluation of the Euler-Maclaurin error bound . . . . . . . . . 127 Evaluation of the Euler-Maclaurin tail . . . . . . . . . . . . . . 129 Evaluation of asymptotic expansions . . . . . . . . . . . . . . 130 Numerical integration . . . . . . . . . . . . . . . . . . . . . . . 132 5.2.4 Benchmark .............................132 5.2.5 Discussion..............................135 5.2.6 Appendix - Algorithms and implementations . . . . . . . . . 136 L-series................................136 Euler-Maclaurin formula . . . . . . . . . . . . . . . . . . . . . 137 Asymptotic expansions . . . . . . . . . . . . . . . . . . . . . . 138 vi List of Figures 2.1 Timing of the three methods in microseconds. . . . . . . . . . . . . . . 19 2.2 Timing in microseconds for 106-bit precision vs MPFR 3.1.4. MPFR caches intermediate results for s∈ {50,60,70}.............. 21 2.3 Relative errors checked with Mathematica. Maximum relative error ≈0.8edd. ................................... 22 2.4 Decision tree generated with several methods to compute the generalized exponential integral for real order and argument. Detail with the first two split points, where class indicates the method exhibiting superior accuracy (right). . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.5 Regions of applicability of each method for the numerical evaluation of the generalized exponential integral for real order and argument. Detail for small argument x(right)..................... 25 2.6 Accuracy plot for the exponential integral using the numerical library chypergeo (left) and scipy (right).................. 28 2.7 Attained accuracy using the default algorithm for the logarithmic integral (left) and accuracy plot when using the new algorithm applied in the region exhibiting loss of accuracy (right). . . . . . . . . . . . . . 28 2.8 Comparison gnstlib.e1_vec methods to Intel vdExpInt1. ...... 33 2.9 Comparison gnstlib.e1_vec methods to MATLAB R2016b expint. . 34 2.10 Comparison gnstlib.ei_vec methods to Scipy scipy.special.expi. 35 3.1 Plot of the absolute and relative errors of E21.05(1.98)and error bound (3.36) for N∈[1,20](left). Plot of |xk/(1−21.05)k+1|,x=2 for k= [1, 40](right). .............................. 44 3.2 Accuracy profiles case n∈Nand x>0.................. 58 3.3 Performance profiles case n∈Nand x>0................ 58 4.1 Real and imaginary part of integrand for 1F1(5,10,100 −1000i)before and after applying steepest descent method. . . . . . . . . . . . . 82 4.2 Relative error in computing U(a,b,z). Error in U(a,b,iz)for a∈ [2,400],b∈[−500, 500],z∈[103,106](left) and U(a,ib,z)for a∈ [10,100],b∈[103, 104],z∈[10, 100](right). 700 and 1400 tests, respectively. .................................. 84 vii List of Tables 2.1 Main parameters of the basic formats specified by the IEEE 754-2008 standard.................................... 14 2.2 Time (ms) to compute the exponential integral of vector of size N element-wise with values within a reduced range. . . . . . . . . . . . 33 2.3 Time (ms) to compute the exponential integral of vector of size N element-wise with values in [0.0001, 700]. . . . . . . . . . . . . . . . . 34 2.4 Time (ms) to compute the exponential integral of vector of size N element-wise with values in [-670, 670]. Cases where parallelization was slower than single-thread were omitted. . . . . . . . . . . . . . . 35 3.1 Approximation terms aN. ......................... 42 3.2 Minimum number of terms kto satisfy |Bk+1(−x)|/νk+1<2−53 for the asymptotic expansion (3.56). . . . . . . . . . . . . . . . . . . . . . 49 3.3 Upper bound for Bell polynomials Bn(x)for x∈R. .......... 50 3.4 Upper bound for Bell numbers Bn. .................... 50 3.5 Comparison of different continued fractions and Laguerre series, number of terms and relative errors. Precision is set to 53-bit. . . . . . . . 52 3.6 Error statistics for each library. gcc-5.4.0 compiler running Cygwin. Time in microseconds. Fails: returns Incorrect/NaN/Inf. Intel(R) Core(TM) i5-3317 CPU at 1.70GHz. . . . . . . . . . . . . . . . . . . . . 59 3.7 Error statistics for each library. gcc-5.4.0 compiler running Cygwin. Time in microseconds. Fails: returns Incorrect/NaN/Inf. Intel(R) Core(TM) i5-3317 CPU at 1.70GHz. . . . . . . . . . . . . . . . . . . . . 59 3.8 Error statistics mpmath library. Average error is computed after excluding relative errors ≥1e−10. A result is considered wrong if relative error is >1e−14........................... 60 4.1 Relative errors of the asymptotic estimate for Pr[X1>X0]for large parameters of two Beta distributions. . . . . . . . . . . . . . . . . . . . 75 4.2 Relative errors for routines computing the confluent hypergeometric function for complex argument. N: number of Gauss-Laguerre quadratures. (∗): precision in mpmath increased to 30 digits. (E): convergence to incorrect value. (−): overflow. . . . . . . . . . . . . . 83 4.3 Error statistics for U(a,b,iz)and U(a,ib,z)using N=100 quadratures. 83 4.4 Comparison in terms of cpu time. MATLAB second evaluation in parenthesis. ................................. 83 4.5 Effectiveness of bound on ck(z)in (4.85) for q<0 and p>0. . . . . . 97 4.6 Asymptotic approximation on ck(z)in (4.89) for q<0 as p+k→∞. 97 4.7 Comparison of the absolute error values when z=15eiθand ν=3 4. Series truncated at N=100terms. ....................100 Chapter 1. Analytic and Numerical Methods for Special Functions 6 with <(z)>0 large and <(µ)>0 fixed, and f(t)has a finite number of discontinuities. If F(z,µ)converges for sufficiently large values of <(z), then F(z,µ)∼ ∞ ∑ k=0 ak Γ(k+µ) zk+µ,z→∞,|ph z|<π 2, where Γ(z)is the gamma function and akare the coefficient of the expansion of f(t) at t=0, also known as Maclaurin expansion, given by f(t)∼ ∞ ∑ k=0 aktk. Laplace’s method and saddle point method The Laplace’s method is a generalization of Watson’s lemma applicable to general integrals of the form F(z) = Zb ae−zp(t)q(t)dt . We assume that p(t)has a simple saddle point, i.e., the point t0such that p0(t0) = 0, with p00(t0)6=0, thus the local minimum of p(t). For large zthe main contribution is located in a neighbourhood of t−t0. Assuming that p(t)and q(t)are continuous in the vicinity of t0and independent of z, if F(z)converges absolutely for sufficiently large values of zthen F(z)∼rπ zp2e−zp(t0) ∞ ∑ k=0 a2k (1/2)k zk,z→∞, where (a)kis the Pochhammer symbol. Formulas for the coefficients a2krequire the coefficients of the Taylor expansion of p(t)and q(t)at the saddle point t=t0. Thus, p(t) = ∞ ∑ k=0 pk(t−t0)k,q(t) = ∞ ∑ k=0 qk(t−t0)k. The first two coefficients a0and a2are a0=q0,a2=1 p2q2−3p3q1 2p2+15p2 3 8p2 2−3p4 2p2q0. The saddle point method deals with contour integrals in the form F(z) = ZCe−zp(t)q(t)dt, for large z. The integral is taken along a path Cin a domain where p(t)and q(t) are analytic, avoiding the singularities of the integrand. The idea is to modify the contour of integration Cthrough a saddle point such that the imaginary part of the dominant part of the integral is constant, thus obtaining a steepest descent path. The resulting integral may ultimately be estimated by using one of the previous methods. This technique has been extensively applied to numerical integration of Chapter 1. Analytic and Numerical Methods for Special Functions 7 oscillating integrals, see Section 4.2. Finally, a unified formulation of Laplace’s and steepest descent method is presented in [50]. A closely related method is the determination of saddle point bounds, which are commonly derived in analytic combinatorics. An elementary saddle point bound [53, §VIII.2] satisfies that ZB Af(t)dt≤ |C0||f0(t0)|,f0(t0) = 0, where |C0|are saddle point paths made of arcs connecting Ato Bthrough t0. Thus, |C0|=|t0−A|+|B−t0|. This method is often used throughout this work, for example in Chapter 3, where we develop an effective bound for the Bell polynomials. 1.1.3 Uniform expansions for Laplace-type integrals Besides the classical Watson’s lemma, the method of Laplace and the saddle point methods, several analytic methods have been devised to obtain uniformly convergent asymptotic expansions. These methods generally require a thorough analysis of the coefficients involved, but they form a powerful set of methods to obtain uniform expansion valid for extended regimes of the parameters. These methods serve to complement the standard dichotomy between series expansion and asymptotic expansion. A detailed analysis of uniform methods applicable to Laplace-type integrals is provided in [157]. Here, we briefly present two of these methods that we shall used throughout this work. The Franklin-Friedman expansion [55,119] is a suitable method to obtain convergent uniform asymptotic expansions. This method replaces the Maclaurin expansion in Watson’s lemma by a type of interpolation process. See Section 4.3 for an extensive detailed analysis of the coefficients of the expansion. The vanishing saddle-point method [156] is an alternative method to the direct application of the Watson’s lemma for Laplace-type integrals, where parameters and argument can be simultaneously large. The resulting expansion is expressible in terms of Tricomi-Carlitz polynomials [157, §24.3], which satisfy a three-term recursive relation. A comparison between the Franklin-Friedman expansion and the vanishing saddle point method is carried out in Section 4.3, to evaluate one of the confluent hypergeometric functions. 1.2 Numerical Methods This Section covers standard alternative methods to the direct evaluation of a convergent or asymptotic series expansion for computing special functions. These methods are needed when the coefficients of the expansion cannot be computed efficiently, or the optimal truncation point of the asymptotic expansion is reached before achieving the desired accuracy. The excellent and already classic book Numerical Methods for Special Functions [61] deals with numerical methods and algorithms to approximate special functions. Chapter 1. Analytic and Numerical Methods for Special Functions 8 1.2.1 Quadrature methods Many special functions can be expressed in terms of several integral representations. This favours the development of asymptotic expansions using some of the techniques described in the previous Section. On the other hand, this also permits the use of quadrature methods when those asymptotic expansions have difficult coefficients and cannot be computed efficiently. The use of standard quadrature methods for the computation of special functions is extensively studied in[61, §5], including a discussion about the most suitable quadrature rule considering the analytical properties of the integrand. Among the variety of numerical integration methods, the most efficient methods used in practice are the extended trapezoidal rule [161], the Gauss quadrature (Gauss-Legendre, Gauss-Laguerre, Gauss-Hermite, Gauss-Kronrod among other variants) and the double-exponential integration, also known as tanh-sinh quadrature, [150,110]. The double-exponential quadrature is often preferred when evaluating integrals at high-precision since computing the nodes and weights for the integration is cheap and can appropiately handle singularities at endpoints of the interval of integration [6]. The double-exponential quadrature of an integrand f(x) over [−1,1]is given by Z1 −1f(x)dx =Z∞ −∞f(g(t))g0(t)dt ≈ N ∑ j=−N wjf(xj), for h>0, where abscissas xjand weights wjare given by xj=g(hj) = tanh π 2sinh(hj) wj=g0(hj) = π 2 cosh(hj) cosh(π/2sinh(hj))2 Numerical implementation aspects are detailed in [7]. Usually, standard methods struggle to return accurate results in the presence of severe oscillations of the integrand. For this case, one can consider the specialized methods using the doubleexponential integration method developed in [127,126] or the Gaussian quadrature [82,40], see Section 4.2 for a complete overview of numerical methods for highly oscillatory integrals. Recent developments aim to overcome the manual choice of the most suitable quadrature method for each integral using a black-box approach [91]. This method combines adaptive bisection with degree-adaptive Gauss-Legendre quadrature for the evaluation of definite integrals. This method is adequate to evaluate integrals at high-precision, say up to 1000 digits, considering rigorous error bounds rather than merely heuristic error estimates like the previous methods. 1.2.2 Continued fractions Let us define a continued fraction C=Cnwhen n→∞by [43, §1.12] Cn=b0+a1 b1+ a2 b2+. . . an bn =An Bn ,an6=0, Chapter 1. Analytic and Numerical Methods for Special Functions 9 where Cnis called the n-th approximant to C, and Anand Bnare called the numerator and denominator respectively. A continued fraction converges if the approximants Cntend to the finite limit as n→∞. The numerator and denominator can be computed iteratively by means of the recurrence relations for k≥1 Ak=bkAk−1+akAk−2 Bk=bkBk−1+akBk−2, with A−1=1, A0=b0,B−1=0 and B0=1. A modern and more convenient representation is f(z) = b0(z) + ∞ K m=1 am(z) bm(z). There are several continued fraction representations: Stieltjes fraction (S-fraction), Jacobi fraction (J-fraction), C-fraction, M-fraction and T-fraction. Additionally, approximants modifications to improve convergence of these continued fractions are discussed in [38]. Continued fractions are generally computed by means of one of the following methods: forward recursion using the above three-term recurrence relations, backwards recurrence algorithm, Steed’s algorithm and the modified Lentz’s algorithm. The latter is the preferred choice due to avoidance of successive rescaling and that prior information about the value of nis not required [61]. Continued fractions are a common technique to evaluate special functions and their quotients. Continued fractions are applied for the computation of confluent hypergeometric functions in [113]. A comparison among several continued fractions types for evaluating the generalized exponential integral is presented in Chapter 3. Lastly, we refer the reader to [38] for an exhaustive treatment of theoretical and numerical aspects for continued fractions. 1.2.3 Sequence acceleration techniques For some particular methods the resulting series expansion converges very slowly, requiring a large number of terms to yield just a few correct digits. In addition, the cost becomes prohibited for a series expansion with coefficients involving functions hard to compute. In these cases, series acceleration techniques stand out as powerful tools to improve convergence at the expense of performing several operations with partial sums. Therefore, the goal of convergence acceleration algorithms is to accurately estimate the sum of slowly convergent infinite series. There exist an extensive literature on sequence (series) acceleration, also referred as sequence transformations. For examples and covering of many transformations such as the classic techniques (the Euler’s transformation, Shank’s transformation and Levin-type transformations among others) we refer the reader to [21,142]. Nowadays, there is not a universal technique that can efficiently accelerate the convergence of all infinite series, in contrast, there are tailored algorithms for different types of sequences. For example, a novel technique developed to accelerate the convergence of generalized hypergeometric functions is studied in [168]. Chapter 1. Analytic and Numerical Methods for Special Functions 10 Other methods often applied to improve convergence properties of a power series are the well-known Euler-Maclaurin formula, requiring derivatives and Bernoulli numbers and polynomials, and the Abel-Plana formula, with no derivatives required, see [43, §2.10]. In the last decades, significant research has been endeavoured to develop efficient algorithms to accelerate the convergence of alternating and divergent series. A simple yet very effective linear method is presented in [35]. This method has been widely applied in number theory for rapid evaluation of alternating sums to very high precision. Nonlinear acceleration methods have been extensively treated by Weniger in [166,86] among other works, where the transformation of monotone slowly convergent series into an alternating series is investigated. Another interesting method for the summation of divergent asymptotic series is the use of factorial series [167]. Finally, note that the technique in [35] is applied to accelerate convergence are remove cancellations when evaluating the Lerch transcendent for small negative argument, see Chapter 5. 1.2.4 Other methods The described methods are generally applicable for the computations of special functions in arbitrary-precision. However, there are also some other methods tailored for computation at fixed precision that can be encountered in many numerical libraries. Chebyshev expansions, rational Chebyshev approximations and Padé approximations [61, §9.2] were methods popularly used during the last part of the past century to develop numerical routines for the evaluation in double-precision floatingpoint arithmetic. These methods are applicable to approximate a function f(x)by a polynomial p(x)within real intervals [a,b]with uniform accuracy. The minimax approximation is the best option to approximate a continuous function f(x)on an interval [a,b]. For details and examples for univariate special functions we refer to the work developed by W. J. Cody [30,28] and the numerical library developed by the same author, SPECFUN [29], where this type of methods are often used to accurately compute functions for arguments in bounded intervals. To conclude, we remark that occasionally, methods to approximate solutions of ordinary differential equations such as Runge-Kutta methods may be a viable alternative when no available method returns a satisfactory value for some function’s domain, see discussion in [133, §Appendix C]. 11 Chapter 2 Software Development for the Numerical Evaluation of Special Functions In the second Chapter, we focus on the main aspects considered when developing numerical software for the evaluation of special functions. The first two Sections are devoted to arithmetic in fixed and arbitrary-precision, where we present algorithms implemented in software arithmetic (not to be confused with hardware arithmetic). The remaining Sections discuss fundamental aspects in numerical software development such as the use of standard libraries for compatibility, compilers and best practices for proper testing, profiling, and deployment. The Chapter concludes with an introduction to GNSTLIB, a numerical library written in C++ for the evaluation of special functions developed following the principles previously presented. 2.1 Arbitrary-precision arithmetic In what follows we briefly summarize some fundamental arbitrary-precision algorithms for performing arithmetic operations, which are implemented in packages for the computation of elementary and special functions. By high-precision, more generally arbitrary-precision, we refer to higher precision than the achievable directly using IEEE 754 standard floating-point hardware, introduced after this subsection. A modern book on the subject is Modern Computer Arithmetic [18], complementing the classical reference [99], which we refer to more complete material. 2.1.1 Algorithms Let us define nas the number of binary digits required to obtain a result with accuracy 2−n. For addition and subtraction of two n-bit integer numbers the cost is O(n), but in computer algebra the quintessential primitive operation is multiplication. Consider M(n)a bound for the time, measured in word or bit-operations, required to multiply two n-bit integer numbers or polynomials of degree n−1. The naive multiplication algorithm (schoolbook multiplication) gives M(n) = O(n2) and the subquadratic “divide and conquer" multiplication algorithm by Karatsuba [96] gives M(n) = O(nlog23)≈O(n1.585). For large n, the Schönhage-Strassen algorithm [139], based on the fast Fourier transform gives M(n) = O(nlog nlog log n) Chapter 2. Software Development for the Numerical Evaluation of Special Functions 12 asymptotic complexity. In general, the naive multiplication algorithm is used for small n, and subquadratic algorithms are used elsewhere except for very large n, where asymptotic complexity algorithms are preferred. A good survey of algorithms for fast multiplication with applications can be found in [9]. The division operation is avoided when possible, and replaced by multiplication since it is a more expensive operation [18, §1.4]. Note that the complexity of the arithmetic operations of p-bit floating-point numbers is the same as the described for integer numbers, up to a constant factor [20, §3]. Several techniques are used for computing elementary transcendental functions to arbitrary-precision. The basic and widely used techniques are: argument reduction, the arithmetic-geometric mean (AGM), Newton’s method and fast methods for evaluation of power series. Argument reduction (expansion) is a technique used to decrease (augment) the magnitude of the argument to a domain where the function can be evaluated effectively. This result in the evaluation of fewer terms to achieve the desired accuracy thus improving the convergence rate; for example exp(x)=(exp(x/2k))2k. Other tricks such as combination of power series after argument reduction or the use of symmetries are usually exploited in software implementations. When computations are performed at very large precision p, the AGM algorithm is chosen due to its asymptotic complexity; requires O(M(p)log p) bit operations to give p-bit accuracy. On the other hand, Newton’s method can be used in the same cases where AGM is applicable. Newton’s method has complexity O(M(p)log p), but increased with a constant factor. Now, we mention several techniques to evaluate polynomials of degree P(x) = ∑n−1 k=0akxkat p-bit precision, resulting after determination of the optimal truncation point when evaluating a power series. Hereinafter, we assume that coefficients ak+j/akare rational functions, which eases a sequential evaluation by means of a linear recurrence (this is the common case of hypergeometric functions, see Chapter 4). Fast algorithms for evaluation of linear recurrence include the binary splitting, rectangular splitting and fast multipoint evaluation. A naive forward recursion algorithm requires O(n2)operations and is only suitable at low precision. The binary splitting algorithm has time complexity O(M(n)log n)as noted in [19]. In this algorithm the finite sum is computed by “divide and conquer" [18, §4.9]. The fast multipoint evaluation method allows evaluation of the n-th term of a linear recurrence in O(M(√n)) operations [17]. The rectangular splitting algorithm [18, §4.4.3] is based on the baby-step giant-step technique in [130] and extended in [145]. The idea of rectangular series splitting is to evaluate a power series with O(√n)nonscalar multiplications and O(n)scalar operations using O(√n)storage. Finally, a description of the domain of applicability of each algorithm in the context of the evaluation of hypergeometric functions is given in [88,90]. 2.1.2 Libraries Here we present a list of popular open-source software packages for arbitraryprecision arithmetic. 1. GMP [69]: The GNU MP is a library written in C and the main reference for arbitrary-precision arithmetic. Most of the new developments are built on Chapter 2. Software Development for the Numerical Evaluation of Special Functions 13 this library. GMP is released under the GNU Lesser General Public License (LGPL). 2. MPFR [54]: The MPFR is a library written in C for arbitrary-precision floatingpoint computations with correct rounding and exceptions, extending the ideas of the IEEE 754 standard. This library is based on the GMP and therefore also distributed under the GNU LGPL. 3. MPC [47]: The GNU MPC library, is a C library for arbitrary-precision complex arithmetic with correct rounding, based on the MPFR and GMP libraries. This library is also distributed under the GNU LGPL. 4. mpmath [92]: This is a Python library for arbitrary-precision real and complex arithmetic. Mpmath can use GMP as a backend, replacing native Python integer operations thus improving performance at high precision. Mpmath is distributed under the Berkeley Software Distribution (BSD) license. 5. Arb [87]: Arb is a C library for rigorous real and complex arithmetic with arbitrary precision. This library differs from the previous ones on the approach to tracking numerical errors, which relies on a form of interval arithmetic based on a midpoint-radius representation called ball arithmetic. Arb is distributed under the GNU LGPL. 2.2 Floating-point arithmetic In this subsection, we present a brief survey on the extensive topic of floating-point arithmetic. An excellent reference for this subject is the Handbook of Floating-point Arithmetic [112] to which we refer the reader for further reading. After a mandatory introduction to floating-point arithmetic, this subsection is focused on the less known floating-point extensions. Floating-point extensions are used when higher precision than the standard double-precision or binary64 is required, and a software implementing arbitrary-precision arithmetic is not available. This need arises in numerical problems in mathematics, physics and engineering fields when higher precision is necessary to compensate cancellation or ill-conditioned sums (for example, the procedure known as iterative refinement when numerically solving a system of linear equations). Some of the techniques presented are implemented and discussed in detail in Section 3.4. for the numerical evaluation of the generalized exponential integral. 2.2.1 Definitions and basic notation Let us start by defining a floating-point number in binary representation. A normal binary floating-point number with precision p-bit is a number of the form x=M·2e−p+1, (2.1) where Mis a signed integer denoted as the significant or mantissa of x, which absolute value is bounded 2p−1≤ |M| ≤ 2p−1. The integer eis called the exponent of x. The 2 in above formula represents the base or radix for exponentiation, in this Chapter 2. Software Development for the Numerical Evaluation of Special Functions 14 case binary. The commonly used bases to represent floating-point numbers are decimal (the scientific notation with base ten) and binary with base two. Let us define emin and emax as the minimum and maximum allowed exponent, respectively. Three extreme cases are considered: 1. minimum subnormal number: 2emin−p+1. 2. minimum normal number: 2emin . 3. maximum normal number: 2emax (2−21−p). In order to store floating-point number correctly, its significant must be normalized, i.e,. must be represented in the normal form (2.1), assuring the first bit of the significant is set to 1 and adjusting the exponent accordingly. This process is known as normalization. For example, 1001.101 is normalized as 1.001101 ·23. A floating-point number xsatisfying that x≤2emin is called subnormal or denormalized number. This number is characterized by having the leading bit of the significant set to 0, which result in an exponent that is below emin. In the IEEE 754 standard, described below, an underflow exception is raised when a subnormal number occurs and the operation is inexact. The IEEE 754 standard, specifies interchange and arithmetic formats and methods for binary and decimal floating-point arithmetic, along with exception conditions and their default handling, in computer programming environments. The active IEEE 754-2008 standard[146]1supports several binary formats. The characteristics of the three most common floating-point binary storage formats are listed in Table 2.1. For example, the bits for binary64 or double-precision are arranged as follows, 1 bit for the sign, 11 bits for the exponent, and 52 bits for the significant. format word size sign exponent significant p emin emax Binary32 (Single) 32 1 8 23 24 -126 127 Binary64 (Double) 64 1 11 52 53 -1022 1023 Binary128 (Quad) 128 1 15 112 113 -16382 16383 TABLE 2.1: Main parameters of the basic formats specified by the IEEE 754-2008 standard. The operations specified by the IEEE 754-2008 are: addition/subtraction, multiplication, division/remainder and squared root. All values from these operations are returned with correct rounding using the current rounding mode. The IEEE 754 standard considers five exceptions that can be flagged during a calculation. The first three exceptions (invalid operation, division by zero and overflow) are the most common exceptions and can be easily identified. The last two (underflow and inexact) and usually ignored, and careful inspection is required to detect the source of errors. 1. Invalid operation: This exception is raised if the result of a calculation is mathematically undefined. By default returns quite NaN. A few examples: √xwhere x<0 or (±0)/(±0). 1The active IEEE 754-2008 standard was adopted in June 2008. This version superseded two previous standards from 1985 and 1987. Two of the major additions with respect to previous standards are the fused multiply-add (FMA) operator and including quadruple precision. Chapter 2. Software Development for the Numerical Evaluation of Special Functions 15 2. Division by zero: This occurs when computing x/0 if xis a nonzero finite number, the division by zero exception is flagged. The result is a correctly signed infinity. 3. Overflow: This exception is raised when the absolute value of the computed result is strictly larger than the maximum normal number, i.e., |x|>2emax (2− 21−p), or equivalently, when the exponent of the computed result is strictly larger that emax. 4. Underflow: This exception is raised when the result of computation is a nonzero of absolute value less than |x|<2emin . In this case, the returned value is in the subnormal range, and a significant loss of accuracy may occur. The returned value is subnormal or zero. 5. Inexact: This exception is raised when the rounded result of a valid operation is not exact. The correctly rounded, overflowed or underflowed result is returned. Floating-point operations are performed internally with extra precision. The calculated values, not exactly representable in the same floating-point system used for the input data, are returned rounded to ensure precision. The IEEE 754 defines four possible rounding modes: 1. Round toward +∞: result is rounded to the smallest representable value which is greater that the result. 2. Round toward −∞: result is rounded to the largest representable value which is less that the result. 3. Round toward zero: truncation, it is similar to the common behaviour of float- to-integer conversions. If the result is negative is rounded up, and contrarily for positive result. 4. Round to nearest: the result is rounded to the nearest representable value. Two modes: the default rounding mode for binary floating-point arithmetic is round to nearest even, which in case of ties, select result with even significant. Alternatively, round to nearest away, where ties round away from zero (used only for decimal floating-point arithmetic). To conclude, we introduce two instruction sets currently supported by many processors. We refer to [112, §3.5-3.6] for an extended list of instructions supported by modern CPU and GPU. 1. Fused multiply-add (FMA): The FMA instruction was introduced to facilitate correctly rounded software division and to make some calculations (especially dot products and polynomial evaluations) faster and more accurate. The new IEEE 754-2008 standard for floating-point arithmetic specifies the FMA instruction. The FMA instruction performs the operation a×b+cwith only one rounding error with respect to the exact result. This is actually a family of instructions that includes useful variations such as fused multiply-subtract. The processors implementing these instructions sets provide hardware FMA operators, with latencies comparable to classical +and ×operators. Chapter 2. Software Development for the Numerical Evaluation of Special Functions 22 10 20 30 40 50 s 10−35 10−34 10−33 10−32 10−31 10−30 10−29 relative error dd ≈4.93038e−32 dd error FIGURE 2.3: Relative errors checked with Mathematica. Maximum relative error ≈0.8edd. (Cephes[111] and GSL[56]). On the other side, two classical commercial libraries including special functions from their very first release are IMSL[147] and NAG[114]. Recent alternatives are Boost[11] and AMath[46]. In addition, some scientific journal such as TOMS stores the collected algorithm of the ACM, published by the journal ACM Transactions on Mathematical Software. Other public repositories are Netlib or John Burkardt webpage https://people.sc.fsu.edu/~jburkardt/, where one can find a great deal of TOMS codes written or translated to C++. New numerical libraries for the evaluations of special functions should make use of high-performance libraries with parallelization capabilities on the CPU, and ideally GPU. The Intel Math Kernel Library (MKL) is a good example, including functions to accelerate and optimize routines in linear algebra, statistics and common special functions. This is a high-optimize and easy-to-use library including vectorized mathematical functions. In particular, includes an extensive list of vectorized special functions5. Additionally, several programming languages include many common and special functions as a part of their standards; for example, C++17 <cmath> incorporates new special functions such as elliptic integrals or exponential integrals. Finally, as mentioned later, most of the previous numerical libraries do not cover correctly all functions’ domain, especially for those functions with several real and complex parameters and arguments. Nevertheless, some of the functions correctly implemented can be used as building blocks for new implementation of more involved functions. For the development of numerical libraries in Fortran or C/C++, we required the use of compilers. The following list includes the most widely used compilers by programming language: 5https://software.intel.com/en-us/mkl-developer-reference-c-vm-mathematical-functions Chapter 2. Software Development for the Numerical Evaluation of Special Functions 23 •C/C++: GNU (gcc and g++), Clang C++ and Intel C++ (icc). Vendors benchmarks6. •Fortran: GNU (gfortran), Intel Fortran (ifort), NAG Fortran compiler, PGI compilers and absoft Fortran compiler. Vendors benchmarks7. During the development, it is convenient to use different compilers with high checking capabilities and detailed error reporting, rather than the compilers producing the best performance results. This extensive checking is useful to write cleaner code (some compilers include source file polishers) leading to fewer mistakes. For deployment, the fastest compiler across all supported platforms is used. Note that compilers’ performance is strongly influenced by the use of adequate optimization flags; careful and systematic testing of these flags is required, as noted below. Finally, we remark that apart from automatic optimization and vectorization performed by the compiler, it is recommended to write algorithms using techniques allowing optimizations. For example, writing power series or piecewise approximation polynomials using the Horner scheme with a fixed number of terms permits loop-unrolling optimizations available in all modern compilers. 2.3.2 Design of software for computing special functions The implementation of special functions in double-precision floating-point arithmetic presents some major difficulties when most of a the function’s domain needs to be correctly covered. For arbitrary-precision arithmetic, implementation of special functions usually includes only a few algorithms, and working precision is adequately incremented to compensate numerical instabilities. However, this approach is not suitable for fixed-point arithmetic. Therefore, the goal is to combine various methods in order to efficiently and accurately compute a wide region of the function’s domain. These methods range from series expansions and continued fractions to numerical quadrature. In cases when there are various valid methods for the same function’s domain, the obvious choice is the fastest and more accurate method. For these cases, it is also a good practice to enable various execution modes for the same function, allowing the choice of the best suitable method for each application. This is a common practice to control central compiler behaviours, for instance, optimization flag -ffast-math on GCC compiler might yield faster code, but do not guarantee the strict IEEE compliance. For some special functions, the achievable accuracy of each method can be effectively estimated by developing rigorous error bounds. Generally, these developments require hard theoretical error analysis, especially when dealing with complex uniform asymptotic expansion with various parameters involved. Therefore, unfortunately, only a few rigorous bounds are known for elementary functions on restricted domains. Availability of such rigorous limits eases the correct determination of the region of applicability for each algorithm and permits to identify regions where none of the considered algorithms behaves adequately. Besides, these bounds might be used to determine the required number of iterations to achieve 6https://software.intel.com/en-us/c-compilers/features/benchmarks 7https://www.fortran.uk/fortran-compiler-comparisons/ Chapter 2. Software Development for the Numerical Evaluation of Special Functions 24 certain accuracy; for asymptotic expansions this helps to detect if it is applicable with given parameters and argument values. However, when rigorous bounds are not available, it is unavoidable to resort to using heuristic error estimates, giving up rigour and being exposed to incorrect results. Therefore, if used, these must be meticulously tested to have strong empirical results about their usability. Implementations of special functions with several parameters and argument tend to require several methods. If various methods cover the same regions of the function’s domain, the process of manually choosing the most suitable method for each region becomes a time-consuming task. One can treat this problem using classification algorithms such as decision trees, widely employ in predictive modelling. Given a large set of samples with features (parameters and argument) and a multi-class target (the most accurate and/or fast method for each sample), we aim to devise the best split points for each feature in order to predict the class (the most suitable algorithm) and the probability of each class. This method does not substitute a numerical analysis of error bounds but generates a first set of rules useful to develop heuristics. As an advantage, decision trees are data structures easy to visualize and interpret, which rules can be straightforwardly translated into code. The main disadvantages include over-complex trees producing over-fitting and the need to have implementations for several methods, some of which may be discarded in the final algorithm. Figure 2.4 show a decision tree example generated with several methods to compute the generalized exponential integral. On the other hand, Figure 2.5 presents an alternative plot with regions of applicability of each method for the same functions. Note that these type of plots are difficult to interpret as the number of parameters increases, even using pairwise plots and for these cases, therefore, binary trees improve visualization. FIGURE 2.4: Decision tree generated with several methods to compute the generalized exponential integral for real order and argument. Detail with the first two split points, where class indicates the method exhibiting superior accuracy (right). Besides considering several methods, the use of connection formulas with simpler formulas is recommended to facilitate code maintenance and reduce development times. Furthermore, the implementation of many special cases, expressible in Chapter 2. Software Development for the Numerical Evaluation of Special Functions 25 0 50 100 150 200 x 0 50 100 150 200 ν ν=x UASYMP S-FRACTION ASYMP QDE2 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 x 0 10 20 30 40 50 60 70 ν QDE1 QDE2 TAYLOR UASYMP FIGURE 2.5: Regions of applicability of each method for the numerical evaluation of the generalized exponential integral for real order and argument. Detail for small argument x(right). terms of simpler formulas, also reduces sources of numerical instability improving consistency across the same family of functions. In some applications we need scaled versions of special functions to widen the region of calculation and avoid overflow problems, for instance, when evaluating ratios of functions with an exponential terms. Additionally, some specific regions such as the vicinity of function zeros suffer from accuracy loss and require algorithms implemented in extended precision to mitigate catastrophic cancellation and other numerical issues, see Section 3.2.2. Many open-source and commercial libraries exhibit similar accuracy degradation when evaluating functions in close vicinity of zeros. However, not many include efficient algorithms for these regions. Any new numerical library should be designed taking into account this severe problem; for instance, see efficient algorithm for Bessel functions in [74]. In addition, some challenging regions of a function’s domain might present numerical difficulties for all algorithms. These cases can be effectively treated by the use of efficient analytic continuation along a path, from a proximal point correctly evaluated to the point of interest by connecting local solutions. Given a function defined by a second order ordinary differential equation (ODE) with known derivatives at an arbitrary point z, it is possible to build generalized power series (local Taylor series expansion) which can be used to compute values in a neighbourhood of the point z. Although this computation method is primarily used to cover difficult corner cases, it can also find applications in sensibility analysis, when we need to evaluate a function to many similar points. Therefore, we can develop specific algorithms which can be effectively vectorized, as shown in Section 2.4.2. The main inconvenience of this approach is that computation of generalized power series for some functions can be trickier than the function in question. Another important aspect missing in many numerical libraries implementing Chapter 2. Software Development for the Numerical Evaluation of Special Functions 26 special functions is the availability of vectorized versions exploiting multi-core architectures and SIMD (single instruction multiple data) instructions of modern processors. Vectorization refers to the evaluation of a function on an array of values at once avoiding looping over each array element. These functions are generally implemented in low-level programming languages (C/C++ or Fortran) to reduce overhead when looping in languages such as Python8or R, and can easily interface with OpenMP for developing parallel implementations. Finally, it is important to consider development tools to locate and fix performance issues. Checking why a software is slow is an extremely time-consuming task, therefore fast code analysis to detect bottlenecks is critical. There are broadly used tools such as Callgrind (front-end for Valgrind9), and its accompanying visualization tool KCachegrind, to profiling and generating call-graphs. Furthermore, Intel R Parallel Studio XE is a great tool to analyse performance and memory access, and report possible optimizations for single and multi-threading applications, being useful to assure that the executed code effectively exploits multi-core architectures and detect which parts of the code are blocking vectorization. 2.3.3 Testing methodologies There are several methods to test the quality of the implementation of special functions. These methods use distinct well-established metrics, such as achievable absolute and relative accuracy and efficiency or computation time among others. A reliable numerical library, usable in production environments, must show stable performance when used in various infrastructures with different specifications. In general, automatic testing tools are employed to generate various configuration settings combining different processors, compilers and optimization flags. Some companies developing commercial multi-platform numerical libraries, consider robustness when the maximum difference in terms of precision for a given function across different configurations is about 104eand 102e, where eis the machine precision. In situations where higher differences or inconsistent performance is observed across some supported platforms, a careful inspection of the implemented algorithm is required. Eventually, the algorithm should be changed in order to maintain homogeneous accuracy levels across all supported environments, guaranteeing portability. In case, no suitable algorithmic substitution exist, these performance issues must be adequately documented. The standard and widely used automation testing tool in the software development industry is Jenkins10. Jenkins is an open-source tool used to automate processes with continuous integration (CI) to facilitate monitoring tasks during development, ultimately reducing time-to-market delivery. Other popular CI tool is Travis11. Several methods exist to assess the achievable accuracy of a function implemented in double-precision floating-point arithmetic. The most widely used method is to compute relative and absolute errors with respect to the same function evaluated at higher precision, say quadruple, octuple-precision or superior. For instance, 8Note that vectorization in numpy arrays are fast because ufunc is implemented in C. 9Valgrind is used to detect memory management bugs (memory leaks) and profile performance. 10https://jenkins.io/ 11https://travis-ci.com/ Chapter 2. Software Development for the Numerical Evaluation of Special Functions 27 various values are computed using a software package of arbitrary-precision arithmetic to ascending levels of precision, assuring sufficient certainty about the precision of the result used as a reference. Note that, this method can only be trusted if reliable computer algebra systems (CAS) are employed to perform validations. Basic testing of special functions include the evaluations of special values, which provides a first estimation of the attainable accuracy. Other methods for verification involve the use of functions relations via evaluation of Wronskians [61], evaluations of functional relationships and other special cases such as the zeros of the function. Naturally, the functional relationships used to assess accuracy must be well-conditioned to be utilized for verification purposes. The other main metric to evaluate the performance of an implementation is computational time. Obtainment of accurate and reliable timing measurements might be tricky under certain settings, ultimately generating misleading conclusions. For implementations in double-precision, it is common that functions calls take more than the execution time of the function itself, thus difficulting the determination of the actual performance. In order to circumvent the problem, it is recommended to measure the time required to evaluate a function many times, diminishing the impact of function calls. Finally, the average and deviation of CPU times is reported. In other cases, a given function is evaluated during an elapsed-time, returning the number of evaluations. These precautions are needed to perform a fair comparison among different software implemented in various programming languages. During the development of new algorithms, it is recommended to evaluate their consistency with respect to other methods used to evaluate a function in the same regions. This allows a comparison in terms of accuracy and CPU time per iteration, facilitating the selection of the most efficient algorithm. An alternative method for univariate and bivariate functions is accuracy evaluation by visual inspection. The idea is simple, evaluate a function randomly within its parameters regions and plot the attained accuracy to detect wherever loss of accuracy is exhibited. Figure 2.6 compares the accuracy of the exponential integral for complex argument between the implementation in the numerical libraries chypergeo12 and scipy. We observe that the implementation in scipy shows a significant loss of accuracy around <(z)≤5, due to the use of the ascending series. In some particular cases, the affected regions are well determined, permitting the study of specific algorithms to improve the accuracy in that particular region. Figure 2.7 shows a concerning loss of accuracy in the sector arg(z)∈[1.7,1.9]; the first image shows the performance of the initial implementation, whereas the second image shows how a new algorithm for that particular region reduces this loss. Additionally, note that this type of tests requires the use of appropriate legends to correctly identify regions of study. Nevertheless, performance assessment by visual inspections is difficult to undertake when evaluating multivariate functions, therefore, is only a viable approach for univariate and bivariate functions. Finally, a robust testing environment should include tools for reporting and monitoring tasks, along with a warning system to ease the detection of those cases 12https://sites.google.com/site/guillermonavaspalencia/software/chypergeo Chapter 2. Software Development for the Numerical Evaluation of Special Functions 28 FIGURE 2.6: Accuracy plot for the exponential integral using the numerical library chypergeo (left) and scipy (right). FIGURE 2.7: Attained accuracy using the default algorithm for the logarithmic integral (left) and accuracy plot when using the new algorithm applied in the region exhibiting loss of accuracy (right). requiring revision. Usually, automatic building of code into the version control system and testing is performed overnight, this is usually called a nightly build. Automated builds are generally run on dedicated servers with stable CPU workloads to avoid altering performance metrics. 2.3.4 Benchmarking methodologies The amount of information gathered during testing of different mathematical software packages is analysed for posterior comparisons. In order to compare and benchmark the mathematical software, the performance profiles were developed in [44]. This method was devised to assess the performance of optimization packages and sparse linear algebra, as a way of providing objective information, but has become a popular tool in other mathematical fields. Many metrics can be compared by means of performance profiles, CPU times, number of iterations and attained accuracy are some commonly used for benchmarking. This methodology has been Chapter 2. Software Development for the Numerical Evaluation of Special Functions 29 subject to criticism by several authors, due to being a biased method when ranking after excluding one particular library from the comparison. Therefore, performance profiles are appropriate when comparing two solvers, but comparison among more than two solvers leads to misleading conclusions regarding the performance of one solver relative to another. Recent work in [76] propose a reliable algorithm to bypass the negative side effect incurred by performance profiles. When comparing mathematical software in terms of CPU time, one approach is to use the shifted geometric mean, as used in well-known and publicly accepted optimization software benchmarks http://plato.asu.edu/bench.html. For benchmarking special functions, besides CPU times, we consider statistical analysis of the relative and absolute errors with respect to reference values. These statistics permit comparison by parameters regions, building a ranking with the best numerical library for each region of interest. An extensive example is presented in Section 3.5, comparing different numerical libraries implementing the generalized exponential integral. 2.4 GNSTLIB project 2.4.1 Introduction GNSTLIB is a numerical library currently developed in C++11 for fast and accurate computation of special functions in double-precision floating-point arithmetic. The aim of GNSTLIB is to be used as stand-alone C++ library and provide wrappers for the major programming languages used in scientific computing, such as Fortran, C and Python. This library includes vectorized versions of all special functions implemented. These routines include an option to trigger OpenMP for parallelization, thus taking advantage of multi-core processors. Furthermore, several algorithms for multi-evaluation of univariate special functions via analytic continuation/generalized power series are implemented. These routines are suitable for the evaluation of large samples with values within a small range, as previously mentioned. This library is developed with the following considerations: 1. Quality: most of the algorithms implemented have been published in peerreview journals (verified software such as ACM TOMS). An extensive framework for testing has been developed to guarantee the highest quality standards. 2. One of the goals is to fill several gaps in the available software for the evaluations of special functions. This is achieved by developing new algorithms and improving those widely used showing a loss of accuracy in some regions. 3. Flexibility: new software must have interfaces for most programming languages. 4. Parallelization and vectorization are a must. The GNSTLIB project was initiated by the present author in 2016 with the development of Chypergeo13, which was the basis for the development of GNSTLIB. 13https://sites.google.com/site/guillermonavaspalencia/software/chypergeo Chapter 2. Software Development for the Numerical Evaluation of Special Functions 30 During the author’s stay at Universidad de Cantabria in May 2017, Amparo Gil, Javier Segura and Nico M. Temme joined the project. GNSTLIB 0.1 was released in November 2017 and was made freely available at https://sites.google.com/ site/guillermonavaspalencia/software/gnstlib. Version 0.1 includes 1. Elementary functions (real and complex) 2. Gamma functions (real and complex) 3. Exponential, logarithmic and trigonometric integrals (real and complex) 4. Error functions, Dawson’s and Fresnel integrals (real and complex) 5. Incomplete Gamma and generalized exponential integral (real) In addition, GNSTLIB 0.1 was presented in the International Conference on Computational Science and Engineering, Oslo 2017. Future releases will include Airy, Bessel and confluent hypergeometric functions among others. The addition of statistical distributions and routines for fast computation of Gauss quadratures is also on the roadmap. Furthermore, we plan to include GPU implementation of special functions, extending the CUDA Math Library to provide high-performance when running large simulations. In the next subsections, we describe the algorithmic details of the multi-evaluation vectorized implementation of the exponential integral and show various benchmarks results comparing against open source and commercial libraries. 2.4.2 Efficient vectorization via generalized power series In this subsection we present a methodology for multi-evaluation of univariate special functions via generalized power series, using as an illustrative example the exponential integral. The use of generalized power series can benefit the evaluation of an array of arguments with small variations, which might occur when performing sensitivity analysis in some applications in engineering. Let us define the exponential integral for real argument as a Cauchy principal value Ei(x) = PZx −∞ et tdt,x∈R. (2.12) The exponential integral series representation is given by Ei(x) = γ+log(x) + ∞ ∑ k=1 xk kk!−(iπ,x<0 0, otherwise , (2.13) and the generalized power series at x=x0is given by Ei(x) = Ei(x0)− ∞ ∑ k=1 (−1)k k!xk 0 Γ(k,−x0)(x−x0)k, (2.14) where Γ(k,−x0)is the upper incomplete gamma defined as Γ(k,−x0) = (k−1)!ex0 k−1 ∑ m=0 (−x0)m m!,k∈N. (2.15) Chapter 2. Software Development for the Numerical Evaluation of Special Functions 31 Let us define the coefficients Ak(x0,x)as follows Ak(x0,x) = (−1)k(x−x0)kex0 kxk 0 k−1 ∑ m=0 (−x0)m m!, (2.16) thus, we obtain Ei(x) = Ei(x0)− ∞ ∑ k=1 Ak(x0,x), (2.17) The basic usage of generalized power series is to perform analytic continuation steps |xi−x0|for i=1,2, . . .. Note that there exists a trade-off in choosing the steps lengths |xi−x0|, since larger steps yield slower convergence, i.e., more terms are needed. In order to determine the required numbers of terms given |x−x0| we calculate two rigorous upper bounds for the regions x0>0 and x0≤ −18. The uncovered region x0∈(−18,0)utilizes the first bound, since it is found that performs reasonably well based on numerical experiments. Proposition 2.4.1 For x0>0and (x,x0)∈R |x−x0|k k1 xk 0−ex0 k!<2−p|Ei(x0)|, (2.18) where p indicates the precision in bits. Proof: First, by observing that k−1 ∑ m=0 (−x0)m m!=e−x0− ∞ ∑ m=k (−x0)m m!. (2.19) The problem is reduced to find ksuch that |Ak(x0,x)|is below a given threshold. For x0>0 the series is alternating, therefore the following inequality is satisfied e−x0− ∞ ∑ m=k (−x0)m m!≤e−x0−|x0|k k!, (2.20) plugging into (2.16) and after performing basic manipulations we obtain the result.  Proposition 2.4.2 For x0≤ −18 and (x,x0)∈R |Ak(x0,x)| ≤  x−x0 x0 kex0 k!(1+ (k−1)/x0)<2−p|Ei(x0)|. (2.21) Proof: We use a majorant ¯ Γ(k,x0)≥Γ(k,x0)described in [10] valid when the following two conditions are satisfied x0+1≥kand 1 ≥1 p1+π(k−1)/2 +k−1 x0. (2.22) Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 38 representations for the cases x<1 and x≥1. This algorithm applies the recurrence Eν(x) = 1 x(e−x−νEν+1(x)),(x>0, ν∈R)(3.12) and combines Taylor series expansion, series expansion in terms of Tricomi functions and uniform asymptotic expansion for large ν. The outline of the work is the following: First, we study some of the main numerical methods considered for the evaluation of Eν(x), including error bounds, and we describe a new asymptotic expansion along with several improvements for difficult regions of computation. Then, we review other methods of computation implemented in several software packages, focusing in quadrature methods and suitable integral representations. Subsequently, we present our algorithm and a detailed description of its implementation. After that, we assess the performance of our algorithm – in terms of relative error and computation time – and we compare to other publicly available codes. Finally, we present our conclusions. 3.2 Methods of computation In this section we provide a detailed description of the methods of computation implemented in the algorithm, both for the special case ν≡n,n∈Nand the general case ν∈R+. 3.2.1 Special values Special cases are typically treated separately, here we list some of the most relevant cases: E0(x) = e−x x,x6=0, (3.13) which can be used as starting point for recursive evaluation of En(x). For x=0 Eν(0) = (1 ν−1,ν>1 ∞,ν∈(−∞,1](3.14) For ν=1/2 we have the following value, which is also used for recursive evaluation of half-integers E1 2(x) = √π √xerfc(√x). (3.15) Finally, ν=1, the so-called exponential integral E1(x) = −Ei(−x),x>0. (3.16) 3.2.2 Series expansions Series expansions for the generalized exponential integral are commonly used in the domain |x|.1. We consider two different series expansions valid when the Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 39 parameter ν∈R\N. The first expansion [43, §8.19.10] is given by Eν(x) = Γ(1−ν)xν−1− ∞ ∑ k=0 (−1)kxk (1−ν+k)k!,ν∈R\N,x∈R\{0}. (3.17) The terms of the series expansion at the origin decrease for |x|<1, and in practice the best performance is observed in this region, where fast convergence is experimented. The series expansion is alternating and hence the computation of such a sum leads to catastrophic cancellation issues for x>1, especially in finite precision arithmetic. For x<0, νnot being a negative integer, the result is complex. The principal branch of the generalized exponential integral is defined by taking the principal branch of the natural logarithm in exp((ν−1)log(x)) = xν−1(with the logarithm branch cut (−∞, 0)). Along the negative real axis, the cancellation errors on the power series are removed, although the required number of terms increases due to slower convergence. For its evaluation, the series is truncated after a level of precision 2−p(pnumber of bits) is obtained, therefore it can be written as follows, Eν(x) = Γ(1−ν)xν−1−N−1 ∑ k=0 (−x)k (1−ν+k)k!+ ∞ ∑ k=N (−x)k (1−ν+k)k!. (3.18) For x>0, Equation (3.17) is an alternating series and thus the remainder is easily bounded by the first neglected term, therefore we choose Nsuch that xN/(|1−ν+N|N!)<2−p. For small values of x, the first neglected term tends rapidly to 0 as k→∞. However, the required number of terms can grow considerably when x>1, leading to initial ascending terms before the series starts to show convergence, which originates a loss of digits due to roundoff errors. Series in terms of the confluent hypergeometric function As previously stated, the generalized exponential integral can be defined in terms of the confluent hypergeometric function of the first kind, 1F1(a;b;x), Eν(x) = Γ(1−ν)xν−1+1F1(1−ν;2 −ν;−x) ν−1, (3.19) where 1F1(a;b;z)is defined as 1F1(a;b;z) = ∞ ∑ k=0 (a)kzk (b)kk!(3.20) for a∈C,b∈C\Z− 0and z∈C. Series (3.19) is equivalent to series (3.17), note that (1−ν)k/(2−ν)k= (1−ν)/(1−ν+k). In order to reduce significant cancellation issues, we apply Kummer’s transformation 1F1(a;b;z) = ez 1F1(b−a;b;−z), thus Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 40 Equation (3.19) can be written in this form, see [43, §8.19.11] Eν(x) = Γ(1−ν)xν−1+e−x ν−11F1(1;2 −ν;x) =Γ(1−ν)xν−1+e−x ν−1 ∞ ∑ k=0 xk (2−ν)k . (3.21) This series expansion turns out to be more numerically stable, especially for small values of ν, (for ν<2 all the terms of the expansion are positive), but the convergence is slightly slower. Similarly to the previous series representation, the number of terms diminish for |x|<1. A rigorous error bound for the evaluation of convergent generalized hypergeometric series pFq(a1, . . . , ap;b1, . . . , bq;z)in devised in [90]. Expansion (3.21) can be effectively used as an asymptotic expansion for large ν and fixed x. In fact, note that when νxthe term Γ(1−ν)xν−1is not significant compared to the terms in the finite sum and it can be neglected when less than νterms are used. When ν=n,nbeing a large integer, and not many terms are considered, we can neglect the contribution of Γ(1−ν)xν−1because it should be combined with the k=n−1 term, which gives the term shown in series expansion (3.39). Laguerre series A globally convergent Laguerre series for the incomplete gamma function Γ(a,x) is described in [77] Γ(a,x) = xa−1e−x ∞ ∑ k=0 (1−a)k (k+1)!L−a k(−x)L−a k+1(−x), (3.22) where L−a k(−x)is a generalized Laguerre polynomial. The region of validity of the Laguerre series is outside the zeros of Laguerre polynomials. Zeros of La k(x)occur in the interval x∈(0,4κ)where κ=n+1 2(a+1), so for our region of interest (x>0 and a=1−ν)L−a k(−x)lies in the monotonic region. As remarked in [13], the Laguerre series for (3.22) is closely related to the continued fraction for the incomplete gamma function; see §3.3.2 for a comparison to several continued fractions. Applying the functional relation (3.4) in (3.22) we obtain the Laguerre series for Eν(x), Eν(x) = e−x ∞ ∑ k=0 (ν)k (k+1)!L(ν−1) k(−x)L(ν−1) k+1(−x). (3.23) This series has two properties that make it very suitable for our regime of parameters: it does not exhibit cancellations and the error can be made arbitrarily small by increasing the number of terms (in contrast to asymptotic expansions, which have an optimal value). The generalized Laguerre polynomials satisfy the three-term recurrence relation L(ν−1) k+1(−x) = x+2k+ν k+1L(ν−1) k(−x)−k+ν−1 k+1L(ν−1) k−1(−x), (3.24) Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 41 which is not ill-conditioned in both backward and forward direction, consequently it is used with initial values L(ν−1) 0(−x) = 1 and L(ν−1) 1(−x) = x+ν. Moreover, given the reduced number of terms needed, the loss of precision is almost negligible. In [13] a sub-exponential error bound valid for non-negative real xis given for L−a k(−x), L(−a) k(−x)∼Sk(a,x)1+O1 m1/2 , (3.25) where m=k+1 and the sub-exponential1term Sk(a,x)is Sk(a,x) = e−x/2e2√mx 2√πx1/4−a/2m1/4+a/2 . (3.26) This asymptotic estimate results to be particularly effective for large n. For moderate and large values of νand/or xin a “medium-precision" range2the Laguerre series converges after a small number of terms and thus the error term of the subexponential estimate is significant. We now proceed to calculate approximations for the coefficients of the Laguerre series define as Eν(x) = e−x ∞ ∑ k=0 ak, and ak=(ν)k (k+1)!L(ν−1) k(−x)L(ν−1) k+1(−x). (3.27) For k≥1, √2πkk+1/2e−k≤k!≤ekk+1/2e−k, and given (ν)k=Γ(ν+k)/Γ(ν)the following inequality [97, Theorem 1] holds for Γ(b)/Γ(a)and b>a>1, bb−1 aa−1ea−b<Γ(b) Γ(a)<bb−1/2 aa−1/2 ea−b, (3.28) so (ν)k/(k+1)! satisfy (ν)k (k+1)!<Ck(ν,x) = ν 2π(ν+k)1/2 (ν+k)ν+kek+1 νν(k+1)k+3/2 . (3.29) For xνwe shall use the relation Lν−1 k(−x) = (−1)k k!U(−k,ν,−x)and the property U(a,b,z)∼z−a,z→∞,|ph z|<3 2π, therefore L(ν−1) k(−x)∼Bk(x) = (x)k k!,x→∞. (3.30) Combining (3.29) and (3.30) the coefficients aksatisfy ak≈aB k=Ck(ν,x) Bk(x)Bk+1(x). (3.31) 1In [13], sub-exponential growth is defined as loglog|f(n)| ∼ δlog n, for some 0 <δ<1. 2We consider medium-precision the range from double precision to up to a few hundred bits of precision. Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 42 When kis small and x.ν, a first order approximation [13, §1.3] is given by L(ν−1) k(−x)≈Ak(ν,x) = k+ν−1 k1+x νk . (3.32) Again, combining (3.29) and (3.32) we obtain the following approximation for ak ak≈aA k=Ck(ν,x) Ak(x)Ak+1(x). (3.33) Note that approximation Ak(ν,x)indicates that for small values of x,ak∼ k!/(ν)k+1and the rate of convergence is generally slow, depending entirely on ν. Therefore, if νis not sufficiently large, the method is not fast enough for efficient numerical evaluation. Table 3.1 shows the first neglected term aN<2−53 and the corresponding values for aA Nand aB N. Observe that approximation aA Nacts as an upper bound for large ν, whereas tends to overestimate aNfor smaller values. Nevertheless, one could easily devise a heuristic in order to compensate that overestimation by adding qextra bits such that aN<2−p−q,q<p. For large x,aB Nbounds aNadequately, but is too conservative when ν>x. νx N aNaA NaB N 10 10 17 2.84e−17 3.48e−19 3.99e+00 100 10 10 2.9e−17 2.15e−16 5.66e+06 10 100 6 4.14e−18 3.67e−19 2.63e−17 100 100 7 1.32e−17 1.18e−17 6.26e−13 500 500 5 3.69e−18 3.69e−18 7.94e−15 500 100 6 8.28e−18 8.94e−17 1.17e−07 100 500 5 3.38e−19 2.89e−19 2.75e−18 10000 10 4 2.38e−19 2.44e−19 2.44e+08 10 10000 2 2.19e−18 1.55e−18 2.26e−18 TABLE 3.1: Approximation terms aN. In practice, these approximations along with double-precision arithmetic are used to select Nusing linear search or by inverting these approximations in function of N. This approach is particularly useful in arbitrary-precision interval arithmetic. Taylor series for 1≤x<2 As previously stated, the series expansions for x>1 exhibit cancellation issues, therefore other methods need to be used, especially if the working precision cannot be increased to compensate the bad condition number of the series. Henceforth we fix the working precision at 53-bit. For values of xsuch that x∈[1, 2), we consider the following Taylor series described in [24] Eν(x−y) = ∞ ∑ k=0 yk k!Eν−k(x),x>0, (ν,y)∈R, (3.34) Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 43 which is obtained from the Taylor series [24, (10)] Eν(x−y) = ∞ ∑ k=0 (−y)k k!dk dxkEν−k(x), making use of the following differential formula [24, (11)] dk dxkEν(x) = (−1)kEν−k(x). The Taylor series truncated at k=Nis given by Eν(x−y) = N−1 ∑ k=0 yk k!Eν−k(x) + ∞ ∑ k=N yk k!Eν−k(x). (3.35) Proposition 3.2.1 Given ν≥1, x >0and positive integer N, such that bν+x−1c> N, the remainder of the Taylor series in (3.35) for |y| ≤ 1satisfies ∞ ∑ k=N yk k!Eν−k(x)<4e−xbν+x−1c x|y|N N!. (3.36) Proof: Starting with the integral definition (3.2), it immediately results that the generalized exponential integrals is monotonic increasing as ν→ −∞, satisfying the inequality Eν(x)>Eν+1(x). This implies that Er(x)≤E0(x) = e−x x,r∈[0, ∞). With the assumption bν+x−1c>Nand using the well-known upper bound for the generalized exponential integral in this domain, the following inequality holds Eν−k(x)≤e−x ν+x−k−1<e−x x. Hence, ∞ ∑ k=N yk k!Eν−k(x)<bν+x−1ce−x x ∞ ∑ k=N yk k!. Thus it remains to bound the series expansion. By observing that ∑∞ k=Nyk/k! is equivalent to the remainder term after truncating the Taylor series of ey, we can use the well-known upper bound for |y| ≤ 1 ∞ ∑ k=N yk k!≤4yN N!. Finally, combining both bounds the upper bound for the remainder is obtained.  By using bound (3.36) we can determine the required number of terms Nin order to target a level of precision 2−53. For x→1 and y→ −1, N=20 terms suffice, meaning that ν&21; see Figure (3.1) (left). This constraint demands the use of recurrence relations for smaller values of ν. For example, we can use the following recursion after increasing νtaking care of possible cancellation issues for Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 44 ν>1. Eν−n(x) = (1−ν)n xnEν(x) + e−xn−1 ∑ k=0 xk (1−ν)k+1,n∈N. (3.37) Furthermore, by using recursion (3.37), this method can be applied for ν<0. Regarding the finite series in (3.37), for ν−n>0 the minimum value occurs for k∼ν; see Figure (3.1) (right). In order to evaluate Eν−k(x)we make use of the 5 10 15 20 10−20 10−18 10−16 10−14 10−12 10−10 10−8 10−6 10−4 10−2 100 102 |rN−r| |rN−r|/r 4bν+x−1ce−x|y|N xN! 5 10 15 20 25 30 35 40 10−24 10−22 10−20 10−18 10−16 10−14 10−12 10−10 10−8 10−6 10−4 10−2 |xk/(1 −ν)k+1| FIGURE 3.1: Plot of the absolute and relative errors of E21.05(1.98) and error bound (3.36) for N∈[1,20](left). Plot of |xk/(1− 21.05)k+1|,x=2 for k= [1,40](right). recurrence relation [43, §8.19.12] Eν(x) = 1 x(e−x−νEν+1(x)). (3.38) Hence, we just need to compute the first Eν(x)(k=0), in N1terms, and for x→1 and ν≈21 we require N2=18. Thus, when x−y≈2, this algorithm would require N1+N2+N3terms, where N3is the number of recursions in (3.37). For implementation purposes, a simple choice x=−y= (x−y)/2 works well, although an iterative procedure could optimize3these parameters. Series expansions: special cases Previous series expansions, excepting Laguerre series, cannot be used for integer ν. For this special case we introduce two series expansions, see [43, §8.19]: Case: n∈N En(x) = (−x)n−1 (n−1)!(ψ0(n)−log(x)) − ∞ ∑ k=0, k6=n−1 (−x)k k!(1−n+k), (3.39) where ψ0(t)is the digamma function, which for integer t=nis denoted as ψ0(n) = −γ+ n−1 ∑ k=1 1 k=−γ+Hn−1, 3The optimal choice arises as a solution of a non-convex mix integer nonlinear programming problem, which is prohibitively expensive to compute. Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 45 where γis the Euler-Mascheroni constant and Hnis a harmonic number. Alike the series expansions (3.17) and (3.21), this series performs better for x<1. Other series expansion in terms of the exponential integral E1(x)(also known as Theis well function) is given by En(x) = (−x)n−1 (n−1)!E1(x) + e−x (n−1)! n−2 ∑ k=0 (n−k−2)!(−x)k =(−x)n−1 (n−1)!E1(x) + e−xn−2 ∑ k=0 (n)−k−1(−x)k. (3.40) Case: n+1 2,n∈N En+1 2(x) = (−1)n√πxn−1 2 (1/2)n erfc(√π)−e−xn−1 ∑ k=0 xk (1/2 −n)k+1. (3.41) This series expansion for half-integers is used for moderate values of nand small x in order to reduce the effect of cancellation. Case: n+e,n∈N:A difficult case arises when ν=n+e,|e|  1, for small values of x, say x.2. A direct evaluation of series expansion (3.17) leads to significant loss of precision both in the series expansion and Γ(1−n−e)xn−1+e. Moreover, final subtraction of both terms incurs in catastrophic cancellation, since both are of large magnitude. To deal with this issue, series expansion (3.17) is also implemented in quadruple precision (128-bit) using the libquadmath4library. Our implementation includes two interfaces: expint(const int vi, const double vf, const double x) and expint(const double v, const double x), where vi and vf (|vf|<0.5) denote the integral and decimal fractional part of ν, respectively. A unique interface passing ν=n+eproduces a similar loss of precision, even splitting νusing functions such as std::modf in C++. Two relevant examples using a double precision (53-bit) implementation: ν=2+1e−14 and x=1e−10 returns a result with relative error 1.6e-12, whereas ν=1−1e−13 and x=1e−01 has a relative error 6.5e-06. An implementation in quadruple precision returns an relative error below 2−53. In terms of performance, quadruple precision is about 10 ∼15 times slower. Although other approaches are possible, in our experience, quadruple precision is indispensable to return reliable results in this regime of parameters. 4There seems to be a bug in libquadmath for tgammaq and lgammaq. It returns incorrect signs when e<1e −6. This was fixed in our implementation. Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 46 3.2.3 Asymptotic expansions Large xand fixed ν Asymptotic expansions for Eν(x)as x→∞can be derived from the integral representation in Equation (3.2) Eν(x) = xν−1Z∞ xe−tt−νdt =e−xZ∞ 0e−xt(1+t)−νdt. (3.42) The transformation gives a Laplace integral and Watson’s lemma [165] can be applied, obtaining the following asymptotic expansion Eν(x)∼e−x ∞ ∑ k=0 (−1)k(ν)k xk+1,x∈R. (3.43) The remainder εN(x)of the expansion after truncation can be written as follows, Eν(x) = e−x N−1 ∑ k=0 (−1)k(ν)k xk+1+εN(x)!. (3.44) For x>0, the asymptotic series is alternating, and as previously stated, the remainder can be bounded by the absolute value of the first neglected term, |εN(x)| ≤  (ν)N xN+1. (3.45) As pointed out in §3.2.2, in asymptotic expansions the remainder cannot be reduced arbitrarily as N→∞, in fact, given νand x, bound (3.45) first decreases until an optimal value of terms Nmax =dx−νeis reached. Subsequent N>Nmax increase the bound. Thus, linear search is performed up to a limit N≤Nmax, without guarantee of finding Nsuch that εN(x)<2−p. Hence, when x(x>1)is not large enough with respect to νand the required precision bits is moderate/high, this asymptotic expansion cannot be used effectively. For an exponentially-improved asymptotic expansion see [43, §2.11(iii)]. Large ν A uniform asymptotic expansion when both νand xare large is introduced in [58]. Using the definition in [43, §8.20(ii)], the expansion is given by Eν(x)∼e−x x+ν ∞ ∑ k=0 Ak(λ) (λ+1)2kνk, (3.46) where λ=x/ν. The coefficients Ak(λ), starting with A0(λ) = 1, can be computed using the recursion Ak+1(λ) = (1−2kλ)Ak(λ) + λ(λ+1)dAk(λ) dλ,k=0,1,2, . . . (3.47) Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 47 and the degree of Ak(λ)is k−1 when k≥1. In particular, the first 8 coefficients are A0(λ) = 1, A1(λ) = 1, A2(λ) = 1−2λ, A3(λ) = 1−8λ+6λ2, A4(λ) = 1−22λ+58λ2−24λ3, A5(λ) = 1−52λ+328λ2−444λ3+120λ4, A6(λ) = 1−114λ+1452λ2−4400λ3+3708λ4−720λ5, A7(λ) = 1−240λ+5610λ2−32120λ3+58140λ4−33984λ5+5040λ6. Remark 3.2.2 It is not hard to observe that polynomials Ak+1(λ)computed via recursion in (3.47) can be obtained for k ≥2using the series Ak+1(λ) = 1+ k−1 ∑ j=1 (aj+bj−1+bj−2kaj−1)λj+ (bk−1−2kak−1)λk,k≥2 where a0=1, b0=0and a1=b1=−2. ajare the coefficients of each polynomial Ak(λ) and bjare the coefficients of their corresponding derivatives. Given the relation bj=jaj, the above series can be simplified Ak+1(λ) = 1+ k−1 ∑ j=1{aj(j+1) + (j−1−2k)aj−1}λj+{(k−1−2)kak−1}λk,k≥2 (3.48) Remark 3.2.3 Ak(λ)is an Eulerian polynomial of second kind defined by Ak(λ) = k ∑ m=0 (−1)mk mλm, (3.49) where DDk mEEare second-order Eulerian numbers5, defined by the recursion equation k m= (m+1)k−1 m+ (2k−m−1)k−1 m−1, (3.50) with DDk 0EE=1and DDk mEE=0for m ≥k. The remainder after truncating the series εk(ν,x)satisfies εk(ν,x)≤Ck1+1 x+ν−11 νk. (3.51) Gautschi in [58] provides rigorous bounds for εk(ν,x),k≤7. This uniform asymptotic expansion proves to be very powerful in a wide domain, λ∈[0, ∞). However, each term Ak(λ)requires the construction of a polynomial and its evaluation, 5https://oeis.org/A008517 Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 54 free transformations and double-double numbers, for difficult regions prone to numerical instability, thus diminishing the effect of round off errors. This approach is particularly intended for the evaluation of series expansions, where cancellation errors in the regime x∈[1, 1.5)occur. A double-double (DD) number is a multiple-term representation in which a number is expressed as the unevaluated sum of two standard floating-point (FP) numbers. The DD number is capable of representing at least 106-bit of significant, roughly 31 digits of accuracy and is, therefore, similar to IEEE 754 quadrupleprecision. A reference library using this approach is Bailey’s library10 QD [79]. There are several reasons for using DD numbers instead of quadruple-precision (e.g., using libquadmath included in GCC): operations with DD numbers use highly optimized hardware implementation of floating-point operations, and quadrupleprecision is still not available for all compilers and programming languages, which would limit the implementation of the algorithm. An error free transformation (EFT) is an algorithm which transforms any arithmetic operation of two FP numbers aand binto a sum of two FP numbers sand t, a floating-point approximation and an exact error term, respectively. Therefore, these algorithms keep track of all accumulated rounding errors, avoiding the lost of information. The basic brick for our implementation is Algorithm 3. This algorithm requires Algorithm 1 [99], which computes the exact sum of two FP numbers and returns the result under sand t. It requires 6 native FP operations (flops). Algorithm 1 Error-free transformation of the sum of two floating-point numbers. Input: a,b Output: s,t 1: function TWOSUM(a,b) 2: s←RN(a+b).RN: Rounding to nearest mode. 3: c←RN(s−a) 4: t←RN(RN(a−RN(s−c)) + RN(b−c)) 5: end function Furthermore, it also uses Algorithm 2 [42], requiring 3 flops. This algorithm is applicable when the exponent of ais larger or equal to that of b. Algorithm 2 Error-free transformation of the sum of two floating-point numbers (|a|≥|b|). Input: a,b Output: s,t 1: function FASTTWOSUM(a,b) 2: s←RN(a+b) 3: z←RN(s−a) 4: t←RN(b−z) 5: end function Algorithm 3 computes the exact sum of a DD number and a FP number, storing the resulting operation into the DD number, performing an operation in-place. This 10The operations implemented in this library are not compliant with the IEEE 754-2008 standard. Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 55 algorithm is used to accumulate the intermediate summation of terms in series expansions (3.17), (3.21) and (3.39) and for the final subtraction or addition operation. Although the use of EFTs for every single operation would definitely enhance the accuracy of the algorithm, we aim to provide a good balance between achievable accuracy and computational time, so that our implementation is competitive with other software packages only using FP operations. Other alternatives to reduce cancellations consist of grouping two consecutive terms in descending order, so the subtraction of the second term does not produce cancellation. However, given the satisfactory results obtained with EFTs, we discarded those methods. Algorithm 3 Addition of a double-double number and a double number in-place. Input: sh,sl,a Output: sh,sl 1: function ADD_DD_D_IP(sh,sl,a) 2: (th,tl)←TWOSUM(sh,a) 3: tl ←RN(th +tl) 4: (sh,sl)←FASTTWOSUM(th,tl) 5: end function Finally, our algorithm uses some mathematical functions from the standard library defined in <cmath>, for instance tgamma and lgamma, which compute the gamma function and the natural logarithm of the absolute value of the gamma function, respectively. 3.4.1 Algorithm for integer order The algorithm of integer order ν≡n,n∈Ncombines asymptotic expansions, Laguerre series, series expansions and Chebyshev approximations. Laguerre series is the dominant method for x>2 and it is used as a backup method wherever asymptotic expansions are not applicable. For small xseries expansions are employed, since they show faster convergence and return more accurate results than Laguerre series. For the special case n=1 we use the Chebyshev approximations in [30], which require fewer terms and provide more accurate results for moderate values of x. Note that we avoid the evaluation of Ei(−x)in the vicinity of x0≈ −0.372507, which corresponds to a single zero. Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 56 Algorithm 4 Algorithm for En(x),n∈Nand x>0 Input: n∈N,x∈R Output: En(x) 1: if n== 1and x∈(0.9,10)then 2: compute E1(x) = −Ei(−x)using Chebyshev approximations [30] 3: else if x≤1.5 and n<20 then 4: series expansion (3.39) 5: else if x≤2.0 and n≤10 then 6: series expansion (3.40) .Faster than Laguerre series 7: else if n≥xthen 8: if x<5then 9: check if asymptotic expansion (3.56) can be used, otherwise Laguerre series (3.23) 10: end if 11: Laguerre series (3.23) .Backup method 12: else 13: if x/ν>100 then 14: check if asymptotic expansion (3.44) can be used, otherwise Laguerre series (3.23) 15: end if 16: Laguerre series (3.23) .Backup method 17: end if 3.4.2 Algorithm for real order The algorithm for real order differs on the computational methods applied for small x. The alternating series (3.17) converges faster and it is used for large ν/xand as a backup method. Series (3.21) is used when the value νguarantees that all terms of the expansion are positive. Finally, Laguerre series (3.23) is employed in regions where results returned by series expansions are not sufficiently accurate. 3.5 Benchmarks Publicly available implementations of the generalized exponential integral in doubleprecision arithmetic are Cephes [111], Boost [11] and GNU Scientific Library (GSL) [56]. These libraries provide implementations for the special case ν≡n,n∈N. To our knowledge, there are no numerical libraries in double-precision arithmetic implementing Eν(x)for real values of ν. We compare our implementation to the aforementioned software for νinteger and to mpmath [92] and Arb [87], both supporting arbitrary-precision arithmetic, for real ν. To compare our implementation to other software packages we use performance profiles. Performance profiles [44] are widely used tools for benchmarking and evaluating the performance of several solvers, particularly in the fields of optimization and linear algebra, when run on a large test set. Performance profiles provide a convenient procedure of assessing the performance of a code relative to the best code of the set. Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 57 Algorithm 5 Algorithm for Eν(x),ν∈R+and x>0 Input: ν∈R+,x>0 Output: Eν(x) 1: if x≤1and x<20 then 2: if ν/x>10 then 3: series expansion (3.17) .Fast convergence 4: end if 5: if ν>1.5 and x>0.5 then 6: Laguerre series (3.23) .Slow but more accurate 7: else if ν<0.9 then 8: series expansion (3.21) .All terms of expansion are positive 9: else 10: series expansion (3.17) .Backup method 11: end if 12: else if ν≥xthen 13: if x<5then 14: check if asymptotic expansion (3.56) can be used, otherwise Laguerre series (3.23) 15: end if 16: Laguerre series (3.23) .Backup method 17: else 18: if x/ν>100 then 19: check if asymptotic expansion (3.44) can be used, otherwise Laguerre series (3.23) 20: end if 21: Laguerre series (3.23) .Backup method 22: end if Regarding the other codes, Cephes and Boost use similar algorithms, both use continued fractions as a main method and the power series for small x. In addition, Cephes includes the uniform asymptotic expansion in (3.46) for n>5000. The implementation in GSL is purely based on the applications of the functional relation with the incomplete gamma function (3.4). As shown in Figure 3.2 and Table 3.6, this simplistic approach in double-precision has several limitations, especially for large n, as the number of failures indicate. Figure 3.2 compares all four codes in terms of the relative error using as a reference the value computed by mpmath with 1000 digits of precision. If relevant discrepancies arise using different levels of precision, we use the result from Arb or Mathematica, which tend to be more reliable. The test samples are generated non-uniformly, in fact we select certain input values around regions of transition between computational methods, in order to test the worst cases. Figure 3.3 shows a comparison in terms of computation time. All measurements were obtained by evaluating each test sample 100 times are returning the average time. Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 58 012345678 Time ratios: log2( ratio ) 0.0 0.2 0.4 0.6 0.8 1.0 Ratio of problems Paper Cephes Boost GSL FIGURE 3.2: Accuracy profiles case n∈Nand x>0. 012345678 Time ratios: log2( ratio ) 0.0 0.2 0.4 0.6 0.8 1.0 Ratio of problems Paper Cephes Boost GSL FIGURE 3.3: Performance profiles case n∈Nand x>0. Observing the performance profiles and the statistics in Table 3.6, it seems safe to claim that our algorithm outperforms the other available codes. In terms of computation time, Boost comes very close in median, however, for some large values of nthe computation time is ridiculously high. Cephes does not include an asymptotic expansion for large n<5000, so cases where nis large and x<1 require the computation of nterms, being prohibitively expensive. Nevertheless, Cephes implements a more effective computation scheme than Boost, the former being possibly improved by replacing the S-fraction by the J-fraction, as shown in Section 3. Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 59 Library Max. error Avg. error Avg. time (µs) Stdev. time (µs) fails Paper 9.7e−16 1.3e−16 0.25 0.21 0/200 Cephes 1.4e−15 2.0e−16 0.73 2.47 0/200 Boost-1.61.0 4.8e−15 3.3e−16 63.76 558.36 0/200 GSL-2.2.1 5.2e−14 6.1e−15 1.34 1.19 75/200 TABLE 3.6: Error statistics for each library. gcc-5.4.0 compiler running Cygwin. Time in microseconds. Fails: returns Incorrect/- NaN/Inf. Intel(R) Core(TM) i5-3317 CPU at 1.70GHz. For real order νwe have generated two sample sets with the following characteristics: •Large set: ν∈[0.0, 10000]and x∈[10−9, 1000] •Small set: ν∈[0.04,70]and x∈[0.00075, 1.5] The large set was generated to test the accuracy of asymptotic expansions and Laguerre series, whereas the small set is testing the region in xwhere a loss of significant digits is expected. As shown in Table 3.7, the maximum relative error determines that about 5 bits of precision might be lost. These results suggest that the computation in this region could be improved by re-implementing both series expansions using DD operations, at the cost of worsening the computation time. Library Max. error Avg. error Avg. time (µs) Stdev. time (µs) fails Large set 9.8e−16 1.1e−16 0.14 0.10 0/1500 Small set 3.1e−15 1.7e−16 0.52 0.37 0/500 TABLE 3.7: Error statistics for each library. gcc-5.4.0 compiler running Cygwin. Time in microseconds. Fails: returns Incorrect/- NaN/Inf. Intel(R) Core(TM) i5-3317 CPU at 1.70GHz. 3.5.1 Arbitrary-precision floating-point libraries We evaluate the implementation of the generalized exponential integral in the arbitraryprecision packages Arb 2.8 and mpmath 0.19. Test were run on an Intel(R) Core(TM) i7-6700HQ CPU at 2.60GHz. For testing Arb we use Sage 7.3. Both software packages implement the generalized exponential integral using the functional relation with the incomplete gamma function, which is implemented using the series expansion of the confluent hypergeometric function for small xand the asymptotic expansion of the U-Kummer function for large x, for more details refer to [90]. Table 3.8 summarizes the results obtained by mpmath for all three test sets using 53-bit of precision. Mpmath automatically chooses guard bits to achieve the requested accuracy, however it is usually unable to return a correct results for large parameters. Additionally, mpmath doest not return a flag indicating that the result is incorrect. Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 60 Set Max. error Avg. error Avg. time (µs) Stdev. time (µs) fails Integer 1.0 4.4e−13 125 243 5/200 Large real 1.2e+163 2.2e−15 16397 128024 75/1500 Small real 0.0 0.0 672 187 0/500 TABLE 3.8: Error statistics mpmath library. Average error is computed after excluding relative errors ≥1e−10. A result is considered wrong if relative error is >1e−14. Arb uses interval arithmetic and efficiently tracks errors. The usage of the functional relation works reasonably well in most of the cases, but as shown below for large parameters one needs to increase the working precision considerably to obtain a solution with 16 significant digits. For example, evaluating E500.25(400)at 53, 1000 and 1210 bits with Arb produces: sage: CBF = ComplexBallField(53) sage: CBF(400).exp_integral_e(CBF(500+1/4)) nan + nan*I sage: CBF = ComplexBallField(1000) sage: CBF(400).exp_integral_e(CBF(500+1/4)) [+/- 5.05e-130] sage: CBF = ComplexBallField(1210) sage: CBF(400).exp_integral_e(CBF(500+1/4)) [2.128687916150507e-177 +/- 6.64e-194] sage: %timeit CBF(400).exp_integral_e(CBF(500+1/4)) 1000 loops, best of 3: 1.15 ms per loop Hence, it is necessary to systematically increase the precision in order to obtain results at the desired accuracy. On the other hand, our implementation uses the Laguerre series in this domain reporting fast convergence (5 terms), see below: In [1]: import expint In [2]: expint.expint_v(500+1/4,400) Out[2]: 2.128687916150507e-177 In [3]: %timeit expint.expint_v(500+1/4,400) 1000000 loops, best of 3: 475 ns per loop Finally, we encourage the use of more sophisticated computation scheme and addition of specific numerical methods for the computation of the generalized exponential integral in arbitrary-precision arithmetic. 3.6 Conclusions In this work, we proposed an efficient algorithm for the computation of the generalized exponential integral. The algorithm includes a new asymptotic expansion for large order νand other methods not implemented in existing software. Numerical experiments confirmed the benefits of using internal higher precision arithmetic for Chapter 3. Fast and Accurate Algorithm for the Generalized Exponential Integral for positive real order 61 regions where numerical instability appears, thus obtaining more reliable results. This resulted in an implementation capable of outperforming available software packages in terms of accuracy and computation time. We believe the improvements and suggested numerical methods in this work should be considered for inclusion in arbitrary-precision arithmetic software packages, which in general implement simplistic computation schema and rely on continuously increasing the working precision to obtain a solution satisfying the user’s precision. Finally, our implementation in C++ was made freely available. 62 Chapter 4 Confluent Hypergeometric Functions 4.1 Background and Previous Work Confluent hypergeometric functions (also known in the literature as Kummer functions) and Gauss hypergeometric function compound a set of general functions covering a majority portion of the most commonly used special functions. Even though this chapter is focused on confluent hypergeometric functions of the first kind 1F1and the confluent hypergeometric function of the second kind or Kummer U-function U, we consider instructive to provide a minimum background on the generalized hypergeometric function. The generalized hypergeometric function of order (p,q),pand qbeing nonnegative integers representing the number of numerator and denominator parameters, respectively, is usually represented as pFq(a1, . . . , ap;b1, . . . , bq;z) = ∞ ∑ k=0 (a1)k···(ap)k (b1)k···(bq)k zk k!, (4.1) where (a)kis the Pochhammer symbol or rising factorial, ai,∀i∈ {1, . . . , p}and bi,∀i∈ {1, . . . , q}are the parameters and zis called the argument. The generalized hypergeometric function is given by a hypergeometric function. A hypergeometric function defined as F(z) = ∑∞ k=0ckzk, is a power series for which coefficients cksatisfy a first-order recurrence relation, ck+1=P(k) Q(k)ck, where the ratio of polynomials P(k)and Q(k)form a rational function of k. For numerical computation reasons when bjis close to a non-positive integer, it is sometimes preferable to use the regularized generalized hypergeometric function given by p˜ Fq(a1, . . . , ap;b1, . . . , bq;z) = pFq(a1, . . . , ap;b1, . . . , bq;z) Γ(b1)···Γ(bq). For certain values of aiand bitwo important cases are considered: if any ai∈ Z− 0, the series terminates and the generalized hypergeometric function is a polynomial in z. On the other hand, if any bj∈Z− 0, the series is undefined due to zero denominator, except if ai>bj. The radius of convergence of the series (4.1) is described by three cases. 1. Case p≤q: the series converges for all finite values of zand defines an entire function. This is the case for confluent hypergeometric functions 0F1, called confluent hypergeometric limit function, and 1F1. Chapter 4. Confluent Hypergeometric Functions 63 2. Case p=q+1: For ai/∈Z− 0,∀i∈ {1, . . . , p}, the series has a radius of 1 for |z|<1 and is defined by analytic continuation with respect to zelsewhere. 3. Case p>q+1: the series diverges for all nonzero values of z, except when values of the parameters satisfy some of the aforementioned terminating conditions. The function 2F0, which is equivalent to Uis the most used hypergeometric function of this kind. Several infinite power series and partial sums can be written as generalized hypergeometric functions by inspection of the ratios of consecutive terms. There is a large number of identities in terms of pFqfor large orders (p,q)[43, §16.4]. In the field of discrete mathematics, the generalized hypergeometric function arise in many combinatorial identities and random graph theory [84]. 4.1.1 Confluent hypergeometric function of the first and second kind The confluent hypergeometric function of the first kind M(a,b,z) = 1F1(a;b;z) arises as one of the solutions of the limiting form of the hypergeometric differential equation zd2w dz2+ (b−z)dw dz −aw =0, (4.2) for b/∈Z− 0, see [43, §13.2]. 1F1(a;b;z)is entire in zand aand is a meromorphic function of b, however, its regularized form Γ(b)1˜ F1(a;b;z) = 1F1(a;b;z)is entire in bsince its limiting form is well defined lim b→−m 1F1(a;b;z) Γ(b)=(a)m+1zm+1 (m+1)!1F1(a+m+1; m+2; z). Another standard solution is the confluent hypergeometric function of the second kind (also called Kummer U-function or Tricomi confluent hypergeometric function, indistinctly) U(a,b,z), which is defined by the property U(a,b,z)∼z−a,z→ ∞,|ph z| ≤ (3/2)π−δwhere δis an arbitrary small positive constant such that 0<δ1. For certain regimes of the parameters, these functions are expressible as polynomials in z. In particular, when a∈Z− 0,U(a,b,z)is a polynomial of degree m U(−m,b,z) = (−1)m(b)m1F1(−m,b,z) = (−1)mm ∑ k=0m k(b+k)m−k(−z)k. Similarly, when a−b+1∈Z− 0, U(a,a+m+1, z) = (−1)m(1−a−m)mz−a−m1F1(−m,1 −a−m,z). For 1F1the previous polynomials can be used after application of connection formulas as shown later on. However, we mention a few terminating series in terms of the lower incomplete gamma function, see http://functions.wolfram.com/07. 20.03.0106.01 1F1(a;a+m;z) = Γ(a+m)(−z)−a Γ(a)Γ(m) m ∑ k=0m−1 kγ(a+k,−z)z−k,m∈N+, Chapter 4. Confluent Hypergeometric Functions 70 HypergeometricU and Hypergeometric2F1 compute 0F1,1F1,Uand 2F1as well. •Maple (C) [109]: This software provides the function hypergeom to compute a floating-point approximate value of pFq and Hypergeom to evaluate pFq symbolically. To the author’s knowledge/experience Arb and Mathematica are generally faster and more reliable than mpmath, Matlab or Maple. Matlab is observed to be significantly slower than other software libraries. Finally, we note that Arb and Mathematica are chosen for benchmarking throughout this work. 4.1.3 Applications In this section, we mention several applications where hypergeometric functions are encountered. A complete and up to date survey of their applications would hardly be achievable. Therefore, we aim to introduce applications that might be less well-known or that are of interest on current relevant research topics. Other specific applications, related to numerical methods developed in subsequent sections, will be discussed further on. Special functions. There are many special functions appearing in engineering, physics and mathematics which are particular cases of the hypergeometric function. The following list presents the most common derived cases of confluent hypergeometric functions and Gauss hypergeometric function. •Confluent hypergeometric functions: –Elementary functions. –Exponential, logarithmic and trigonometric integrals. –Error functions, Faddeeva function, Fresnel integrals and Dawson’s and Goodwin-Staton integral. –Incomplete gamma functions and generalized exponential integral. –Airy and Scorer functions. –Bessel, Kelvin, Struve and Lommel functions. –Parabolic cylinder functions. –Whittaker functions. –Hermite and generalized Laguerre orthogonal polynomials. •Gauss hypergeometric function: –Incomplete beta functions. –Chebyshev, Gegenbauer, Jacobi and Legendre orthogonal polynomials. –Spherical and spheroidal harmonics. –Complete elliptic integrals. Chapter 4. Confluent Hypergeometric Functions 71 Physics. Confluent hypergeometric functions, their special cases and especially the closely related Whittaker functions are ubiquitous in physics. They appear in the study of potentials in quantum mechanics, the solution of eigenvalue problems, dynamics of many-body systems and relativistic cosmology to mention a few. As recent application, we note that confluent hypergeometric functions are often used to describe first passage of Ornstein-Ulhenbeck processes [70]. It is worthwhile to mention that the confluent hypergeometric function 1F1is used for the solution of time-dependent Schrödinger equation for an atom in the laser field, where fast multi-evaluation over a grid is required during simulation processes3. Other cases of the hypergeometric function such as 3F2arise in considering coupled angular momenta in two quantum systems, where Wigner 3 j-symbols are used [141]. Last, single variable hypergeometric functions pFqarise in applications in quantum and statistical physics and chemistry as described in [31]. Mathematics. In particular, Gauss hypergeometric function 2F1arises in several applications in number theory; complete elliptic integrals of the first and second kind are expressible in terms of 2F1,K(k) = π/22F1(1/2, 1/2; 1; k2)and E(k) = π/2 2F1(−1/2, 1/2; 1; k2), respectively. Furthermore 2F1is used to compute the inverse of the j-invariant in parametrization of elliptic curves over C. Additionally, the hypergeometric function arise as matrix coefficients of representations of Lie groups. We mention the connection between hypergeometric functions and algebraic equations, for example the roots of the general quintic equation are expressible in terms of 4F3, which can be found in [98]. Combinatoric interpretations of the hypergeometric function and general hypergeometric sums, together with computational aspects about their identification, are studied in depth in the already classic book [134]. Finally, an extensive survey of classic applications of basic hypergeometric functions to partitions, number theory, finite vector spaces and combinatorial identities is presented in [4]. Statistics. The hypergeometric function and several special cases are regularly encountered in statistical applications. Numerous probability distribution functions (PDF) and cumulative distribution functions (CDF) of discrete and continuous distributions are expressible in terms of the hypergeometric function. A few examples are: 1. Hyperbolic distribution: probability distribution function in terms of the modified Bessel function of the second kind, F(x;α,β,δ,µ) = pα2−β2 2αδK1(δpα2−β2)e−α√δ2+(x−µ)2+β(x−µ),(α,β,δ,µ)∈R4, 3Personal communication from Professor Liangyou Peng. http://www.phy.pku.edu.cn/ ~lypeng/. Chapter 4. Confluent Hypergeometric Functions 72 where the modified Bessel function K1(z)is expressible in terms of the Kummer U-function as follows K1(z) = 2z√πe−zU3 2,3,2z. 2. Hypergeometric distribution: cumulative distribution function in terms of hypergeometric function 3F2given by F(k;N,K,n) = 1−(n k+1)( N−n K−k−1) (N K)3F2(1, A,B;C,D;1), (4.15) where (k,N,K,n)∈N4and A=k+1−K,B=k+1−n,C=k+2, D=N+k+2−K−n. 3. Non-central Student’s t-distribution: probability distribution function is expressed in terms of the confluent hypergeometric function 1F1as follows f(x;ν,µ) = νν/2Γ(ν+1)e−µ2/2 2ν(ν+x2)ν/2Γ(ν/2)√2µx1F1(ν/2 +1; 3/2; γ) (ν+x2)Γ((ν+1)/2) +1F1((ν+1)/2;1/2; γ) √ν+x2Γ(ν/2 +1),ν∈R+,µ∈R, where γ=(µx)2 2(ν+x2). Other well-known statistical distributions such as the non-central Chi distribution or the Pearson type IV distribution have PDF and CDF expressible in terms of the incomplete gamma function, incomplete beta function and Marcum functions, see [157, §36 – 39] for references and further examples. Furthermore, several characteristic functions and moment generating functions might be represented in terms of the hypergeometric function as detailed in the next section, where numerical methods for the computation of various characteristic functions are presented. Moreover, we refer to [138] for recent applications in the field of directional statistics in Machine Learning, where Von Mises-Fisher distribution and particular cases of the Kent distribution (also known as Fisher-Bingham distribution) in terms of the hypergeometric functions are considered. Despite the fact that matrix functions are not studied in this work, we note that the hypergeometric function of a matrix argument have applications in multivariate statistical analysis, random matrix theory and wireless communications, see [100] for numerical aspects and experiments. The hypergeometric function occasionally arise in the computation of the total probability that a given distribution is greater than another distribution, which is required for evaluating A/B tests in a Bayesian context4, for instance. Another related problem is the computation of the accuracy ratio (AR) or Gini coefficient, which are widely used performance metrics in classification models, the latest being the standard metric to assess the performance of credit risk default models. The 4http://www.evanmiller.org/bayesian-ab-testing.html Chapter 4. Confluent Hypergeometric Functions 73 remaining of this section is devoted to the computation of the Gini coefficient for two well-known statistical distributions; the Beta and the Gumbel distribution. Let us introduce a standard definition of the Gini coefficient [151]: given two distribution X0and X1the Gini coefficient is defined as Gini =AR =|2Pr[X0<X1] + Pr[X0=X1]−1|=|Pr[X0<X1]−Pr[X0>X1]|, and considering the assumption that parameters of both distributions are different, Pr[X0=X1] = 0, we take the definition using the area under the ROC curve (AUC) given by Gini =AR =|2AUC −1|. (4.16) As previously stated, we will focus on the Beta distribution and the Gumbel distribution. Their respective probability density functions are given by fBeta(x;α,β) = xα−1(1−x)β−1 B(α,β),(α,β)∈R2 +, fGumbel(x;µ,β) = e−(x−µ)/β−e−(x−µ)/β β,µ∈R,β∈R+. Having introduced the main requirements, we proceed to present our contributions in the form of the following two theorems. Theorem 4.1.1 Given two standard Beta distributions X0∼Beta(α0,β0)and X1∼ Beta(α1,β1)such that (α0,β0,α1,β1)∈R4 +, the Gini or Accuracy Ratio (AR) between distributions is given by ARBeta =|2AUC −1|, (4.17) where AUC is the area under the ROC curve defined as AUC =B(α0+α1,β0) α1B(α0,β0)B(α1,β1)3F2(α1,α0+α1,1 −β1;1 +α1,α0+α1+β0;1). (4.18) Proof: Integrating the joint distribution, under the assumption of independence, over all values of X1>X0we obtain the following integral Pr[X1>X0] = Z1 0Z1 x0 xα0−1 0(1−x0)β0−1 B(α0,β0) xα1−1 1(1−x1)β1−1 B(α1,β1)dx1dx0 =1−Z1 0 xα0−1 0(1−x0)β0−1 B(α0,β0)Ix0(α1,β1)dx0, where Ix(a,b)is the regularized incomplete Beta function defined by Ix(a,b) = xa B(a,b) ∞ ∑ k=0 (1−b)k (a+k) xk k!,|x|<1. Let us focus on the above integral I. By formally interchanging integration and summation, which is justified by the absolute convergence of the hypergeometric Chapter 4. Confluent Hypergeometric Functions 74 series, we obtain I=Z1 0 xα0−1(1−x)β0−1xα1 B(α0,β0)B(α1,β1) ∞ ∑ k=0 (1−β1)k (α1+k) xk k!dx =1 B(α0,β0)B(α1,β1) ∞ ∑ k=0 (1−β1)k (α1+k)k!Z1 0xα0+α1+k−1(1−x)β0−1dx =Γ(β0) B(α0,β0)B(α1,β1) ∞ ∑ k=0 (1−β1)k (α1+k)k! Γ(α0+α1+k) Γ(α0+α1+β0+k). Finally, note that the resulting series is hypergeometric and expressible in terms of 3F2which yields ∞ ∑ k=0 (1−β1)k (α1+k)k! Γ(α0+α1+k) Γ(α0+α1+β0+k)=3F2(α1,α0+α1,1 −β1;1 +α1,α0+α1+β0;1) α1(α0+α1)β0 . Rearranging terms the proof is completed.  Note that the hypergeometric function in (4.18) is terminating for β1∈N, although is numerically unstable due to the amount of cancellation when adding large alternating terms. A stable convergent solution is given by applying the transformation in http://functions.wolfram.com/07.27.17.0035.01 yielding B(α0+α1,β0+β1) β0B(α0,β0)B(α1,β1)3F2(1, α0+β0,β0+β1;β0+1, α0+α1+β0+β1;1). (4.19) The hypergeometric function is reduced to ∞ ∑ k=0 (α0+β0)k(β0+β1)k (β0+1)k(α0+α1+β0+β1)k , where all terms are positive. For some combinations of parameters, this hypergeometric series is slowly convergent, therefore series acceleration techniques come into play. Finally, we can derive an asymptotic approximation for large parameters to estimate Pr[X1>X0]. First, notice the resemblance of expression (4.19) with the Hypergeometric distribution in (4.15). Matching parameters we have K=−α0,n=−β1,k=β0−1, N=α1−1. By the Law of Large Numbers we can approximate Pr[X1>X0]as the probability of Pr[X≤k],X∼Hypergeometric(K,N,n). Hence, µ=α0β1 α1−1,σ2=α0β1 α1−1α0+α1−1 α1−1α1β1−1 α1−2 and Pr[X1>X0]≈Φ    β0−1−α0β1 α1−1 rα0β1 α1−1α0+α1−1 α1−1α1β1−1 α1−2   , (4.20) Chapter 4. Confluent Hypergeometric Functions 75 where Φ(x)is the cumulative normal distribution function. Table 4.1 shows the relative error of the asymptotic estimate for several parameters of the Beta distribution. We observe the effectiveness of the asymptotic estimate as α0,β0,α1,β1→∞, exhibiting a linear decay rate. α0β0α1β1rel. error 50 70 100 120 4e-2 500 700 1000 1200 3e-3 5000 7000 100 160 3e-2 300 610 20000 40000 2e-2 3000 6100 20000 40000 3e-3 10000 20100 20000 40000 4e-3 100000 201000 200000 400000 9e-5 TABLE 4.1: Relative errors of the asymptotic estimate for Pr[X1> X0]for large parameters of two Beta distributions. Theorem 4.1.2 Given two Gumbel distributions defined as X0∼Gumbel(µ0,β0)and X1∼Gumbel(µ1,β1)such that (µ0,µ1)∈R2and (β0,β1)∈R2 +, the Gini or Accuracy Ratio (AR) between distributions is given by ARGumbel =|2AUC −1|, (4.21) where AUC is the area under the ROC curve defined as AUC = ∞ ∑ k=0 (−1)kΓ(Ak +1) k!eBk ,A=β0 β1and B=(µ0−µ1) β1, where |A|<1. Proof: Following the steps presented previously, we compute the integral Igiven by I=1 β0Z∞ −∞e−(x−µ0) β0−e−(x−µ0) β0e−e−(x−µ1) β1dx . After performing the change of variable z= (x−µ0)/β0→dz β0=dx we get I=Z∞ −∞e−ze−e−ze−e−(zA+B)dz, where A=β0/β1and B= (µ0−µ1)/β1. Unfortunately, this integral does not seem to have a closed-form for arbitrary values of Aand B, therefore we easily compute a series expansion by expanding the third exponential function in the integrand as follows e−e−(zA+B)= ∞ ∑ k=0 (−1)k(e−(zA+B))k k!, Chapter 4. Confluent Hypergeometric Functions 76 and plugging the resulting series expansion into the integral I=Z∞ −∞e−e−ze−z ∞ ∑ k=0 (−1)ke−z(Ak+1) k!e−Bk dz, = ∞ ∑ k=0 (−1)k k!e−Bk Z∞ −∞e−e−ze−z(Ak+1)dz = ∞ ∑ k=0 (−1)kΓ(Ak +1) k!eBk . Note that the series expansion is convergent for |A|<1.  A simple observation of the Gumbel case shows that given the absolute value in the calculation of the Gini coefficient, we can interchange distributions X0and X1when A≥1, satisfying ARGumbel A=β0 β1,B=(µ0−µ1) β1=ARGumbel A=β1 β0,B=(µ1−µ0) β0 Finally, it is possible to obtain a closed-form expression for ARGumbel for fractional values of Aand B, expressing the series expansion as a combination of hypergeometric functions. For example A=1/3 and B=2 yields ARGumbel =1F21; 1 3,2 3;−1 27e6−2π 3 1 3 √3e2Bi 1 3 √3e2, where Bi(z)is one of the standard solutions of the Airy’s equation [43, §9], expressible in terms of 0F1. Chapter 4. Confluent Hypergeometric Functions 77 4.2 On the Computation of Confluent Hypergeometric Functions for Large Imaginary Part of Parameters b and z 4.2.1 Introduction Many different methods have been devised for evaluating the confluent hypergeometric function of the first and second kind, 1F1(a;b;z)and U(a,b,z)respectively. In this work we are mainly interested in numerical methods involving some of their integral representations for complex values of the parameters and argument. As mentioned in previous sections of this Chapter, the basic approach for computing the confluent hypergeometric functions is based on the combination of power series and asymptotic series expansions. In addition, the Kummer’s transformations are applied for cases where the parameters are not valid for some methods, or when the regime of parameters causes numerical instability. In particular, as noted in [90], the Kummer’s transformation (4.3) is used to compute 1F1for <(z)<0, so that the worst-case cancellation occurs around the oscillatory region z=iy, y∈R. Besides the described disadvantages commonly occurring by using series expansions, numerical integration methods based on polynomial interpolation or Gaussian quadrature for large complex parameters also suffer severe difficulties to return accurate values. In order to compensate the inaccuracies in the presence of large oscillations, these methods require a prohibited number of quadrature points, consequently being computationally inefficient. Therefore, specific analytic and numerical methods are required to potentially diminish these difficulties. The most relevant analytic method to handle this problem is the so-called method of stationary phase. The method of stationary phase [157, §14] is an analytic approach to handle high oscillatory integrals commonly encountered in the form of Fourier-type integrals, F(ω) = Rb af(t)eiωg(t)dt; more details in subsequent sections. The principle of the method establishes that the main contributions to the asymptotic expansion of the integral are located in the vicinity of the critical points: stationary points in interval [a,b], the finite endpoints aand band singular points of the integrand. An application of the method to the confluent hypergeometric function 1F1for pure imaginary argument zwas derived by Erdélyi in 1955, see [157, §14.6], 1F1(a;a+b;iω)∼Γ(a+b) Γ(a)eiω ∞ ∑ k=0 e−1 2πi(k+b)(b)k(1−a)k k!ωk+b +Γ(a+b) Γ(b)eiω ∞ ∑ k=0 e1 2πi(k+a)(a)k(1−b)k k!ωk+a,ω→+∞, where <(a)>0 and <(b)>0. We note that these type of asymptotic expansions are generally divergent when ωis not sufficiently large. Therefore, one must switch to alternative methods such as numerical integration for fixed values of ω or whenever high-precision results are needed. In the last two decades, substantial progress has been accomplished in numerical quadratures methods for highly oscillatory integrals. Most of these methods use, as a building block, analytic tools like the method of stationary phase just mentioned or the steepest descent method hereafter described. Some of these methods Chapter 4. Confluent Hypergeometric Functions 78 are: the Filon-type method [83], the Levin method [105], numerical steepest descent [82] and complex-valued Gaussian distribution [40]. Other recent numerical integration methods, conceptually different, are based on exploitation of the trapezoidal rule properties after performing effective variable transformations; see [127,126]. Finally, we consider a recent proposed method applied to the evaluation of confluent hypergeometric function 1F1described in [132]. The numerical quadrature technique is described in [131] and given by Z1 −1f(x)eiωxdx ≈ N ∑ k=1 ik−1(2k−1)rπ 2ωJk−1 2(ω) N ∑ j=1 wj−1Pk−1(xj−1)f(xj−1), where Jk(z)is the Bessel function of the first kind, Pk(x)are the Legendre polynomials and wkand xkare the weights and nodes for Gauss quadrature. The method is directly applicable to the integral transformation (4.14) Z1 −1ez(t/2+1/2)(1−t)b−a−1ta−1dt =ez/2 Z1 −1e<(z)t/2(1−t)b−a−1ta−1ei=(z)t/2 dt . In this work we present an efficient algorithm for the computation of the confluent hypergeometric functions when the imaginary part of the parameter bor argument zis large. The outline of the Section is the following: we briefly review the theory behind the steepest descent method and present the integral representations for four particular cases. Then, we discuss different numerical quadrature schemes amenable for the resulting integrals. After that, we perform numerical examples and a benchmarking against available software. Then, we present several applications where this method is applicable. Finally, some remarks and prospective enhancements to the presented method are given. 4.2.2 Algorithm The presented method for the computation of the confluent hypergeometric functions is based on the application of suitable transformations to highly oscillatory integrals and posterior numerical evaluation by means of quadrature methods. Some direct methods for 1F1(a;b;iz)can be applied for moderate values of |=(z)|, however a more general approach is the use of the numerical steepest descent method, which turns out to be very effective for the regime of parameters of interest. First, we briefly explain the path of steepest descent. Subsequently, we introduce the steepest descent integrals for those cases where |=(b)|,|=(z)| → ∞. Path of steepest descent For this work we consider the ideal case for analytic integrand with no stationary points. We follow closely the theory developed in [82]. Let us consider the oscillatory integral I=Zβ αf(x)eiωg(x)dx (4.22) Chapter 4. Confluent Hypergeometric Functions 79 where f(x)and g(x)are smooth functions. By applying the steepest descent method, the interval of integration is substituted by a union of contours on the complex plane, such that along these contours the integrand is non-oscillatory and exponentially decaying. Given a point x∈[α,β], we define the path of steepest descent hx(p), parametrized by p∈[0, ∞), such that the real part of the phase function g(x)remains constant along the path. This is achieved by solving the equation g(hx(p)) = g(x) + ip. If g(x)is easily invertible, then hx(p) = g−1(g(x) + ip), otherwise root-finding methods are employed, see [82, §5.2]. Along this path of steepest descent, integral (4.22) is transformed to I[f;hx] = eiωg(x)Z∞ 0f(hx(p))h0x(p)e−ωpdp =eiωg(x) ωZ∞ 0fhxq ωh0xq ωe−qdq (4.23) and I=I[f;hα]−I[f;hβ]with both integrals well behaved. In the cases where β=∞, this parametrization gives I=I[f;hα]−0. A particular case of interest is when g(x) = x. Then the path of steepest descent can be taken as hx(p) = x+ip, and along this path (4.22) is written as Zβ αf(x)eiωxdx =ieiωα ωZ∞ 0fα+iq ωe−qdq −ieiωβ ωZ∞ 0fβ+iq ωe−qdq . (4.24) Case U(a,b,z),=(z)→∞ Integral representation (4.13) can be transformed into a highly oscillatory integral U(a,b,z) = 1 Γ(a)Z∞ 0e−<(z)tta−1(1+t)b−a−1e−i=(z)tdt . (4.25) Although the integral transformation is not in standard form of the oscillatory integral, one can amend it after application of the mirror symmetry property U(a,b,z) = U(a,b,z)valid when z/∈(−∞,0). Taking g(t) = t,g0(t) = 16=0 and there are no stationary points. Therefore, in this case we only have one endpoint and the steepest descent integral obtained by (4.24) is reduced to a single line integral, U(a,b,z) = i ωΓ(a)Z∞ 0e−<(z)iq ωiq ωa−11+iq ωb−a−1e−qdq, (4.26) where ω=−=(z). Case U(a,b,z),=(b)→∞ In this case, the path of integration is modified to avoid the singularity at t=0, as can be observed after performing the transformation to a highly oscillatory integral, U(a,b,z) = 1 Γ(a)Z∞ 0e−ztta−1(1+t)b−a−1dt =ez Γ(a)Z∞ 1e−zt(t−1)a−1t<(b)−a−1ei=(b)log(t)dt . (4.27) Chapter 4. Confluent Hypergeometric Functions 86 4.3 High-precision Computation of the Confluent Hypergeometric Functions via Franklin-Friedman Expansion 4.3.1 Introduction The current standard method of evaluation of many special functions to highprecision consists of employing the ascending series for small argument z, i.e. the direct series expansion at z=0, combined with the usage of an asymptotic expansion for large values of the argument z. It is well known that the behaviour of asymptotic series of Poincaré type for large |z|is characterized by having initial terms that decrease in magnitude until a minimum is attained, also known as optimal truncation, and thereafter subsequent terms start to increase. This limitation on the achievable accuracy forces a switch from the asymptotic series to the ascending series depending on the desired level of precision. However, the evaluation of ascending series for large zrequires to increase the working precision in order to compensate the large amount of cancellation, which in turn increases the computational cost. Normally, the scheme of computation implemented in high-precision software is a relatively simplistic choice between the ascending series and the asymptotic series based on the magnitude of the argument zand the desired level of precision or other heuristics that generally exclude other parameters involved. This type of scheme, although asymptotically valid, may lead to incorrect results in the vicinity of the transition region. Alternative computational methods have been devised to complement the described dichotomy between series expansion and asymptotic expansion. These methods, such as exponentially-improved expansions [124] or their extension called hyperasymptotic expansions [123], are focused on extending the region of validity of the asymptotic series by iteratively re-expanding the remainder terms at optimal truncation into another asymptotic series, each exponentially smaller than its predecessor. This procedure increases the attainable accuracy of the asymptotic expansion at the expense of the computational cost of evaluating substantial complicated terms at each level of the hyperasymptotic expansion. A remarkable method to obtain geometrically convergent series for the evaluation of special functions consists of using variants of Hadamard series, which have been extensively investigated by R. B. Paris, for example in [129]. These series involving the normalized incomplete gamma function exhibit a rapid decay after the optimal truncation term, being comparable with the behaviour of the first terms of the asymptotic expansion. A similar geometrically convergent series for the evaluation of Bessel functions was developed by D. Borwein, J. Borwein and O. Chan in [12] through the evaluation of the so-called “exp-arc" integrals. On the other hand, it is essential to mention the role played by uniform asymptotic expansions to obtain powerful expansions valid for extended regimes of the parameters. We shall remark the so-called vanishing saddle point method developed by N. M. Temme in [155,156]. This method is applicable to Laplace-type integrals of the form Fλ(z) = 1 Γ(λ)Z∞ 0tλ−1e−zt f(t)dt, (4.43) Chapter 4. Confluent Hypergeometric Functions 87 with <(λ)>0 and zlarge, in which λmay also be large. Essentially, this method expands the amplitude function f(t)at t=µ,µ=λ/z≥0 being a uniformity parameter corresponding to the saddle point of the dominant part of the integral (4.43). In this work, we revisit the theory originally developed by J. Franklin and B. Friedman in [55], which henceforth we shall call Franklin-Friedman expansions. Their method was developed with the aim to overcome the disadvantages of the direct application of Watson’s lemma to Laplace-type integrals [157, §2]. Historically, this method has not received significant attention, presumably due to the inherent difficulty of evaluating the coefficients of the expansion. We shall show, through the study of an important amplitude function occurring in many integral representations of special functions, how the coefficients of the Franklin-Friedman expansion can be efficiently evaluated, resulting in a convergent method capable of out-performing aforementioned methods. The rest of the Section is outlined as follows. First, we briefly revisit the theory corresponding to the Franklin-Friedman expansion and we show an illustrative example. Then we compute the coefficients for the amplitude function corresponding to the confluent hypergeometric function and we provide an analysis of the obtained coefficients. Subsequently, we present an effective recursive algorithm for the computation of the coefficients and we provide numerical calculations and compare the present method with the conventional ascending-asymptotic series and previously discussed convergent and uniform asymptotic expansions. Finally, we discuss possible enhancements and present our conclusions. 4.3.2 The Franklin-Friedman expansion J. Franklin and B. Friedman developed in [55] a method for obtaining convergent asymptotic representations for Laplace-type integrals of the form Fλ(z) = 1 Γ(λ)Z∞ 0tλ−1e−zt f(t)dt,<(z)>0, <(λ)>0, (4.44) for large values of zwith suitable assumptions on the amplitude function f(t). This method is based on the application of a type of interpolation process to the function f(t), differing from Watson’s lemma, in which the amplitude function is expanded in a power series at t=0 and integrated term by term. The first interpolation point t0=λ/zcorresponds to the saddle point of the dominant part tλe−zt, and by substituting in (4.44) we obtain Fλ(z) = f(t0)z−λ+1 Γ(λ)Z∞ 0tλ−1e−zt(f(t)−f(t0)) dt . (4.45) After integrating by parts we obtain Fλ(z) = f(t0)z−λ+1 zΓ(λ)Z∞ 0tλe−zt f1(t)dt, (4.46) Chapter 4. Confluent Hypergeometric Functions 88 where the new amplitude function f1(t)is defined by f1(t) = d dt f(t)−f(t0) t−t0. (4.47) One can observe that integral (4.46) has the same form as the integral (4.44), with λreplaced by λ+1 and fby f1. The interpolation point for the next iteration is t1= (λ+1)/z. This process can be continued iteratively obtaining the following series expansion Fλ(z) = n−1 ∑ k=0 fk(tk)(λ)k zλ+2k+1 znΓ(λ)Z∞ 0tλ+n−1e−zt fn(t)dt, (4.48) where n=0, 1, 2, . . ., f0(t) = f(t)and fk+1(t) = d dt fk(t)−fk(tk) t−tk ,tk=λ+k z,k=0, 1,2, . . . . (4.49) Sufficient conditions on the amplitude function f(t)for the convergent behaviour of the series expansion are stated in the following two theorems. We refer to [55] for proofs. Theorem 4.3.1 (J. Franklin and B. Friedman [55]) Take λ=α+iβ, where αis real and positive and βis real. For β6=0, suppose that f (t)is analytic for <(t)>0and that f∈C2n[0, ∞), such that the derivatives satisfy |f(m)(t)| ≤ Meµt,m=0, 1, . . . ,2n, where M and µare non-negative constants. Under these conditions, expansion (4.48) has an asymptotic behaviour as z →∞, with remainder term of order O(z−2n−λ). If λ=α, the assumption that f (t)is analytic for <(t)>0may be replaced by the assumption that f∈C2n[0, ∞)for t >0. Therefore, the series expansion is convergent. Theorem 4.3.2 (J. Franklin and B. Friedman [55]) Suppose f (q) = f(x+iy)can be represented in the form f(q) = Z∞ 0e−qt dΨ(t),x>0, where Ψ(t)is a complex-value function which is of bounded variation in each finite interval t∈[0, T]and which satisfies the inequality |Ψ(t)| ≤ M,t≥0. Then for z >0and <(λ)>0, series expansion (4.48) converges to (4.44). In [157, §17.4], Temme gives the first five coefficients fk(tk)for the incomplete gamma function ezΓ(1−λ,z) = 1 Γ(λ)R∞ 0tλ−1e−zt(1+t)−1dt, amplitude function Chapter 4. Confluent Hypergeometric Functions 89 f(t) = (1+t)−1, by using computer algebra f0=z ζ,f1=z3 ζ(ζ+1)2,f2=z5(3ζ+4) ζ(ζ+1)2(ζ+2)3, f3=z7(15ζ3+90ζ2+175ζ+108) ζ(ζ+1)2(ζ+2)3(ζ+3)4, f4=z9(105ζ6+1680ζ5+11025ζ4+37870ζ3+71540ζ2+70120ζ+27648) ζ(ζ+1)2(ζ+2)3(ζ+3)4(ζ+4)5, (4.50) where ζ=z+λ. Despite the relative ease of computing the coefficients by means of computer algebra systems, it is usually difficult to obtain explicit representations such that these become usable for numerical evaluation purposes. In practice, one generates a few coefficients of the expansions for a bounded domain of the parameters and incorporate them into a routine, this procedure being solely valid for fixed precision. 4.3.3 The expansion for U(a,b,z) The confluent hypergeometric function of the first kind 1F1(a;b;z)and the Kummer function U(a,b,z)arise as linearly independent solutions of the Kummer’s differential equation [43, §13.2] zd2w dz2+ (b−z)dw dz −aw =0, (4.51) for b/∈Z−∪{0}. Confluent hypergeometric functions appear in a wide range of applications in mathematical physics and applied mathematics. Many special functions are expressible in terms of specific forms of the confluent hypergeometric functions such as, for example, Bessel functions, incomplete Gamma functions and Laguerre polynomials amongst others. A convenient starting point for U(a,b,z)is the integral representation [157, §10.1.5] U(a,b,z) = 1 Γ(a)Z∞ 0ta−1e−zt(1+t)b−a−1dt, (4.52) valid for <(a)>0 and <(z)>0. Laplace-type integral (4.13) includes the amplitude function f(t) = (1+t)b−a−1, which we shall investigate further on. An asymptotic expansion valid for |z| → ∞can be derived by application of Watson’s lemma to the integral representation (4.13). We obtain [43, §13.7.3] U(a,b,z)∼z−a ∞ ∑ k=0 (−1)k(a)k(a−b+1)k k!zk,|ph z| ≤ 3 2π−δ, (4.53) where δis an arbitrary small positive constant such that 0 <δ1 and (a)k=a(a+ 1)···(a+k−1)denotes a rising factorial or Pochhammer symbol. For <(z)>0, asymptotic series (4.53) is alternating and thus the remainder is bounded by the absolute value of the first neglected term. As previously discussed, the remainder cannot be reduced arbitrarily, hence when zis not sufficiently large with respect to Chapter 4. Confluent Hypergeometric Functions 90 aand b(not made rigorous here) and the required precision bits is moderate, this expansion cannot be used effectively. Evaluation of U(a,b,z)outside the sector |ph z|<1 2πcan be achieved by use of the continuation formula [157, §10.1.11] e−zU(a,b,z) = e∓πiaΓ(b−a) Γ(b)1F1(b−a;b;−z) −e∓πibΓ(b−a) Γ(a)U(b−a,b,ze∓πi), (4.54) where 1F1(a;b;z)is an entire function with series expansion given by [157, §10.1.2] 1F1(a;b;z) = ∞ ∑ k=0 (a)k (b)kk!zk. (4.55) To compute the Kummer function U(a,b,z)for small values of z, the usual approach is to employ connection formulas for this function in terms of 1F1(a;b;z), for example [157, §10.1.12] U(a,b,z) = Γ(1−b) Γ(a−b+1)1F1(a;b;z) + Γ(b−1) Γ(a)z1−b1F1(a−b+1;2 −b;z), (4.56) which is not defined for integer values of b, although the limit exists for b→0. Additionally, a recent method for computing the Kummer function U(a,b,z)for small values of |a|,|b|and |z|is described in [63]. 4.3.4 The Franklin-Friedman expansion coefficients We compute the coefficients of the Franklin-Friedman expansion for the amplitude function f(t)=(1+t)b−a−1appearing in the Laplace-type integral for U(a,b,z) in (4.13). We start computing a few coefficients fkin expansion (4.48) using Mathematica 10 [169] and employing the Expand and FullSimplify options to perform algebraic simplifications and transformations. We only show the first two coefficients since their size grows considerably with k f0= (1+a/z)b−a−1and f1=z3(a+z z)b−a a+z−(1+a+z z)b−a(2+2a−b+z) (1+a+z)2. Note that above coefficients coincide with those in (4.50) when λ=a=b. Unfortunately, Mathematica was unable to produce more simplified expressions of fk. Hereinafter, we proceed to generate tractable explicit representations of the coefficients fk. Let us first define the coefficients Aq s:= (1+ (a+s)/z)q. Subsequently, we factorize the previously obtained coefficients and rearrange terms such that coefficients Ab−a−i jappear in ascending order (i,j). The first four coefficients fkare Chapter 4. Confluent Hypergeometric Functions 91 now given by f0=Ab−a−1 0, f1= (Ab−a−2 1(b−a−1) + (Ab−a−1 0−Ab−a−1 1)z)z, f2=Ab−a−3 2(b−a−1)(b−a−2) + 2(Ab−a−2 1−Ab−a−2 2)(b−a−1)z + (Ab−a−1 0−2Ab−a−1 1+Ab−a−1 2)z2z2 2, f3=Ab−a−4 3(b−a−1)(b−a−2)(b−a−3) +3(b−a−1)(b−a−2)(Ab−a−3 2−Ab−a−3 3)z +3(b−a−1)(Ab−a−2 1−2Ab−a−2 2+Ab−a−2 3)z2 + (Ab−a−1 0−3Ab−a−1 1+3Ab−a−1 2−Ab−a−1 3)z3z3 6. We observe that the terms multiplying Ab−a−i jin fkcorrespond to rows of Pascal’s triangle, with alternating sign for the inner terms in (···)zk−j. Furthermore, a multiplicative factor zk/k! is present. After performing a few more algebraic manipulations we obtain the explicit representation of fkgiven by fk=ck(z)zk k!, (4.57) where ck(z) = k ∑ j=0k jzk−jdj k ∑ s=j (−1)s−jk−j k−sAb−a−1−j s,k=0, 1,2, . . . (4.58) and djis defined by dj=Γ(b−a) Γ(b−a−j)=(1, j=0 dj−1(b−a−j),j>0(4.59) We remark that equations (4.58)-(4.59) add the internal coefficients backwards. In order to calculate them forward, the coefficients ck(z)are written equivalently as ck(z) = k ∑ j=0k jzjlj j ∑ s=0 (−1)sj sAb−a−1−k+j k−j+s, (4.60) where lj=Γ(b−a) Γ(b−a+j−k)=(∏k i=1(b−a−i),j=0 lj−1 (b−a−k+j),j>0(4.61) Chapter 4. Confluent Hypergeometric Functions 92 Note that the previous double finite summation is over the triangle 0 ≤s≤j≤k. Furthermore, ck(z)can be written as ck(z) = zk−qk!k ∑ j=0q k−j1 j! j ∑ s=0 (−1)sj s1 (p+k−j+s)k−q−j, (4.62) where q=b−a−1 and p=z+a. We shall see that the explicit representation in (4.62) will lead to our main result (Theorem 4.3.5), where we prove that the following expression for U(a,b,z)holds U(a,b,z) = ∞ ∑ k=0 ck(z)(a)k k!za+k. (4.63) Analysis of the coefficients ck(z) In this subsection we examine the coefficients ck(z)defined in (4.62). Let us define the coefficients rj:=∑j s=0(−1)s(j s)(p+k−j+s)q+j−kcorresponding to the inner summation in (4.62). These coefficients are defined by the binomial transform of the sequence {(p+k−j+s)q+j−k}s≥0, which can be represented by means of the Nörlund-Rice integrals [52]. In what follows, we proceed to derive asymptotic expansions and upper bounds for the coefficients ck(z). Let us consider the alternating binomial sum defined by F(z,N,m) = N ∑ k=0N k(−1)k1 (z+k)m. (4.64) In [32], Coffey calculates the alternating binomial sum (4.64) for (N,m)∈Nand z∈C\Z− 0. The main result of [32] is an analytic relation in terms of Bell polynomials with generalized harmonic number arguments. We present some of his results along with other relations that will be needed further on F(z,N,m) = 1 zmm+1Fm(z, . . . , z,−N;z+1, . . . , z+1;1)(4.65) =1 (m−1)!Z∞ 0tm−1e−zt(1−e−t)Ndt (4.66) where pFq(a1, . . . , ap;b1, . . . , bq;z)is the generalized hypergeometric function. The Stirling numbers of the second kind S(n,k)may be defined by the following generating function n ∑ k=1 S(n,k)(x−k+1)k=xn, (4.67) and S(n,k) = 0 for n<k. We introduce the following proposition for the coefficients ck(z). Chapter 4. Confluent Hypergeometric Functions 93 Proposition 4.3.3 Given a,b,z∈C,<(z)>0and j,k∈N, coefficients ck(z)in (4.62) can be represented by the following asymptotic expansion as (p+k)→∞ ck(z)∼zk−qk!k ∑ j=0q k−j(j+1) ∞ ∑ i=j+1 S(i,j+1)(k−q−j)i i!ζ(k−q−j+i,p+k+1). (4.68) Proof: We use the integral representation (4.66) for rj rj=1 Γ(k−q−j)Z∞ 0tk−q−j−1e−(p+k−j)t(1−e−t)jdt . (4.69) This Laplace-type integral is defined for <(k−q−j)>0, where a direct use of Watson’s lemma applies, see (4.72). Alternatively, note that this integral can be written as Z∞ 0tk−q−j−1e−(p+k−j)t(1−e−t)jdt =Z∞ 0tk−q−j−1e−(p+k+1)t(et−1)j+1 (1−e−t)dt . An asymptotic expansion for rjcan be obtained if we expand (et−1)j+1at t=0, which corresponds to the following generating function of the Stirling coefficients of the second kind (4.67) (et−1)j+1= (j+1)! ∞ ∑ i=j+1 S(i,j+1)ti i!, (4.70) and interchanging the previous summation and integration we obtain a divergent asymptotic series rj∼(j+1)! Γ(k−q−j) ∞ ∑ i=j+1 S(i,j+1) i!Z∞ 0tk−q−j+i−1e−(p+k+1)t (1−e−t)dt . (4.71) The resulting integral has an explicit representation in terms of the Hurwitz zeta function [43, §25.11]. Hence, replacing the integral by the Hurwitz zeta function and substituting the ratio of gamma functions by a Pochhammer symbol gives the result.  An equivalent asymptotic expansion representation for (p+k)→∞is obtained by application of Watson’s lemma to integral (4.69) rj∼j! Γ(k−q−j) ∞ ∑ i=j S(i,j) i! Γ(k−q−j+i) (p+k)i+k−q−1=j! ∞ ∑ i=j S(i,j) i! (k−q−j)i (p+k)i+k−q−1, (4.72) where the use of Pochhammer symbol permits the evaluation out of the domain <(k−q−j)>0. In [32] a similar asymptotic expansion restricted to k−q−j∈N is obtained after a change of variable and using the generating function for Stirling numbers of the first kind and solving the beta function. Remark 4.3.4 Interestingly, coefficients ck(z)have a remarkable property for (a,b)in a domain D:={(a,b)∈C2:b−a−1=n,n∈N}. For this particular case, U(a,b,z) Chapter 4. Confluent Hypergeometric Functions 94 reduces to a polynomial in z of degree n given by U(a,a+n+1, z) = z−an ∑ j=0n j(a)j zj. (4.73) We note, by expanding the double binomial sum in (4.62), that coefficients ck(z)vanish by symmetry for k >bn/2c. This implies that expansion (4.63) terminates in almost half of terms required by (4.73). We now prove the Franklin-Friedman expansion for U(a,b,z)in (4.63). Theorem 4.3.5 For (a,b,z)∈C3and <(z)>0the Franklin-Friedman expansion for the confluent hypergeometric function U(a,b,z)is given by U(a,b,z) = ∞ ∑ k=0 ck(z)(a)k k!za+k, (4.74) where ck(z) = k ∑ j=0k jzk−jΓ(b−a) Γ(b−a−j) k ∑ s=j (−1)s−jk−j k−sAb−a−1−j s(4.75) = k ∑ j=0k jzjΓ(b−a) Γ(b−a+j−k) j ∑ s=0 (−1)sj sAb−a−1−k+j k−j+s,k=0, 1,2, . . . , (4.76) and Aq s=1+a+s zq . (4.77) Proof: It follows from (4.66) that coefficients ck(z)can be written as ck(z) = k! zq−k k ∑ j=0q k−j1 j! j ∑ s=0 (−1)sj s1 (p+k−j+s)k−q−j =k! zq−k k ∑ j=0q k−j1 j!Γ(k−j−q)Z∞ 0tk−q−j−1e−(p+k−j)t(1−e−t)jdt, (4.78) where q=b−a−1 and p=z+awith the integral representation being valid for <(k−q−j)>0 and <(p+k−j)>0. Next, we rearrange U:=(q k−j)1 j!Γ(k−j−q), to obtain U=u(q,k,j)f(k,j), where f(k,j) = 1/(j!(k−j)!). The following identity is established for u(q,k,j) u(q,k,j) = Γ(q+1) Γ(q−k+j+1)Γ(k−j−q)=−Γ(q+1)sin(π(j−k+q)) π. (4.79) Chapter 4. Confluent Hypergeometric Functions 95 Now replacing (4.79) into (4.78) and by formally interchanging integration and summation we obtain the following integral representation for ck(z) ck(z) = −Γ(q+1)k! zq−kπZ∞ 0 k ∑ j=0 sin(π(j−k+q))ejt(1−e−t)j j!(k−j)!tj!tk−q−1e−(p+k)tdt =Γ(q+1)sin(π(k−q)) zq−kπZ∞ 0t−q−1e−(p+k)t(1−et+t)kdt, (4.80) valid for <(q)<0 and <(p)>0. Given the explicit integral representation of ck(z) in (4.80), the proof consists of developing the sum after replacing (4.80) into (4.74). Thus, we obtain after interchanging summation and integration ∞ ∑ k=0 ck(z)(a)k k!za+k=Γ(q+1) πza+qZ∞ 0 ∞ ∑ k=0 (a)ksin(π(k−q))(1−et+t)k ektk!!t−q−1e−pt dt . This interchange is justified since the series converges absolutely. Now we consider the following identity ∞ ∑ k=0 (a)ksin(π(k−q))(1−et+t)k ektk!=−sin(πq)eat (1+t)a. (4.81) Using (4.81), it follows that the Franklin-Friedman expansion in (4.74) is expressible in terms of the Laplace-type integral given by ∞ ∑ k=0 ck(z)(a)k k!za+k=−Γ(q+1)sin(πq) πza+qZ∞ 0 t−q−1e−(p−a)t (1+t)adt =−Γ(b−a)sin(π(b−a−1)) πzb−1Z∞ 0 ta−be−zt (1+t)adt . By observing that the resulting integral is indeed the integral representation of U(a,b,z)in (4.13) after application of Kummer’s transformation U(a,b,z) = z1−bU(1+a−b,2 −b,z), we obtain U(a,b,z) = −Γ(b−a)sin(π(b−a−1))z1−b πZ∞ 0 ta−be−zt (1+t)adt (4.82) =1 Γ(a)Z∞ 0ta−1e−zt(1+t)b−a−1dt, (4.83) and the proof of the theorem is completed.  Remark 4.3.6 A relation between contiguous coefficients can be obtained by performing integration by parts on (4.80), which yields ck+1(p,q;z) = z(ck(p,q;z)−ck(p+1, q;z)) + qck(p+1, q−1; z). (4.84) Despite the interest of the latter result, this recurrence is not the preferred choice to compute consecutive coefficients. An efficient method to compute a set of coefficients ck(z)is described in Section 4. Chapter 4. Confluent Hypergeometric Functions 102 (a,b,z)NAscending (4.56) Asymptotic (4.53) Vanishing (4.96) Expansion (4.63) 10 - 1e−04 6e−10 8e−20 30 - 1e−16 8e−26 1e−52 (30,81/4,300)50 - 1e−27 8e−39 3e−79 100 - 5e−48 6e−63 5e−131 200 1e−13 (N=1000)4e−68 3e−88 4e−202 10 - - 8e−04 6e−08 30 - - 3e−07 7e−20 (123/4,101/5,50)50 - - 7e−08 2e−28 100 - - - 4e−43 300 2e−48 - - 9e−71 10 - 1e−10 2e−11 8e−19 30 - 5e−15 4e−16 4e−32 (5/4,10/4,30)50 - 7e−13 3e−14 2e−39 100 6e−11 - - 4e−50 200 6e−80 - - 4e−61 10 - - - 7e−01 30 - - - 1e−04 (401/2,211/6,300)50 - - - 5e−11 100 - - - 6e−30 200 4e−53 (N=1600)- - 3e−66 TABLE 4.9: Comparison between various methods for U(a,b,z). Small and moderate values of parameters and argument. (a,b,z)NAsymptotic (4.53) Vanishing (4.96) Expansion (4.63) 10 - - - 30 - - - (−241/2,20,400)50 - - 2e−19 100 1e−11 3e−16 2e−170 200 1e−226 4e−138 2e−375 10 - - - 30 - - 3e−21 (−500/6, −21/6,300)50 - 9e−11 2e−87 100 9e−118 7e−78 9e−212 200 6e−225 1e−143 3e−334 TABLE 4.10: Comparison between various methods for U(a,b,z). Moderate negative parameters and argument. in their respective regions of validity and is remarkably useful to compute the confluent hypergeometric function for large parameters and argument, providing a clear advantage over direct computation using the ascending series. Furthermore, it is observed that for small argument the expansion developed converges at approximately geometric rate 2−N. However, for sufficiently small argument the ascending series still exhibits faster convergence. The presented approach results adequate in a “medium/high-precision" range, say 100 - 1000 digits, given the considerable computation complexity as the number of terms increases. Therefore, a complete arbitrary-precision implementation should combine the Franklin-Friedman expansion with other low-complexity methods described in this work. Finally, further work is needed to compute uniform bounds for the coefficients of the expansion in a wider regions of the parameters aand b, and to enhance the algorithm to accelerate the computation of coefficients via efficient parallelization. 103 Chapter 5 The Lerch Transcendent and Other Special Functions in Analytic Number Theory 5.1 Background 5.1.1 Special number and polynomials We introduce some basic properties of special numbers and polynomials essential in the field of analytic number theory and asymptotic expansions for special functions. Most of the section shall be devoted to the Bernoulli numbers and polynomials given their number of appearances throughout this work and their relevance in the field. The number of formulae relating special numbers and polynomials between each other is considerable and practically infeasible to cover in detail. Bernoulli numbers and polynomials The Bernoulli polynomials Bn(z), for n∈N0and z∈C, are defined by their exponential generating function (EGF) tezt et−1= ∞ ∑ n=0 Bn(z)tn n!,|t|<2π, (5.1) and the Bernoulli numbers Bnby Bn(0) = Bn. Some basic properties of Bernoulli numbers and polynomials are the following •Bernoulli numbers are rational numbers. Bnis defined for n∈ {0,1}and, n≥2 and neven, otherwise Bn=0. On the other hand, the even-indexed Bn alternate in sign, thus (−1)n+1B2n>0, n≥1. •The exact denominator of Bnis obtained by the Von Staudt-Clausen theorem. The sequence of the numerator and denominators of the rational Bnare detailed in [144, A027641] and [144, A027642], respectively. •Bernoulli polynomials are expressible in terms of Bernoulli numbers Bn(z) = n ∑ k=0n kBkzn−k. (5.2) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 104 •They satisfy the difference equation: Bn(z+1)−Bn(z) = nzn−1. •The derivative w.r.t. argument z:d dz Bn(z) = nBn−1(z). •Multiplicative formula is given by the finite series [136], Bn(mx) = mn−1m−1 ∑ k=0 Bnx+k m,m≥2 and meven. A generalization of Bernoulli polynomials denoted by B(µ) n(z)for complex order and argument, and integer degree is described in [157, §15.6]. The generalized Bernoulli polynomials, like previous particular cases, are defined by an exponential generating function given by [43, §24.16.1] tµezt (et−1)µ= ∞ ∑ n=0 B(µ) n(z)tn n!,|t|<2π. (5.3) Note that when µ=1, they reduce to the conventional Bernoulli polynomials and numbers B(1) n(z) = Bn(z)and B(1) n(0) = Bn. As previously stated, generalized Bernoulli polynomials can be computed recursively with the following formula B(µ) n(z) = n ∑ k=0n kB(µ) n−kzk=znn ∑ k=0n kB(µ) kz−k. (5.4) Therefore, these polynomials are expressible in terms of a finite sum of generalized Bernoulli numbers, also called Nörlund numbers, B(µ) n=B(µ) n(0). Nörlund numbers are, therefore, easily defined by the generating function [43, §24.16.9] t et−1µ = ∞ ∑ n=0 B(µ) n tn n!,|t|<2π. (5.5) Several methods have been developed to perform the efficient computation of many Bernoulli numbers. In what follows, we aim to summarize some common approaches implemented in arbitrary-precision software packages. An exhaustive chronology of earlier work with several references is included in [75]. The most widely used algorithm for computing a single Bnis based on the application of the relationship between Bnand the Riemann zeta function ζ(s), given by Bn= (−1)n/2+12ζ(n)n! (2π)n,n≥2 and neven. (5.6) A state-of-the-art parallel implementation is the software CalcBn V3.0 (C++ making use of the GMP library) https://www.bernoulli.org/. A faster method developed in [75] computes Bnmodulo pfor many small primes pand then reconstruct Bnvia the Chinese Remainder Theorem. This is the default algorithm in Sage [160] and was used to achieve a new record (2008), Bnfor n=108. On the other hand, the recurrent formula from Ramanujan’s congruences is the method of choice in mpmath [92] for n<3000, whereas the Riemann zeta function relationship is exploited for Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 105 larger values. Ramanujan congruences are n+3 nBn=     n+3 3−∑n/6 k=1(n+3 n−6k)Bn−6k, if n≡0(mod 6) n+3 3−∑(n−2)/6 k=1(n+3 n−6k)Bn−6k, if n≡2(mod 6) −n+3 3−∑(n−4)/6 k=1(n+3 n−6k)Bn−6k, if n≡4(mod 6) , (5.7) where a≡b(mod c) indicates that aand bare congruent modulo c, i.e. a−bis integrally divisible by c, thus (a−b)/c∈Z. The Arb library [87] implementation also exploits the relationship between Bn and the Riemann zeta function, but instead of using the Euler product for ζ(n), as in various aforementioned implementations, a reversing computation of the L-series to favour the recycling of powers is used. Finally, it is worth mentioning that most of the libraries systematically catch Bernoulli numbers for subsequent calculations, since the computation of a large number of Bnat high precision is time-consuming. The number of available methods of computation of Bernoulli polynomials and generalized Bernoulli polynomials is limited if compared with Bernoulli numbers. To the author knowledge the main methods implemented are based on the recurrences (5.2) and (5.4). However, this recurrence is numerically unstable if applied using floating-point arithmetic. Alternatively, Bn(z)are expressible in terms of the Hurwitz zeta function ζ(s,a)via the functional relation Bn(z) = −nζ(1−n,z). (5.8) Note that the Hurwitz zeta function generalizes the Bernoulli polynomials to n∈C. Furthermore, some explicit formulas have been developed such as Bn(x) = n ∑ k=0 1 k+1 k ∑ j=0 (−1)jk j(x+j)n, (5.9) which might also cause numerical instability due to the binomial alternating sum. Finally, for z∈[0, 1], the Fourier series in [43, §24.8] can be applied. For the generalized Bernoulli polynomials, extensions to complex z,µand n and uniform asymptotic expansion for large argument zand degree nare studied in [157, §15.6]. Explicit formulas for the generalized Bernoulli polynomials and Nörlund polynomials are studied in [148], these are respectively B(µ) n= n ∑ k=0 (−1)kµ+n n−kµ+k−1 kS(n+k,k) (n+k k), (5.10) where S(n,k)are Stirling numbers of the second kind, described later on, and B(µ) n(z) = n ∑ k=0n kµ+k−1 kk! (2k)! k ∑ j=0 (−1)jk jj2k(z+j)n−k ×2F1k−n,k−µ;2k+1; j z+j, (5.11) where 2F1is the Gauss hypergeometric function, see Chapter 4. Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 106 Euler numbers and polynomials Analogous to the generalized Bernoulli polynomials, the generalized Euler polynomials are defined by means of the exponential generating function [43, §24.16.2] 2µ (et+1)µezt = ∞ ∑ n=0 E(µ) n(z)tn n!,|t|<π. (5.12) The Euler polynomials are defined by En(z) = E(1) n(z), and the classical Euler numbers by En=2nEn(1/2), which leads to the generating function for Euler numbers given by sech(t) = 1 cosh(t)=2 et+e−t= ∞ ∑ n=0 En tn n!,|t|<π 2. (5.13) Euler polynomials satisfy the recurrence formula En(z) = n ∑ k=0n kEk (z−1/2)n−k 2k. (5.14) The even-indexed Euler numbers are expressible in terms of Bernoulli polynomials as follows E2n=−42n+1B2n+1(1/4) 2n+1, (5.15) and Euler polynomials are related to the Bernoulli polynomials by En−1(z) = 2 n(Bn(x)−2nBn(x/2)). (5.16) Finally, we refer to [34, §9] and [43, §24] for further properties. For uniform asymptotic expansion of the generalized Euler polynomials see [157, §15.7], which derivation follow the same steps as those of the generalized Bernoulli polynomials. Stirling numbers and polynomials The Stirling polynomials are defined by the exponential generating function t 1−e−tz+1 = ∞ ∑ n=0 Sn(z)tn n!,|t| ≤ 2π. (5.17) Note that Stirling polynomials represent a special case of the generalized Bernoulli polynomials in (5.3). This can be observed by rewriting (t/(1−e−t))z+1= (tet/(et− 1))z+1hence Sn(z) = B(z+1) n(z+1)follows. Stirling numbers of the first kind, denoted as s(n,m), are related to the Stirling polynomials by Sn(m) = (−1)n (m n)s(m+1, m+1−n). (5.18) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 107 The Stirling numbers of the second kind, denoted as S(n,m), are also related by Sn(−m) = (−1)n (n+m−1 m−1)S(n+m−1, m−1). (5.19) Given m,n∈Zand m≤n, both Stirling numbers share the following properties s(n,n) = S(n,n) = 1, n≥0 and s(n,0) = S(n, 0) = 0, n≥1, (5.20) and s(n,m) = S(n,m) = 0 if m>n. The Stirling numbers of the first kind, also known as ordinary or signed Stirling numbers of the first kind, represent the number of permutations of nelements with mdisjoint cycles. Several generating functions exist (t−n+1)n= n ∑ m=1 s(n,m)tm(5.21) (ln(t+1))m m!= ∞ ∑ n=m s(n,m)tn n!, (5.22) for t<1. These numbers satisfy the recurrence relation s(n,m) = s(n−1, m−1)−(n−1)s(n−1, m), 1 ≤m≤n, (5.23) and can be computed iteratively by means of the finite summation s(n,m) = n ∑ k=m nk−ms(n+1, k+1),m≥1. (5.24) The Stirling numbers of the second kind are non-negative integers representing the number of partitions of nelements into exactly mnon-empty subsets. These are defined by the generating functions tn= n ∑ m=1 S(n,m)(t−m+1)m(5.25) (et−1)m m!= ∞ ∑ n=m S(n,m)tn n!. (5.26) The Stirling numbers of the second kind have an explicit representation S(n,m) = 1 m! m ∑ k=0 (−1)m+km kkn. (5.27) Equivalently to the Stirling numbers of the first kind, they satisfy the recurrence relations S(n,m) = mS(n−1, m) + S(n−1, m−1)(5.28) S(n,m) = n ∑ k=m mn−kS(k−1, m−1). (5.29) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 108 Interestingly, the Stirling numbers are related to other special numbers; for example the Bernoulli numbers are expressible in terms of the Stirling numbers of the second kind as follows Bn= n ∑ k=0 (−1)kk!S(n,k) k+1= n ∑ k=0 (−1)kn+1 k+1S(n+k,k) (n+k n). (5.30) Although the general recurrence and direct summation is usually implemented in numerical libraries such as Sage [160], we mention that several methods for obtaining asymptotic expansion for large order nand uniform asymptotic expansions when n∼mfor both Stirling numbers are described in [157, §24]. Other special numbers and polynomials For completeness we give a non-exhaustive short overview of other combinatorial numbers and polynomials of interest in the field of number theory, some of them being used in various asymptotic formulas derived throughout this work. We start with some less-known list of special numbers expressible in terms of Bernoulli numbers •Genocchi numbers are defined by the exponential generating function 2t et−1= ∞ ∑ n=1 Gn tn n!, (5.31) and are related to the Bernoulli numbers through the relation Gn=2(1−2n)Bn. (5.32) •Tangent numbers are defined by the exponential generating function tan(t) = ∞ ∑ n=0 Tn tn n!. (5.33) These are related to the Bernoulli numbers by means of the functional relation T2n−1= (−1)n−122n(22n−1) 2nB2n,T2n=0, n≥1, (5.34) and T0=0. The first nsecant numbers Sn, also known as zig numbers and expressible in terms of Euler numbers, Sn=|E2n|, and Tangent numbers can be computed very efficiently using asymptotically fast algorithms in O(n2log(n)2+o(1))bit-operations, as described [20]. •Bernoulli numbers of the second kind are defined by the generating function t log(1+t)= ∞ ∑ n=0 bntn,|t|<1, (5.35) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 109 and are expressible in terms of Nörlund numbers as follows n!bn=−1 n−1B(n−1) n,n≥2. (5.36) The Eulerian polynomials are defined by the exponential generating function x−1 x−e(x−1)t= ∞ ∑ n=0 An(x)tn n!. (5.37) Properties of the Eulerian polynomials are described in the next Section. The Eulerian numbers, usually denoted as A(n,m)or hn m−1i, give the number of permutations of set of nelements having mpermutation ascents, i.e. melements are greater than the previous element. They are the coefficient of the Eulerian polynomials An(x) = n ∑ m=0 A(n,m)xm. (5.38) The Eulerian numbers satisfy the recurrence relation A(n,m) = (n−m+1)A(n−1, m−1) + mA(n−1, m), (5.39) and have the explicit formulas n k= k ∑ j=0 (−1)jn+1 j(k+1−j)n(5.40) n k= n−k ∑ j=0 (−1)n−k−jj!n−j kS(n,j), (5.41) the latter in terms of the Stirling numbers of the second kind. The Eulerian numbers are also connected to Bernoulli numbers [170] Bn= n ∑ k=0n k(−1)k k+1,n≥0. (5.42) The Bell polynomials Bn(x)(not be confused with Bernoulli polynomials) have the exponential generating function e(et−1)x=∑ n=0 Bn(x)tn n!, (5.43) and they are connected with Stirling numbers of the second kind through the explicit formula Bn(x) = n ∑ k=0 xkS(n,k). (5.44) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 110 The computation of Bell polynomials can be extended to complex order and argument by using the Dobiínski’s formula given by Bn(x) = e−x ∞ ∑ j=0 jn j!xj. (5.45) For x=1, Bn(1) = Bnis the n-th Bell number, which represent the number of class-partitions of a finite set with nelements. A well-known asymptotic formulas for Bnis given in [39]. A recent discussion about methods for efficient computation of large Bell numbers with arbitrary-precision can be found in http://fredrikj. net/blog/2015/08/computing-bell-numbers/. Last, we recall that uniform upper bounds for the Bell polynomials and Bell numbers are derived in Chapter 3. 5.1.2 The Lerch transcendent and related functions The most prominent and complete work aiming to present a unified framework for the Lerch transcendent and other related functions was carried out by Crandall in [37]. In this subsection, we present some well-known functional relations involving the Lerch transcendent. We briefly introduce the Lerch transcendent notation, and we shall refer to the next section for extended treatment and presentation of numerical methods for its computation. Finally, a quite complete list of zeta functions is given in https://en.wikipedia.org/wiki/List_of_zeta_functions. The Lerch transcendent is defined by the L-series Φ(z,s,a) = ∞ ∑ k=0 zk (k+a)s, (5.46) which converges for |z| ≤ 1, a/∈Z− 0or <(s)>1, |z|=1 and is defined by analytic continuation elsewhere. Relevant special cases include the Riemann zeta function ζ(s) = ∞ ∑ k=1 1 ks=Φ(1, s,1). (5.47) Furthermore, by analytic continuation the following alternating series valid for <(s)>0 is obtained ζ(s) = 1 1−21−s ∞ ∑ n=1 (−1)n+1 ns,<(s)>0 (5.48) where the sum on the right-hand side is exactly the Dirichlet eta function η(s)or alternating zeta function given by η(s) = ∞ ∑ k=1 (−1)k−1 ks= (1−21−s)ζ(s) = Φ(−1, s, 1). (5.49) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 111 The Riemann zeta function is also expressible in terms of Stieltjes constants γkby means of the Laurent expansion ζ(s) = 1 s−1+ ∞ ∑ k=0 (−1)nγn (s−1)n n!. (5.50) The Hurwitz zeta function is defined by analytic continuation of the sum ζ(s,a) = ∞ ∑ k=0 1 (a+k)s=Φ(1, s,a), (5.51) and has a Laurent expansion in terms of generalized Stieltjes constants γk(a)given by ζ(s,a) = 1 s−1+ ∞ ∑ k=0 (−1)kγk(a)(s−1)k k!. (5.52) Other related functions representable in terms of the Lerch transcendent are the Dirichlet beta function β(s) = ∞ ∑ k=0 (−1)k (2k+1)s=4−sζs,1 4−ζs,3 4=2−sΦ−1, s,1 2, (5.53) the Legendre chi function χs(z) = ∞ ∑ k=0 z2k+1 (2k+1)s=2−szΦz2,s,1 2. (5.54) and the Polylogarithm Lin(z) = ∞ ∑ k=1 zk kn=zΦ(z,n,1). (5.55) The Polylogarithm is generally computed by means of its functional relation with the Hurwitz zeta function Lis(z) = Γ(1−s) (2π)1−si1−sζ1−s,1 2+log(−z) 2πi+is−1ζ1−s,1 2−log(−z) 2πi. Additionally, some special polynomials such as the Bernoulli polynomials are also special cases of the Lerch transcendent Bn(x) = n ∑ k=0 1 k+1 k ∑ j=0 (−1)jk j(x+j)n=−nΦ(1,1 −n,x). (5.56) There is a vast literature on numerical methods for the computation of the Riemann zeta function and the Hurwitz zeta function. Besides the numerical methods for the Riemann zeta function in [15], previously discussed in Chapter 2, other methods are included in [14] and [78]. A complete algorithmic description of the implementation in [54] for real and integer argument is included in https://www. mpfr.org/algorithms.pdf. Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 118 and ∞ ∑ j=0k j(alog(z))k−j(−s)(j)= (−1)kU(−k,1 −k−s,−alog(z)). (5.76) Finally, taking the imaginary part of (5.73) yields I=1 as ∞ ∑ k=0 (−1)k a2k+1 U(−2k−1, −2k−s,−alog(z)) (2π)2k+2ζ(2k+2) =1 2as ∞ ∑ k=1 B2k (2k)! U(−2k+1, −2k+2−s,−alog(z)) a2k−1, (5.77) where the relationship between Bernoulli numbers B2kand the Riemann zeta function is applied.  Note that the expansion is convergent for |log(z)|<2π. This can be observed by taking the asymptotic estimate of the k-th term in (5.77) |tk|= B2k (2k)! U(−2k+1, −2k+2−s,−(a+N)log(z)) (a+N)2k−1 ∼2 (2π)2k|log(z)|2k−1, (5.78) as N,M→∞, where we consider the usual asymptotic estimates for U(a,b,z)∼ z−aas |z| → ∞and |B2k|/(2k)! using the fact that ζ(2k)∼1 as k→∞. To assess the domain of convergence for zwe use the ratio test (d’Alembert ratio test) lim k→∞ tk+1 tk∼|log(z)2| 4π2<1⇐⇒ |log(z)|<2π. Finally, taking Msuch that <(s) + 2M−1>0, the remainder term (5.67) in the Euler-Maclaurin summation formula is well defined, giving its analytic continuation to s∈C\{1}. Theorem 5.2.2 Given a,s,z∈Cwith |log(z)|<2πand N,M∈Nsuch that <(a) + N>0and <(s) + 2M>1, the error term (5.67) in the Euler-Maclaurin summation formula satisfies |R| ≤ 4 (2π)2M C 2M ∑ k=02M kQ(k+1−2M−s,W)(−log(z))−k−1+2M+s log−k(z) , (5.79) where C =Γ(1−s)/za, W =−(a+N)log(z)and Q(a,z) = Γ(a,z)/Γ(a)is the regularized incomplete Gamma function. Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 119 Proof: We have |R|=Z∞ N ˜ B2M(t) (2M)! zt (a+t)s+2MU(−2M,−2M+1−s,−(a+t)log(z)) dt ≤˜ B2M(t) (2M)!Z∞ N zt (a+t)s+2MU(−2M,−2M+1−s,−(a+t)log(z)) dt ≤4 (2π)2M 2M ∑ k=02M kBM k(s)Z∞ N zt (a+t)s+2M((a+t)log(z))kdt with BM k(s) = (k+1−2M−s)2M−k. We apply the usual upper bound for |˜ Bn(t)|< 4n!/(2π)nand formally interchange integration and the expansion ofU(−2M,−2M+ 1−s,−(a+N)log(z)) given by U(−2M,−2M+1−s,−(a+N)log(z)) = 2M ∑ k=02M kBM k(s)((a+t)log(z))k. The integral above can be expressed in terms of the incomplete Gamma function Γ(a,z)as follows (similar to (5.65)) Z∞ N zt (a+t)s+2M((a+t)log(z))kdt =logk(z) za(−log(z))−k−1+2M+s ×Γ(k+1−2M−s,−(a+N)log(z)) (5.80) Thus, we have 2M ∑ k=02M kBM k(s)Z∞ N zt (a+t)s+2M((a+t)log(z))kdt =Γ(1−s) za 2M ∑ k=02M kQ(k+1−2M−s,−(a+N)log(z))(−log(z))−k−1+2M+s log−k(z), where we use BM k(s) = Γ(1−s)/Γ(k+1−2M−s). Note that for s∈Nwe take equation (5.80) to avoid the pole.  The bound given in Theorem 5.2.2 give us a notably tight approximation of remainder (5.67). However, for large Mthe direct evaluation of the terminating series in (5.79) might be substantially expensive, being a not negligible part of the total computation time, therefore approximations for large order will be considered in Section 5.2.3. Uniform asymptotic expansion for Φ(z,s,a) A suitable Laplace-type integral representation of Φ(z,s,a)amenable to derive multiple asymptotic expansions [37], is given by Φ(z,s,a) = 1 Γ(s)Z∞ 0 ts−1e−at 1−ze−tdt,<(s)>0, <(a)>0, z/∈[1, ∞), (5.81) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 120 which serves to define the analytic continuation of the Lerch-series to z∈C\[1, ∞). This integral has been chosen as starting point to derive asymptotic expansions for either large or small a(assuming that sand zare fixed) or for large zin [49], and for a Bernoulli-series representation as in [37]. The aim of this subsection is to extend the domain of computation of the Poincaré type asymptotic expansion for large a defined in [49] by constructing a uniform asymptotic expansion for large a,sand z. We proceed to construct that expansion by using the vanishing saddle point method described in [157]. This method is fundamentally a modification of Laplace’s method applicable to integrals of the form Fλ(z) = 1 Γ(λ)Z∞ 0tλ−1e−zt f(t)dt, (5.82) with <(λ)>0 and zlarge, in which λmight also be large. The resulting expansion is given by Fλ(z)∼ ∞ ∑ k=0 ak(µ)Pk(λ) zk+λ, where ak(µ)are the coefficients of the expansion of f(t)at the saddle point µ=λ/z and coefficients Pk(λ)are expressible in terms of generalized Laguerre polynomials defined by Pk(λ) = k!L−k−λ k(−λ). (5.83) At this point, we briefly recall the definition of the Eulerian polynomial and its connection with the polylogarithm function before stating the next proposition. The Eulerian polynomial is defined as Ak(z) = k−1 ∑ j=0k jzj, (5.84) where hk jiare the Eulerian numbers [64]. The Eulerian polynomials satisfy the recurrence equation A0(z) = 1, Ak(z) = k−1 ∑ j=0k jAj(z)(z−1)k−1−j,k≥1. (5.85) The Eulerian polynomial and polylogarithm are related by the functional equation Ak(z) = (1−z)k+1 zLi−k(z) = (1−z)k+1 z ∞ ∑ j=1 jkzj,|z|<1, (5.86) and if |z|>1 then Ak(z) = (−1)k+1Ak1 z. Proposition 5.2.3 For a,s,z∈C,<(a)>0and z /∈[1, ∞)we have the following uniform asymptotic expansion for Φ(z,s,a) Φ(z,s,a) = eµ eµ−z 1 as+ K−1 ∑ k=2 (−1)kPk(s) k!ak+srkAkeµ z!+εK(z,s,a), (5.87) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 121 where r =z/(eµ−z). Proof: We take f(t)=(1−ze−t)−1and µ=s/ain (5.82), where µis the saddle point of the dominant part of the integral. Following closely the derivation in [49], we expand f(t)at t=µto obtain the Taylor expansion f(t) = ∞ ∑ k=0 ak(µ)(t−µ)k,ak(µ) = (−1)keµzk k!(eµ−z)k+1 k−1 ∑ j=0k jeµ zj . (5.88) After performing a few algebraic manipulations we obtain the final representation for the vanishing point expansion for Φ(z,s,a). We can clearly observe that for large values of <(s)and |z|, the asymptotic convergence of the expansion improves. Furthermore, from a numerical perspective, moderate to large values of <(s)<0 permit the evaluation of Ak(eµ/z)via the convergent series (5.86). It remains to bound the error term in the expansion after truncation at k=K−1. Let us consider the k-th term of expansion (5.87) defined as |tk|= Pk(s) k!ak+sz eµ−zk Akeµ z≤ 1 k!ak+sz eµ−zk|Pk(s)|Akeµ z. A bound for the error term by comparison with a geometric series yields  ∞ ∑ k=K tk≤|tK| 1−C,C= tK+1 tK, (5.89) iff C<1, where tKis the first omitted term in the expansion and |εK(z,s,a)| ≤  eµ eµ−z|tK| 1−C. In order to provide an effective upper bound for |tk|, we compute two saddle point bounds for polynomials Pk(z)and Ak(z). Proposition 5.2.4 For k >1and z ∈C\{1}the Eulerian polynomials satisfy the following bound |Ak(z)| ≤ k!(z−1)eφ(t0), (5.90) where t0=W(ekkz)−k z−1and φ(t0) = −klog t0−log z−e(z−1)t0), and W(x)is the Lambert-W function which solves W(x)eW(x)=x. Proof: An integral representation for the Eulerian polynomials is obtained after applying Cauchy’s integral formula to the exponential generating function given by ∞ ∑ k=0 Ak(z)tk k!=z−1 z−e(z−1)t=⇒Ak(z) = k!(z−1) 2πiIt−k−1 z−e(z−1)tdt, Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 122 which can be written in the form Ak(z) = k!(z−1) 2πiIeφ(t) tdt,φ(t) = −klog t−log z−e(z−1)t. We compute the saddle point of the integrand by solving the following equation φ0(t) = (z−1)e(z−1)t z−e(z−1)t−k t,t0=W(ekkz)−k z−1. (5.91) The principal contribution of the saddle point bound is obtained by substituting t0 into the integrand |Ak(z)| ≤ k! 2πi(z−1)eφ(t0)Idt t=k!(z−1)eφ(t0). Finally, by the residue theorem we obtain the result.  A similar analysis is carried out for polynomials Pk(z). The use of the generating function for generalized Laguerre polynomials gives the Cauchy-type integral representation Pk(s) = k!L−k−s k(−s) = k! 2πiZC(1−t)k+s−1ets/(1−t)dt tk+1, (5.92) where Cis a circle around the origin with a radius less than unity. Proposition 5.2.5 For k >1and s ∈C\{0,1}the polynomials Pk(s)satisfy the following bound |Pk(s)|≤k!eφ(t0), (5.93) where t0=√k2+4ks −2k+1+k+1 2(1−s) and φ(t0) = st0 1−t0+ (k+s−1)log(1−t0)−klog t0. Proof: A proof follows the steps presented previously.  Combination of both bounds (5.90) and (5.93) gives the final form for the error bound. The selection of the appropriate truncation point Kto achieve a desired level of precision is detailed in Section 5.2.3. Asymptotic expansion for large z A careful reader shall have noticed that none of the previous series expansions are suitable for arbitrarily large <(z)>0. The expansion in this subsection complements the asymptotic expansion described in [49] for z∈C\[0, ∞),<(a)>0 and <(s)>0 for large zand fixed aand s Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 123 Theorem 5.2.6 For a,s,z∈Cand <(a)>0we have an asymptotic expansion for large a and z, and fixed s given by Φ(z,s,a)∼1 2as+(−log(z))s−1 zaΓ(1−s,−alog(z)) +1 2as2 log(z)−coth log(z) 2 +1 as ∞ ∑ k=1 (s)k ak(2π)k+11 uk+1−πk+1 k!coth(πu)k−1csch(πu)2Pk(sech(πu)2), (5.94) where u =log(z) 2πand Pk(x)are peak polynomials [149]. Proof: We start from the integral representation (5.69). Application of the binomial theorem yields I==Z∞ 0 z−it (1−it/a)s dt e2πt−1== ∞ ∑ k=0 (s)k k!i akZ∞ 0 z−ittk e2πt−1dt!. Let us focus on the inner integral Ikdefined as Ik=Z∞ 0 z−ittk e2πt−1dt =Z∞ 0 z−ittk(1−e−t) (1−e−t)(e2πt−1)dt . Noting that (1−e−t)/(e2πt−1) = 1 2(coth(πt)−1)(sinh(t)−cosh(t) + 1), we split the integral obtaining a closed form in terms of the Hurwitz zeta function Ik=k!ζ(k+1,ilog(z)/(2π)) (2π)k+1−1 (ilog(z))k+1=k! (2π)k+1ζk+1,1 +ilog(z) 2π. For k=0, ζk+1,1 +ilog(z) 2πhas a pole, so we proceed as follows =Z∞ 0 z−it e2πt−1dt=−Z∞ 0 sin(log(z)t) e2πt−1dt =1 42 log(z)−coth log(z) 2. Combining terms give us the asymptotic expansion for integral (5.69) I∼1 42 log(z)−coth log(z) 2+ ∞ ∑ k=1 (s)k ak(2π)k+1=ikζk+1,1 +ilog(z) 2π. Hereinafter we use u=log(z) 2πto simplify notation. Let us define the terms Ck(u) as Ck(u) = =ikζ(k+1,1 +iu)=ik+1 2(−1)kζ(k+1,1 −iu)−ζ(k+1,1 +iu), where we remove the imaginary part. In order to eliminate the computations on the complex plane for real z, we expand1Ck(u)reducing compound arguments. 1We employ FunctionExpand in Mathematica [169]. Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 124 The first five coefficients ck(u) = 2Ck(u)are c1(u) = 1 u2−π2csch(πu)2, c2(u) = 1 u3−π3coth(πu)csch(πu)2, c3(u) = 1 u4−π4 64coth(πu)2csch(πu)2+2csch(πu)4, c4(u) = 1 u5−π5 24 8coth(πu)3csch(πu)2+16coth(πu)csch(πu)4, c5(u) = 1 u6−π6 120 16coth(πu)4csch(πu)2+88coth(πu)2csch(πu)4+16csch(πu)4. From the observation of previous coefficients, we state the following identity, which proof follows by induction Ck(u) = 1 2uk+1−πk+1 2k! dk/2e−1 ∑ j=0 P(k,j)coth(πu)k−1−2jcsch(πu)2(j+1) =1 2uk+1−πk+1 2k!coth(πu)k−1csch(πu)2dk/2e−1 ∑ j=0 P(k,j)sech(πu)2j =1 2uk+1−πk+1 2k!coth(πu)k−1csch(πu)2Pk(sech(πu)2). where P(k,j)denotes the number of permutations of knumbers with jpeaks, also known as peak number or pk-number, and Pk(x)apk-polynomial. Peak numbers P(k,j)give the sequence A008303 of the OEIS [144]. For k≥1 and 0 ≤j≤k, we have a functional recursion generating a triangular array P(k,j) = 2(j+1)P(k−1, j) + (k−2j)P(k−1, j−1). (5.95) Note that P(k,j) = 0 for j≥k/2 and therefore deg Pk(x) = dk/2e − 1. Peak polynomials are given by the generating function for peak numbers P(k,j). Pk(x) = dk/2e−1 ∑ j=0 P(k,j)xj. Note that for values of |x| → 1 we can estimate its magnitude by the finite sum of peak numbers, since ∑dk/2e−1 j=0P(k,j) = k!, hence |Pk(x)| ∼ k!, |x| → 1. (5.96) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 125 The bivariate exponential generating function can be defined as in [51], [172] ∞ ∑ k=0Pk(p)xk k!=1−1 p+pp−1 ptan xpp−1+arctan(1/pp−1) =p1−pcosh(xp1−p) p1−pcosh(xp1−p)−sinh(xp1−p) =1 p1−pcoth(xp1−p)−1 As customary in analytic combinatorics, application of Cauchy’s integral formula to the bivariate exponential generating function gives Pk(p) = k! 2πZ2π 0 e−ikt p1−pcoth(eitp1−p)−1dt . A remarkable result from the theory of enriched P-partitions is the functional relation between peak polynomials and Eulerian polynomials stated in [149] Pk4x (1+x)2=2k−1 (1+x)k−1Ak(x), (5.97) which allows us to use the upper bound in (5.90) to estimate the truncation point in (5.94). Furthermore, a good asymptotic estimate of Pk(x)for large order kcan be derived from a Mittag-Leffler type decomposition of Eulerian polynomials [36]: Ak(z) = C(k,z) 1 log(z)k+1+ ∞ ∑ j=1 1 (log(z) + 2πij)k+1+1 (log(z)−2πjk)k+1!, where C(k,z) = eπi(k−1)(1−z)k+1k! z. Taking the prefactor of the expansion and applying the functional relation (5.97) we have Pk(x)∼2k−1k!eπi(k−1)(1−u)k+1 (1+u)k−1ulog(u)k+1,u=2−x−2√1−x x,k→∞. 5.2.3 Algorithmic details and implementation In this section we discuss in detail the implementation aspects and several proposed heuristics easy to evaluate while being effective in practice. All algorithms described are implemented in Python2using the mpmath library for arbitray-preci- sion floating-point arithmetic [92] with GMPY2, which supports integer and rational arithmetic via the GMP library [69] and real and complex arithmetic by the MPFR [54] and MPC [47] libraries. 2https://sites.google.com/site/guillermonavaspalencia/software/lerch.py Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 126 As it is well-known, numerical evaluation of special functions requires the use of several methods of computation to cover the whole regime of the parameters. We aim to sketch the building blocks of a basic algorithm, which have been tested to work reasonable well for most cases, but we do not dare to claim that it will cover the whole function’s domain optimally. For those cases either not covered by current series expansions or prone to numerical instability, we select numerical complex integration, which serves as a backup method. Evaluation of L-series The L-series of the form (5.57) are in general difficult to accelerate due to the non recursive scheme of computation. In order to employ common acceleration techniques such as parallelization, the determination of the optimal truncation level is crucial. As described in the previous section, a bound for the remainder term of the L-series can be constructed as follows  ∞ ∑ k=K zk (k+a)s≤|z|K |(K+a)s|(1−CK(z,s,a)) ≤|z|K |(K+a)s|(1−|z|), (5.98) where CK(z,s,a) =  z(K+a)s (K+1+a)s, lim K→∞CK(z,s,a) = |z|. (5.99) The required number of terms Kto obtain a result with P-bit precision can be obtained by performing a simple linear search, which is generally sufficient to target an absolute error of about 2−P. However, a more efficient approximation of Kis yielded by solving the following equation with the first omitted term, zK(K+a)−s=2−Pfor K. The first solution in closed-form is given by K=−sW(φ(z,s,a,P)) + alog(z) log(z),φ(z,s,a,P) = −(2−Pza)−1/slog(z) s. We distinguish two different approximations for K, denoted as ˆ K, depending on <(s). For <(s)>0 ˆ K=<(s)W0(φ1(z,s,a,P)) + |a|log(|z|) log(|z|), where [x]denotes the nearest integer function and φ1(z,s,a,P) = −(2−P|a|−<(s)−1|z||a|)−1/(<(s)+1)log(|z|) <(s) + 1. For <(s)<0 ˆ K=<(s)W−1(φ2(z,s,a,P)) + |a|log(|z|) log(|z|), where φ2(z,s,a,P) = −(2−P|a|−<(s)|z||a|)−1/<(s)log(|z|) <(s). Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 127 Given that φ1,φ2∈R, we use the principal branch W0(z) = W(z)when <(s)>0, since φ1>0 and the branch W−1(z)for <(s)<0, since φ2∈(−1/e, 0). Remember that W(x)is two-valued for −1/e≤x<0. Numerical tests suggest that these approximations for choosing Kare sufficient to obtain good estimates of the required number of terms. We note that ˆ Kcan be computed using 53-bit machine floating-point arithmetic. Several heuristics are implemented to compensate catastrophic cancellation for cases when <(z)<0 and/or <(s)<0. In particular, for <(s)<0 we increase the working precision PW=P+bP/3c+ [−<(s)]. On the other hand, for the case <(s)>1 and z∈R<0we employ the linear acceleration methods for alternating series described in [35]. This method is used when ˆ K>1.2[1.31D], where Dis the precision digits. For all other cases, we add up to 20 guard bits to the working precision. The computation of the L-series is particularly simple to parallelize by assigning a block of size k:k≤Nto each thread. This parallelization scheme is implemented using the multiprocessing module in Python. Based on experiments, parallelization provides a significant speedup factor for ˆ K>1024 or P≥1024 bits. We remark that L-series converges rather slowly when |z| → 1. It is possible to employ convergence acceleration techniques to obtain an efficient evaluation of the Lerch transcendent; see the application of combined nonlinear-condensation transformation in [85]. Alternatively, the Euler-Maclaurin formula is also convenient for those cases, as shown later. Evaluation of the Euler-Maclaurin error bound For a precision of Ddigits, we choose N=bD/3c. For large <(a)>0 we choose N=0 if the following condition is satisfied <(a)>|<(s)|+|<(z)|+D. The number of terms Mcan be effectively approximated by solving tk=2−P, where Pis the precision in bits and tkis the asymptotic estimate in (5.78), which yields M∼1 2 log(2−P−1log(z)) log(2π)−log(log(z)). This is a near-optimal approximation at high-precision. In practice, the asymptotic estimate of Mis used for P≥500, otherwise we use the heuristic M=N+bP/3c. There is a unavoidable trade-off when choosing Nand M, large values results in catastrophic cancellation since the L-series might be unstable, especially for z∈ C\R, but reduces the number of terms M, therefore the time spent computing Bernoulli numbers, which represents a significant amount of the total computation time. We can evaluate the coefficient in the error bound (5.79) using a recurrence. Computation of Q(k+1−2M−s,−(a+N)log(z)) only requires the initial value Q(1−s,−(a+N)log(z)), which can be computed re-using Γ(1−s,−(a+N)log(z)) Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 134 between Mathematica and mpmath (mpmath only implements numerical integration), only the former is used for benchmarking on subsequent tests. Results show that our implementation is comparable to Mathematica (presumably evaluating the same L-series) at lower precision and it is found to be surprisingly faster at higher precision3. Moreover, we observe that our parallelization scheme achieves speedup ratios close to theoretical maximum, which apparently is not implemented in Mathematica. Interestingly, the Euler-Maclaurin formula should be the preferred algorithm at low-medium precision when |z| ∼ 1. Φ(z,s,a)bits Mathematica L-series Parallel Euler-Maclaurin 64 0.0011 0.0011 - - z=1/4 333 0.0067 0.0055 - - s=10/4 1024 0.0339 0.0155 - - a=20/7 3333 0.7313 0.0660 0.0431 - 10000 21.406 0.4885 0.1513 - 64 0.0015 0.0069 - 0.0031 (0.0053) z=9/10 333 0.0109 0.0607 0.0429 0.0153 (0.0255) s=10/4 1024 0.0984 0.2165 0.1052 0.0166 (0.0222) a=20/7 3333 1.8843 1.0422 0.3281 0.0953 (0.1197) 10000 39.937 8.6969 2.4881 2.7331 (3.1578) 64 0.0031 0.0020 - - z=−6/10 333 0.0156 0.0083 - - s=10/4 1024 0.1422 0.0243 - - a=20/7 3333 3.0922 0.0983 - - 10000 21.2969 0.7500 - - TABLE 5.4: Time (in seconds) to compute Φ(z,s,a)for small argument |z|. The third example assesses the performance of the series acceleration technique for alternating series, which while it is hardly parallelizable, it is consistently faster than Mathematica for all tested instances. Table 5.5 shows the time to compute the Lerch transcendent using the asymptotic expansion (5.94) for large zand a. The optimal truncation of the first test is Kmax =1598, limiting the evaluation at 3333 bits of precision, which would require K=2767. The optimal truncation for the second test is Kmax =22297 requiring up to 1952 terms at 10000 bit of precision. As noted, the time spent on the computation of a large number of peak polynomials accounts for a significant amount of the total time, therefore a more sophisticated and efficient algorithm would be needed at higher precision. On the other hand, for multiple evaluations, peak numbers can be cached same as Bernoulli numbers. Numerical experiments show a performance deterioration of the Euler-Maclaurin formula as zincreases due to catastrophic cancellation, therefore its use should be restricted to low precision calculations. Our implementation of the asymptotic expansion exhibits fast convergence for large parameters, but the limitation on the achievable accuracy forces a switch to numerical integration depending on the desired level of precision. 3We guess the poor performance is due to incorrect error tracking, which overestimates the required working precision. Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 135 Φ(z,s,a)bits mpmath Mathematica Euler-Maclaurin Asymptotic Kpeak time z=140 64 0.0684 0.0154 0.0027 0.0022 9 6.3% s=1/4 333 0.7859 0.1219 2.2342 0.0134 59 10.9% a=200 1024 5.0361 0.7297 - 0.1931 254 10.5% 64 0.1238 0.0661 - 0.0017 6 4.6% z=10000 333 1.5456 0.2078 - 0.0066 34 11.5% s=10/4 1024 9.9478 1.0406 - 0.0481 122 10.0% a=2000 3333 94.362 15.141 - 0.9498 493 8.4% 10000 1978.2 283.21 - 39.779 1952 6.0% TABLE 5.5: Time (in seconds) to compute Φ(z,s,a)for large parameter aand argument z. Comparison to Euler-Maclaurin at low precision. The rightmost column shows the percentage of the total time devoted to computation of Kpeak numbers. Finally, Table 5.6 compares the uniform asymptotic expansion (5.87) to the asymptotic expansion (5.94). Results show that the former expansion should be the preferred choice at low-medium precision for sufficiently large parameters and argument, otherwise the previous methods generally show superior performance. Note that the computation of Eulerian polynomials accounts for the majority of the total time, consequently any improvement on this respect will directly reduce the reported timings. Φ(z,s,a)bits mpmath Mathematica Asymptotic Uniform Eulerian time z=−200.65 64 0.0228* 0.0469 0.0031 (16) 0.0173 (20) 97.0% s=100.25 333 0.0149* 0.1563 0.0412 (104) 0.0592 (60) 97.5% a=501.5 1024 1.0219** 0.8438 0.7512 (421) 0.5151 (229) 98.8% z=−20000 64 0.0101* 0.0312 0.0027 (15) 0.0051 (9) 93.2% s=100.25 333 0.0168* 0.1875 0.0362 (93) 0.0436 (53) 96.9% a=501.5 1024 1.7736 1.0313 0.5424 (365) 0.2964 (196) 98.3% TABLE 5.6: Time (in seconds) to compute Φ(z,s,a)for large parameter aand s, and argument z. Number of terms for each expansion within parentheses. For mpmath: (*) and (**) indicate no answer and inaccurate answer, respectively. 5.2.5 Discussion The algorithms presented in this work are an important step towards a complete arbitrary-precision implementation of the Lerch transcendent using asymptotically fast methods. A fundamental improvement to our implementation is to devise a more intelligent strategy to address cancellation issues for the Euler-Maclaurin formula, which should yield a significant reduction of the current overhead factor. Further work is needed to develop an efficient multithreaded implementation of the asymptotic expansions. More importantly, it remains an open problem whether there is a fast memory-efficient algorithm for computing a large number of Eulerian and peak polynomials. Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 136 5.2.6 Appendix - Algorithms and implementations L-series Algorithm 7 Alternating L-series for z<0 Input: a,s,z∈Cand (|z| ≤ 1, a/∈Z− 0)∨(<(s)>1, |z|=1) Output: S=∑∞ k=0zk (k+a)swith Ddigits of precision initialization 1: N← d1.31De 2: d←(3+√8)N 3: b← −1 4: c← −d 5: u←1 6: S←0 7: for k=0; k=N;k←k+1do 8: t←u/(k+a)s 9: c←c−b 10: if kmod 2 then 11: S←S−c·t 12: else 13: S←S+c·t 14: end if 15: b←b2(k+N)(k−N) (2k+1)(k+1) 16: u←u·z 17: end for 18: return S/d LISTING 5.1: mpmath implementation of truncated block L-series def _lerch_lseries_trunc_block (z , s , a , n1 , n2 , queue ) : """ Truncated L−s e r i e s b l o c k f o r p a r a l l e l impl ementatio n . """ u = z∗∗n1 lsum = u / ( n1 + a)∗∗s for kin range(n1+1, n2 ) : u∗= z lsum += u / (k + a )∗∗s queue . put ( lsum) LISTING 5.2: mpmath parallel implementation of truncated L-series def _lerch_lseries_trunc_parallel (z , s , a , N) : """ Truncated L−s e r i e s , p a r a l l e l implementation . """ i f N == 0: return 0 threads = multiprocessing . cpu_count ( ) block_size = N // threads last_block = N % threads queue = multiprocessing . Queue ( ) processes = [ multiprocessing . Process ( target=_lerch_lseries_trunc_block , args =(z , s , a , Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 137 block_size∗thread , block_size ∗( thread +1) , queue)) for thread in range( threads ) ] for pin processes : p . sta r t () for pin processes : p . join () series_sum = sum ( [ queue . get () for pin processes ] ) i f last_block : _lerch_lseries_trunc_block(z, s, a, block_size∗( threads ) , block_size∗( threads ) + last_block , queue ) series_sum += queue . get () return series_sum Euler-Maclaurin formula Algorithm 8 Evaluation of the tail Tin (5.66) Input: a,s,z∈Cand N,M∈N Output: T=∑M k=1B2k (2k)! U(−2k+1,−2k+2−s,−(a+N)log(z)) (a+N)2k−1 1: a←a+N 2: b← −log(z) 3: r←a·b 4: q←1/r 5: p←s+r 6: c←b2 7: m←2 8: n←b 9: t1←1 10: t2←1+s·q 11: T←t2·b/12 12: for k=2; k=M;k←k+1do 13: h←2k+3 14: p1←p+h 15: p2← −h 16: t1←(t2·p1+t1·p2)q 17: t2←(t1·p1+t2·p2+t1−t2)q 18: m←m·(2k−1)(2k) 19: n←n·b 20: u←t2·n·B2k/m 21: T←T+u 22: end for Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 138 Asymptotic expansions Algorithm 9 Compute first NEulerian polynomials using recurrence Input: z∈C,N∈N Output: Ak(z)k∈ {0, . . . , N} 1: A= [1].Cache of polynomials Awith initialization 2: y←z−1 3: r←1/y 4: t←r 5: for k=1; k=N;k←k+1do 6: s←0 7: t←t·y 8: u←1 9: for j=0; j=k;j←j+1do 10: s←s+A[k]·u 11: u←u·(k−j)·r/(j+1) 12: end for 13: s←s·t 14: A[k]←s.Store new polynomial s 15: end for Algorithm 10 Compute first Nrows of peak numbers triangle Input: N∈N Output: Nrows of P(k,j),k∈ {0, . . . , N} 1: P= [[1],[2]] .Cache of coefficients Pwith initialization 2: for k=2; k=N;k←k+1do 3: v=[] 4: w← dk/2e 5: q← bk/2c 6: for j=0; j=q+1; j←j+1do 7: if j<wthen 8: t1←2(j+1)P[k−1, j] 9: else 10: t1←0 11: end if 12: if j>0then 13: t2←(k+1−2j)P[k−1, j−1] 14: else 15: t2←0 16: end if 17: v[j]←t1+t2 18: end for 19: P[k]←v.Store row v 20: end for Chapter 5. The Lerch Transcendent and Other Special Functions in Analytic Number Theory 139 Algorithm 11 Evaluation of power series in asymptotic expansion (5.94) Input: a,s,z∈C,<(a)>0 and N∈N Output: S(N) = 1 2as2 log(z)−coth log(z) 2 +1 as N ∑ k=1 (s)k ak(2π)k+11 uk+1−πk+1 k!coth(πu)k−1csch(πu)2Pk(sech(πu)2) 1: logz ←log(z) 2: logz2←logz/2 3: q←1/(2π) 4: y←1+i·logz ·q 5: ia ←1/a·q 6: n←q 7: sech2←sech(logz2)2 8: cothk ←coth(logz2) 9: iu ←1/(logz2/π) 10: t←iu 11: d←csch(logz2)2π/cothk 12: c←(2/logz −cothk)/2 13: P=GeneratePeakNumbers(N).pre-compute Nof peak numbers triangle 14: S←0 15: for k=1; k=N;k←k+1do 16: n←n·ia(s+k−1) 17: t←t·iu 18: d←d·(πcothk/k) 19: pN ← dk/2e 20: ps ←0 21: sc ←1 22: for j=0; j=pN;j←j+1do 23: ps ←ps +P[k−1, j]·sc 24: sc ←sc ·sech2 25: end for 26: h←t−d·ps 27: S←S+n·h 28: end for 29: return (c+S)/as 140 Bibliography [1] Z. Altaç. Integrals involving Bickley and Bessel functions in radiative transfer, and generalized exponential integral functions. J. Heat Transfer, 118(3):789–792, 1996. [2] T. Amdeberhan and D. Zeilberger. Hypergeometric series acceleration via the WZ method. Electron. J. Combin., 4(3), 1996. [3] Donald E. Amos. Algorithms 683: A portable FORTRAN subroutine for exponential integrals of a complex argument. ACM Trans. Math. Softw., 16(2):178–182, 1990. [4] E. G. Andrews. Applications of basic hypergeometric functions. SIAM Review, 16(4):441–484, 1974. [5] T. M. Apostol. On the lerch zeta function. Pacific J. Math., 1(2):161–167, 1951. [6] D. H. Bailey and J. M. Borwein. High-precision numerical integration: Progress and challenges. Journal of Symbolic Computation, 46(7):741–754, 2011. [7] D. H. Bailey, K. Jeyabalan, and X. S. Li. A comparison of three high-precision quadrature schemes. Experimental Mathematics, 14(3):317–329, 2005. [8] D. Berend and T. Tassa. Improved bounds on bell numbers and on moments of sums of random variables. Probability and Mathematical Statistics, 30(2):185– 205, 2010. [9] D. J. Bernstein. Fast multiplication and its applications. Algorithmic Number Theory, 44:325–384, 2008. [10] G. Boese. Eine majorante asymptotische Abschätzung für die unvollständige Gammafunktion. Z. Angew. Math. Mech., (52):552–553, 1972. [11] Boost. Boost C++ Libraries. http://www.boost.org/, 2016. Last accessed 2016-12-29. [12] D. Borwein, J. M. Borwein, and O. Chan. The evaluation of Bessel functions via exp-arc integrals. Journal of Mathematical Analysis and Applications, 341(1):478–500, 2008. [13] D. Borwein, J. M. Borwein, and R. E. Crandall. Effective laguerre asymptotics. SIAM J. Numerical Analysis, 46(6):3285–3312, 2008. [14] J. M. Borwein, D. M. Bradley, and R. E. Crandall. Computational strategies for the Riemann zeta function. Journal of Computational and Applied Mathematics, 121:247–296, 2000. BIBLIOGRAPHY 141 [15] P. B. Borwein. An efficient algorithm for the Riemann zeta function. Canadian Mathematical Society Conference Proceedings, 27:29–32, 2000. [16] W. Bosma, J. Cannon, and C. Playoust. The Magma algebra system. I. The user language. J. Symbolic Comput., 24(3-4):235–265, 1997. Computational algebra and number theory (London, 1993). [17] A. Bostan, P. Gaudry, and É. Schost. Linear recurrences with polynomial coefficients and application to integer factorization and Cartier-Manin operator. SIAM Journal on Computing, 36(6):1777–1806, 2007. [18] R. Brent and P. Zimmermann. Modern Computer Arithmetic. Cambridge University Press, New York, NY, USA, 2010. [19] R. P. Brent. The complexity of multiple-precision arithmetic. The Complexity of Computatioanl Problem Solving, pages 126–165, 1976. [20] R. P. Brent and D. Harvey. Fast computation of Bernoulli, Tangent and Secant numbers. In Computational and Analytical Mathematics, pages 127–142, New York, NY, 2013. Springer New York. [21] C. Brezinski and M. Redivo Zaglia. Extrapolation Methods. Theory and Practice, volume 2 of Studies in Computational Mathematics. North-Holland Publishing Co., Amsterdam, 1991. With 1 IBM-PC floppy disk (5.25 inch). [22] H. Buchholz. The Confluent Hypergeometric Function with Special Emphasis on Its Applications. Springer-Verlag, New York, 1969. Translated from the German by H. Lichtbau and K. Wetzel. [23] S. Chandrasekhar. Radiative Transfer. Dover Books on Intermediate and Advanced Mathematics. Dover Publications, 1960. [24] C. Chiccoli, S. Lorenzutta, and G. Maino. A numerical method for generalized exponential integrals. Comput. Math. Appl., 14(4):261–268, 1987. [25] C. Chiccoli, S. Lorenzutta, and G. Maino. An algorithm for exponential integrals of real order. Computing, 45(3):269–276, 1990. [26] C. Chiccoli, S. Lorenzutta, and G. Maino. Recent results for generalized exponential integrals. Comput. Math. Appl., 19(5):21–29, 1990. [27] C. Chiccoli, S. Lorenzutta, and G. Maino. Concerning some integrals of the generalized exponential-integral function. Comput. Math. Appl., 23(11):13–21, 1992. [28] W. J. Cody. A survey of practical rational and polynomial approximation of functions. SIAM Review, 12(3):400–423, 1970. [29] W. J. Cody. Algorithm 715: SPECFUN–a portable FORTRAN package of special function routines and test drivers. ACM Trans. Math. Softw., 19(1):22–30, 1993. [30] W. J. Cody and H. C. Thacher, Jr. Chebyshev approximations for the exponential integral Ei(x).Math. Comp., 23(106):289–303, 1969. BIBLIOGRAPHY 142 [31] M. W. Coffey. On hypergeometric series reductions from integral representations, the Kampe de Feriet function, and elsewhere. Int. J. Mod. Phys., B(19):4483–4493, 2006. [32] M. W. Coffey. A set of identities for a class of alternating binomial sums arising in computing applications. Util. Math., 2007. [33] M. W. Coffey. An efficient algorithm for the Hurwitz zeta and related functions. Journal of Computational and Applied Mathematics, 225(2):338–346, 2009. [34] H. Cohen. Number Theory - Vol II: Analytic and Modern Tools. Springer-Verlag - Graduate Texts in Mathematics 240, 2007. [35] H. Cohen, F. Rodriguez Villegas, and D. Zagier. Convergence acceleration of alternating series. Experiment. Math., 9(1):3–12, 2000. [36] O. Costin and S. Garoufalidis. Resurgence of the fractional polylogarithms. 2009. [37] R. E. Crandall. Unified algorithms for polylogarithms, L-series, and zeta variants. 2012. [38] A. Cuyt, V. Petersen, B. Verdonk, H. Waadeland, W. B. Jones, and C. Bonan- Hamada. Handbook of Continued Fractions for Special Functions. Kluwer Academic Publishers Group, Dordrecht, 2007. [39] N.G. de Bruijn. Asymptotic Methods in Analysis. Bibliotheca mathematica. Dover Publications, 1970. [40] A. Deaño and D. Huybrechs. Complex gaussian quadrature of oscillatory integrals. Numerische Mathematik, 112(2):197–219, 2009. [41] A. Deaño and N. M. Temme. On modified asymptotic series involving confluent hypergeometric functions. Electronic Transactions on Numerical Analysis, 35:88–103, 2009. [42] T. J. Dekker. A floating-point technique for extending the available precision. Numer. Math., 18(3):224–242, 1971. [43] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/, Release 1.0.14 of 2016-12-21. F. W. J. Olver, A. B. Olde Daalhuis, D. W. Lozier, B. I. Schneider, R. F. Boisvert, C. W. Clark, B. R. Miller and B. V. Saunders, eds. [44] E. D. Dolan and J. J. Moré. Benchmarking optimization software with performance profiles. Mathematical Programming, 91(2):201–213, 2002. [45] T.M. Dunster, A. Gil, and J. Segura. Uniform asymptotic expansions for laguerre polynomials and related confluent hypergeometric functions. 2017. [46] W. Ehrhardt. The AMath and DAMath Special Functions (version 2.23), 2018. http://www.wolfgang-ehrhardt.de/amath_functions.html. BIBLIOGRAPHY 143 [47] A. Enge, M. Gastineau, P. Théveny, and P. Zimmermann. mpc — A library for multiprecision complex arithmetic with exact rounding. INRIA, 1.0.3 edition, February 2015. http://mpc.multiprecision.org/. [48] A. Erdélyi, W. Magnus, F. Oberhettinger, and F. G. Tricomi. Higher Transcendental Functions. Vol. I. McGraw-Hill Book Company, Inc., New York- Toronto-London, 1953. [49] C. Ferreira and J. L. López. Asymptotic expansions of the Hurwitz—Lerch zeta function. Journal of Mathematical Analysis and Applications, 298(1):210– 224, 2004. [50] C. Ferreira, J. L. López, P. Pagola, and E. Pérez Sinusía. The Laplace’s and steepest descents methods revisited. Int. Math. Forum, 2:297–314, 2007. [51] C. J. Fewster and D. Siemssen. Enumerating permutations by their run structure. The electronic journal of combinatorics, 21, 10 2014. [52] P. Flajolet and R. Sedgewick. Mellin transforms and asymptotics: Finite differences and Rice’s integrals. Theoretical Computer Science, (144):101–124, 1995. [53] P. Flajolet and R. Sedgewick. Analytic Combinatorics. Cambridge University Press, New York, NY, USA, 1 edition, 2009. [54] L. Fousse, G. Hanrot, V. Lefèvre, P. Pélissier, and P. Zimmermann. MPFR: A multiple-precision binary floating-point library with correct rounding. ACM Trans. Math. Softw., 33(2), June 2007. [55] J. Franklin and B. Friedman. A convergent asymptotic representation for integrals. Mathematical Proceedings of the Cambridge Philosophical Society, 53(3):612– 619, 1957. [56] Galassi et al. Gnu Scientific Library: Reference Manual (3rd Ed.). Network Theory Ltd., 2003. [57] The GAP Group. GAP – Groups, Algorithms, and Programming, Version 4.10.0, 2018. [58] W. Gautschi. Exponential integral R∞ 1e−xtt−ndt for large values of n.J. Res. Nat. Bur. Standards, 62:123–125, 1959. [59] W. Gautschi. Gauss quadrature approximations to hypergeometric and confluent hypergeometric functions. Journal of Computational and Applied Mathematics, 139:173–187, 2002. [60] A. Gil, D. Ruiz-Antolín, J. Segura, and N. M. Temme. Algorithm 969: Computation of the incomplete gamma function for negative values of the argument. ACM Trans. Math. Softw., 43(3):26:1–26:9, November 2016. [61] A. Gil, J. Segura, and N. M. Temme. Numerical methods for special functions. SIAM, 2007.