Proceedings of the 8th WSEAS International Conference on EDUCATION and EDUCATIONAL TECHNOLOGY On approximations to the factorial GIANFRANCO CHICCO Dipartimento di Ingegneria Elettrica Politecnico di Torino Corso Duca degli Abruzzi 24, 10129 Torino ITALY [email protected] http://www.polito.it Abstract: - Analytic formulations for approximating the factorial can be helpful to be used in continuous problems. The DeMoivre-Stirling’s formula is the most classical one. However, the literature has provided some examples of continuous functions, that generally can be structured as products of the De Moivre-Stirling’s formula times a correction function, thus investigating the characteristics of the correction function to check whether it is possible to get a better representation of the factorial for natural numbers. This paper provides a tutorial illustration of the characteristics of various approximations to the factorial, as well as the proposal of a novel continuous function, included within the comparisons. This function has relative approximation errors with respect to the factorial very low and always positive for any natural number. These characteristics enable the novel function to be used as an upper bound to the factorial in continuous problems. Key-Words: - Factorial, Stirling, approximation, asymptotic convergence, correction function, relative approximation error. 1 Introduction The factorial of a natural number n ∈ ℵ can be written by using the Gamma function [1] as n ! = Γ(n + 1) or, in the integral form, n! = ∫ ∞ x n e − x dx (1) 0 However, the integral formulation makes Equation (1) difficult to handle. Simple continuous explicit functions have then been proposed for an easier approximation to the factorial. A typical approximation is the well-known De Moivre-Stirling’s formula [2,3], often called in short Stirling’s formula, expressed (using a natural number argument n ∈ ℵ) as s (n ) = n n+ 1 2 e − n 2π 2 Approximations to the factorial Different approximations to the factorial by using explicit continuous functions have been proposed. Some of them can be written by multiplying the Stirling’s formula to a correction function ζ (n ) , such that ψ (n ) = ζ (n ) s(n ) (3) A common formulation uses as corrective function the first terms of the asymptotic series for the Gamma function [16-18]. Using the first two terms of the series, the correction function becomes (2) Proofs of the asymptotic convergence of the Stirling’s formula to n! for n → ∞ and related discussions have been presented in several references [3-15]. As such, the Stirling’s formula is typically used for approximating the factorial n! for very large values of n. However, its accuracy for relatively low values of n is limited and can be further improved also for high values of n. This paper recalls different approximations to the factorial leading to lower approximation errors than the Stirling’s formula for small and large values of n and compare their behavior for high and relatively low values of n. An original analytical formula with intermediate ISSN: 1790-5109 characteristics is proposed and included within the comparisons. ⎛ ζ b (n ) = ⎜⎜1 + ⎝ 1 ⎞ ⎟ b n ⎟⎠ (4) with b = 12. Another formulation uses an exponential correction function [5,9,19,20]: ζ e (n ) = eτ (n ) (5) The exponential correction function has been used by Robbins [5] to introduce suitable expressions to be used as lower and upper bounds to the factorial, by respectively using τ l (n ) = 273 1 1 and τ u (n ) = , such that: 12 n + 1 12 n ISBN: 978-960-474-128-1 Proceedings of the 8th WSEAS International Conference on EDUCATION and EDUCATIONAL TECHNOLOGY s (n ) τ l (n ) < n !< s (n ) τ u (n ) A variant to the lower boundary, τ l (n ) = for which all RAE values are nonnegative. For b > b* the RAE becomes negative for low values of n. Results of a more detailed analysis are shown in Fig. 3, where the maximum RAE is reported for different values of n in function of the parameter b. Fig. 3 shows that only the cases n = 1, n = 4 and n = 5 are involved in defining the maximum RAE as the parameter b changes. Let’s then compute the minimum value of the maximum RAE: (6) 1 3 12 n + 2 (2n + 1) , has been successively proposed by Maria [20]. Other approximations are built by modifying the structure of the Stirling’s formula. An example is g (n ) = n n e − n 2π n + q n f (n ) − n ! n! (8) Fig. 1 shows the RAE values reached by using the Stirling’s formula and other approximations introduced through Equations (3)-(4), Equation (5) with upper bound from [5] and lower bounds from [5] and [20], and Equation (7) with q = π/3. The results easily confirm that the approximated formulas exhibit much better characteristics and lower RAE than the Stirling’s formula, especially for low values of n. However, in all these cases the maximum RAE occurs for n = 1 and is significantly higher than the errors reached for higher values of n. The following section introduces and illustrates the characteristics of a novel continuous formula that improves the approximation accuracy in terms of limiting to a very low value the maximum RAE over the entire range of numbers n ∈ ℵ. ] [ (10) n− 1 2 e −n (11) The formulation of Equation (11) merges the simplicity of representation with a very low value of the maximum RAE and with RAE values always nonnegative for n ∈ ℵ. The latter property allows for using Equation (11) as an upper bound of the factorial for any n ∈ ℵ. The asymptotic convergence of ν(n) to n! for n → ∞ is guaranteed by the fact that ζ b (n ) tends to unity for n → ∞ and by the existing proof of convergence of the Stirling’s formula to n! for n → ∞, such that lim [ν (n )] = lim [s(n )] = n ! 3 A novel continuous approximation to the factorial n→∞ (12) 4 Conclusions Among the various continuous approximations to the factorial, this paper has presented a novel simple formula leading to an improved approximation to the factorial by using an explicit continuous function. This formula shares the asymptotic properties of the classical Stirling’s formula and exhibits excellent performance for approximating the factorial in the entire range of the natural numbers. Its superiority with respect to the Stirling’s formula has been shown with numerical evidence. The relative approximation error reached with the proposed formula in the entire range of the natural numbers is always nonnegative and its maximum value (about 0.01%) is lower than the one reached by using other common continuous explicit functions as approximations to the factorial. Let us consider Equation (4), for which the maximum RAE is relatively low, as shown in Fig. 1, and let’s write the corresponding approximation function as (9) A parametric study carried out by changing the (real) value of the parameter b showed that the RAE is very sensitive to the value of b. Fig. 2 indicates some results. In 2π = 11.843, the RAE is the particular case b = b * = e − 2π null for n = 1 and the corresponding maximum RAE is 0.0102% (for n = 5). This case corresponds to the limit case ISSN: 1790-5109 }} { ν (n ) = e + (n − 1) 2π a n→∞ ψ b (n ) = ζ b (n ) s(n ) b % For n ∈ ℵ, ε min = 0.0085% occurs for n = 5 and b = b′ = 11.855. However, in this case the RAE values are negative for n < 3 and positive for n ≥ 3 (Fig. 2). Let us focus on the case with parameter b = b*, for which the RAE is always nonnegative and the maximum RAE is relatively close to its minimum value. By using Equation (2) and Equation (4) with b = b* and substituting into Equation (9), it is possible to represent the approximation to the factorial in a simple form, for n ∈ ℵ: corresponding for q = π/3 to the Gosper’s approximation reported in [21]. In order to evaluate the accuracy of the approximation to the factorial by using a function f(n), let’s define the relative approximation error (RAE), expressed in percent, as ε % (n, f (n )) = 100 { % ε min = min max ε % (n,ψ b (n )) (7) 274 ISBN: 978-960-474-128-1 Proceedings of the 8th WSEAS International Conference on EDUCATION and EDUCATIONAL TECHNOLOGY Exponential correction (upper bound from [5]) Exponential correction (lower bound from [20]) approximation Eq. (4) with b = 12 Exponential correction (lower bound from [5]) Gosper's approximation [21] Stirling's formula relative approximation error (%) 0.3 0.2 0.1 0 0 5 10 15 20 25 30 35 40 -0.1 -0.2 -0.3 -0.4 -0.5 natural number Fig. 1. Relative approximation errors for the Stirling’s formula and other approximations to the factorial. 0.1 relative approximation error (%) bb = 11.700 11.700 0.08 * 11.843(proposed) (proposed) bb* ==11.843 0.06 b' = 11.855 0.04 bb == 12.000 12.000 0.02 0 -10 -0.02 0 10 20 30 40 -0.04 -0.06 -0.08 -0.1 natural number Fig. 2. Relative approximation errors for different values of the parameter b. ISSN: 1790-5109 275 ISBN: 978-960-474-128-1 50 Proceedings of the 8th WSEAS International Conference on EDUCATION and EDUCATIONAL TECHNOLOGY absolute value of the relative approximation error (%) 0.025 0.02 maximum error 0.015 0.01 n =6 n =7 n =5 n =4 0.005 n =1 n =3 n =2 0 11.81 11.82 11.83 11.84 11.85 11.86 11.87 parameter b Fig. 3. Absolute values of the relative approximation error. [12] N.G. de Bruijn, Asymptotic Methods in Analysis, Dover, New York, 1981. [13] P. Diaconis and D. Freedman, An Elementary Proof of Stirling's Formula, American Math. Monthly, Vol. 93, 1986, pp. 123-125. [14] C.R. Blyth and P.K. Pathak, A Note on Easy Proofs of Stirling's Theorem, American Math. Monthly, Vol. 93, 1986, pp. 376-379. [15] J.M. Patin, A Very Short Proof of Stirling's Formula, American Math. Monthly, Vol. 96, 1989, 41-42. [16] M. Abramowitz and I.A. Stegun (editors), Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, Dover, New York, 1974. [17] V. Namias, A Simple Derivation of Stirling's Asymptotic Series, American Math. Monthly, Vol. 93, 1986, pp. 25-29. [18] G. Marsaglia and J.C.W. Marsaglia, A New Derivation of Stirling's Approximation to n!, American Math. Monthly, Vol. 97, 1990, pp. 826-829. [19] T.S. Nanjundiah, Note on Stirling's Formula, American Math. Monthly, Vol. 66, 1959, 701-703. [20] A.J. Maria, A Remark on Stirling's Formula, American Math. Monthly, Vol. 72, 1965, pp. 1096-1098. [21] E.W. Weisstein, Stirling’s Approximation, Web site http://mathworld.wolfram.com/StirlingsApproximation .html. References: [1] D. Wells, The Penguin Dictionary of Curious and Interesting Numbers, Penguin Books, Middlesex, England, 1986, p. 45. [2] A. de Moivre, Miscellanea Analytica de Seriebus et Quadraturis, London, 1730. [3] J. Stirling, Methodus Differentialis, London, 1730. [4] M.I. Aissen, Some remarks on Stirling formula, American Math. Monthly, Vol. 61, 1954, pp. 687-691. [5] H. Robbins, A Remark on Stirling’s Formula, American Math. Monthly, Vol. 62, 1955, pp. 26-29. [6] E.T. Whittaker and G. Robinson, Stirling’s Approximation to the Factorial, in The Calculus of Observations: A Treatise on Numerical Mathematics, Dover, New York, 1967, pp. 138-140. [7] W. Feller, A Direct Proof of Stirling's Formula, American Math. Monthly, Vol. 74, 1967, pp. 12231225. [8] W. Feller, Correction to "A Direct Proof of Stirling's Formula", American Math. Monthly, Vol. 75, 1968, p. 518. [9] W. Feller, Stirling’s Formula, in An Introduction to Probability Theory and its Applications, Vol.1, Wiley, New York, 1968, pp. 50-53. [10] R.A. Khan, A Probabilistic Proof of Stirling's Formula, American Math. Monthly, Vol. 81, 1974, pp. 366-369. [11] M. Woodrofe, Probability Theory with Applications, McGraw-Hill, New York, 1975, pp. 127-128. ISSN: 1790-5109 276 ISBN: 978-960-474-128-1
© Copyright 2026 Paperzz