Stirling’s Formula: Derivation and Applications

Research Article
Open access

Stirling’s Formula: Derivation and Applications

Wei Ni 1* , Ruohan Ye 2 , Ruiqi Yu 3
  • 1 Qingdao No. 2 High School of Shandong Province, 266061, China    
  • 2 Qingdao No.58 High School of Shandong Province, 266199,China    
  • 3 Qingdao No. 2 High School of Shandong Province 266061, China    
  • *corresponding author wei592727@gmail.com
ACE Vol.174
ISSN (Print): 2755-273X
ISSN (Online): 2755-2721
ISBN (Print): 978-1-80590-235-5
ISBN (Online): 978-1-80590-236-2

Abstract

In this paper, we take a closer look at Stirling’s formula, a method used to estimate factorials, particularly when nnn is large. Starting with its historical background, we then give a derivation using the Gamma function and examine how the formula behaves asymptotically. While it's a classic result in mathematics, we also discuss where it shows up in real-world problems—like signal processing, rubber-based materials, and even brain imaging. The way it links with Fourier transforms of the Gamma function shows how useful it is for interpreting patterns like power-law decay and frequency changes in signals.

Keywords:

Stirling’s approximation, Gamma function, asymptotic analysis, Fourier transform, signal processing, viscoelasticity, power-law decay, biomedical applications.

Ni,W.;Ye,R.;Yu,R. (2025). Stirling’s Formula: Derivation and Applications. Applied and Computational Engineering,174,46-60.
Export citation

1. Introduction

1.1. The history

Stirling’s formula, which is an important approximated tool for factorials and was introduced by James Stirling, who is a famous Scottish mathematician. This approximation gives a high efficient way to estimate factorials n! The positive number of variables that make it a good fit (the factorial of a positive integer n) using logarithmic and exponential functions. Because of its precise approximation for large values of n, the formula is widely used in many mathematic fields like probability theory and statistics.

The original form of Stirling’s formula was introduced in Stirling’s1730 treatise Methodus Differentialis, which use a logarithmic estimate for n!

ln(n!)nlnnn.

After that, this first result was improved to formula with higher- order correction terms, which makes a more accurate estimate for factorials

n!2πn(ne)n  as n

The addition of the  2πn  factor owed to Abraham de Moivre,, a current of Stirling who was working on probability theory about Stirling’s formula, especially about the approximation of binomial coefficients for large values n

The appearance of Stirling’s approximation was closely related to two mathematical advances during the 18th century: logarithmic theory developments and the Gamma function introduction,which expand factorial operations to non-integer values. Euler played an important role by his investigations of the Gamma function, with Gauss later providing more accurate and precise mathematical foundations for these asymptotic expressions.

During the derivation process, Wallis's infinite product expression was used. Stirling's innovative method constructed a continuous form, revealing an unexpected relationship between discrete factorial operations and transcendental numbers. This relationship astonished the mathematicians of that time. This breakthrough demonstrated the significant characteristics of mathematics in the Enlightenment era, namely the profound connection between continuous analysis and discrete mathematics.

In the 19th and 20th centuries, the application scope of this formula expanded significantly, covering various fields such as information theory, computational complexity analysis, statistical mechanics (especially in Boltzmann's entropy formula), and so on. Even today, this formula remains an important tool in asymptotic analysis, focusing on improving the accuracy of error estimation and conducting more extensive expansions.

1.2. Overview

Stirling’s formula serves as an approximation approach for factorials when the numbers involved become large. Although de Moivre was the first person who introduced a similar idea, the formula is more commonly relating to Stirling.Instead of relying on precise calculations, this method offers a practical way to make approximation to factorials, which proves useful in areas such as combinatorics, statistical mechanics, and probability. In this paper, we not only explore the derivation of Stirling’s formula but also reveal the connection between Stirling’s formula and the Fourier transform.

2. Derivation

2.1. Background knowledge

2.1.1. Proof of integral convergence

The Gamma function is defined by the integral:bounded above:  0<tx1et<tx1,t>0 

ϵ1tx1dt=[1xtx]ϵ1=1x(1εx) ϵ>0

If x> 0

ϵ1tx1dt=[1xtx]ϵ1=1x

Notice that 01tx1dt=  if x<0

By comparison  01tx1etdt  is finite

STEP2

1tx1etdt=lima1atx1etdt

When t is large,  01tx1etdt  is small. Because e−t decreases much more rapidly than tx−1 increases.

Precise: Maclaurin serves for  et 

et=1+t1!+t22!++tnn!

Pick n large enough : n ≥x + 1

et>tnn!et<n!tn

tx1et<n!txn1n!t2

1n!t2dt=n!limα1αt2dt=n!lima[1t]1a=n!lα(11a)n!<

Hence  1tx1etdt<  Γ(t) converges for every x> 0.

2.1.2. Γ(x) characterization

Γ(x) is uniquely characterized by: for x > 0

(1) Γ(1) =1 (2) Γ(x + 1) = x Γ(x) (3) Γ(x) is log convex

2.1.3. Proof of γ(x)

Proof of (1):

Through the definition of the Gamma function, we have:

Γ(1)=0t11etdt.

Since 1 −1 =0, this simplifies to:

Γ(1)=0t0etdt.

Since  t0  =1, we obtain:

Γ(1)=0etdt.

This is a standard integral, which evaluates to:

0etdt=1.

Thus, we conclude:

Γ(1)=1

Proof of (2):

Let x∈C with Re(x)> 0.The Gamma function is defined by:

Γ(x) = 0tx1etdt 

We aim to prove the recurrence relation:

Γ(x + 1) = x Γ(x)

We begin by writing:

Γ(x + 1) = 0txetdt 

Apply integration by parts. Let:

u=txdu=xtx1dt,dv=etdtv=et

Then:

Γ(x+1)=[txet]0+0xtx1etdt

We now analyze the boundary word  [txet]0  

As t→∞:

 txet=exlogtt0  since exponential decay dominates

As  t0+ :

 txettx0  since Re(x)> 0

Therefore:

[txet]0=0 

Thus:

Γ(x+1)=x0tx1etdt=xΓ(x) 

Γ(x+1)=xΓ(x)

Proof of (3)

The first step in establishing log-convexity is to calculate the derivatives of  lnΓ(x) :

[DiGamma and TriGamma Functions] The logarithmic derivative of the Gamma function which is known as the diGamma function ψ(x), and its derivative, the triGamma function ψ′(x), are given by:

ψ(x)=ddxlnΓ(x)=Γ(x)Γ(x)ψ(x)=d2dx2lnΓ(x)=Γ(x)Γ(x)(Γ(x)Γ(x))2

Using the integral definition of Γ(x),we can express these derivatives as:

Γ(x)=0tx1etlntdtΓ(x)=0tx1et(lnt)2dt

This gives us the following expressions:

ψ(x)=0tx1etlntdt0tx1etdtψ(x)=0tx1et(lnt)2dt0tx1etdt(0tx1etlntdt0tx1etdt)2

The non-negativity of ψ′(x) follows from the Cauchy-Schwarz inequality. Consider the inner product space of measurable functions on (0,∞) with weight function  tx1et 

f,g=0f(t)g(t)tx1etdt

Letting f(t) = lnt , g(t) =1, the Cauchy-Schwarz inequality show:

f,g2f,fg,g

Which translates to:

(0tx1etlntdt)2(0tx1et(lnt(0tx1etdt)

Dividing both sides by  (0tx1etlntdt)2  gives exactly

ψ′(x)≥0

Since  ψ(x)=d2dx2lnΓ(x)0  for all x>0,we conclude that lnΓ(x)is convex,and therefore Γ(x)is logarithmically convex on  (0,). 

2.2. Derivation of stirling’s formula

(1+1k)k<e<(1+1k)k+1

k=1n1(k+1k)k<en1<k=1n1(k+1k)k+1

LHS:(21)1(32)2(43)3(nn1)n1=nn1(n1)!

RHS:(21)2(32)3(43)4(nn1)n=nn(n1)!

so nn1(n1)!<en1<nn(n1)!

Rearrange and multiply by n

ennen<n!<enn+1en

Γ(x)=0tx1etdt,x>0

Γ(x)=(x1)!

 (x1)!  which is Γ(x) should be between  xx1ex and xxex 

let f(x)=xx12ex+μ(x) 

whereµ(x) is an error term and  xx12ex  is halfway between  xx1ex  and  xxex 

We’d like f(x) to satisfy 2) and 3), because then it would have to be a multiple of Γ(x)! Let’s calculate:

x=f(x+1)f(x)=(x+1)x+12ex1eμ(x+1)xx12exeμ(x)

x=x(1+1x)x+12e1eμ(x+1)μ(x)

Take in:

μ(x)μ(x+1)=(x+12)ln(1+1x)1 

Let g(x) =RHS

μ(x)=n=0g(x+n)

To establish it is convex , we have to find an upper bound.

If  |x|<1, ,then apply Taylor series:

ln(1+y)=yy22+y33

ln(1y)=yy22y33

 so ln(1+y1y)=2(y+y33+y55+) 

set y=12x+1

ln(1+y1y)=ln(2x+22x)=ln(1+1x)

so 12ln(1+1x)=12x+1+13(2x+1)3+15(2x+1)5+

g(x)=(x+12)ln(1+1x)1=1(2x+1)2(13+15(2x+1)2+17(2x+1)4+)

so 0<g(x)<13(2x+1)2(1+1(2x+1)2+1(2x+1)4+)

(1+1(2x+1)2+1(2x+1)4+)=111(2x+1)2=(2x+1)24x(x+1)

0<g(x)<112(1x1x+1),x>0

0<n=0g(x+n)<μ(x)=n=1(1x1x+1)=112x

0<μ(x)<112x

It means these series converge

So with this choice of µ(x), the function  f(x)=xx12exeμ(x)  satisfies the factorial property

 f(x+1)=xf(x) 

So we want to prove the function

f(x)=xx12ex+μ(x)

,where  μ(x)=n=0g(n)  and g(x)=(x+12)ln(1+1x) 

is log convex. We have

lnf(x)=(x12)lnxx+μ(x).

We want to show that ln f(x) is convex.

Since the second derivative is 0, the total of the convex functions is convex (because the latter is defined by convexity).

1. –x is convex, as its second derivative is 0.

2. For  (x12)lnx 

[(x12)lnx]=lnx+(x1x=lnx+112x.

The second derivative is:

[lnx+112x]=1x+12x2>0forx>0.

3.µ(x) is the sum of translates of g(x),so it is convex if g(x) is convex. Proof that g′′(x)>0 for x>0 Let

g(x)=(x+12)ln(1+1x)1.

Using the product rule:

g(x)=ln(1+1x)+(x+12)ddx[ln(1+1x)].

Compute the derivative:

ddx[ln(1+1x)]=1/x21+1/x=1x(x+1)

Thus:

g(x)=ln(1+1x)x+12x(x+1).

Differentiate g′(x):

g(x)=ddx[ln(1+1x)ddx[x+12x(x+1)].

The first term is:

ddxln(1+1x)]=1x(x+1).

For the second term,use the quotient rule:

ddx[x+12x(x+1)]=(1)x(x+1)(x+12)(2x+1)x2(x+1)2.

Expand the numerator:

x(x+1)(x+12)(2x+1)=x2+x(2x2+x+x+12)=x2x12.

Thus:

ddx[x+12x(x+1)]=x2x12x2(x+1)2.

Now combine the terms:

g(x)=1x(x+1)(x2x12x2(x+1)2)=1x(x+1)+x2+x+12x2(x+1)2.

Simplify:

g(x)=(x+1)(x2+x+12)+(x2+x+12)x2(x+1)2=12x2(x+1)2=12x2(x+1)2.

For all x> 0:

x2>0,(x+1)2>0

so:

g(x)=12x2(x+1)2>0.

Thus it is log convex

But this means Γ(x) must be a multiple of f(x):

Γ(x)=αf(x)=αxx12ex+μ(x)=αxx12ex+θ12x.

so we have to compute α

y=xnex

By calculus.We find the maximum value at x = n by  y=nxn1ex+xn(ex) 

y=0

xn1ex(nx)=0

x=n

Inflections points at  x=n+n,x=nn 

y=n(n1)xn2ex+nxn1(ex)+(n)xn1ex+xnex=n(n1)xn2ex2nxn1ex+xnex

y=0

exxn2[n(n1)+x22nx]=0

x22nx+n(n1)=0

x=2n±2n2=n±n.

Because the shape of  y=xnex  is similar to normal distribution analog μn,σn 

So we change of variable  t=xnnx=tn+n 

n!=0xnexdx=n(n+tn)ne(tn+n)ndt.

=nnnenn(1+tn)nentdt

n! is equal to n!

α=n(1+tn)nentdt

 wen n, for eac t (1+tn)nent

et22

et22dt

α=I=et22dt

I2=et22dtes22ds

t=rcosθs=rsinθ

I2=02π0er22rdrdθ

I2=02πdθ0er22rdr

=2π

α=I=2π

α=2π

2.3. Theorem (stirling’s formula)

For x>0:

Γ(x)=2πxx12ex+θ12x,0<θ<1 depends on x

n!=2πnn+12en+θ12n.

2.4. Stirling’s approximation

When n is large:

n!2πnn+12en=2πn(ne)n

3. Fourier transform

3.1. Fourier transform of xz−1e−x and relation to the Gamma function

3.1.1. Corrected derivation

There is no direct correlation between the function f(x)=xz1ex and the Gamma function  Γ(z) , so the  f(x)=xz1ex should be related with the Fourier transform.

Here is the revised derivation:

3.1.2. Fourier transform of f(x)

The single-sided Fourier transform of f(x) is:

F{f(x)}(ω)=0xz1exeiωxdx.

3.1.3. Simplification

Combine the exponential terms:

F{f(x)}(ω)=0xz1e(1+iω)xdx.

3.1.4. Connection to the Gamma function

Recognize this as a Gamma function with a modified parameter:

F{f(x)}(ω)=Γ(z)(1+iω)z

3.1.5. Double integral interpretation

To directly write a double integral(if required),relate the Gamma function and Fourth Fourier Transform:

Γ(z)=0xz1exdxF{f(x)}(ω)=0(eiωxdω)xz1exdx.

However, this is merely symbolic; the rigorous result is given by the closed-form expression

Γ(z)(1+iω)z

4. Derivation of the complex fourier series

The Fourier series’ complicated exponential form, f(t)=n=Cneinω0t,is derived below.

4.1. Trigonometric fourier series

A periodic function f(t) which has period T can be written in the form:

f(t)=a0+n=1(ancos(nω0t)+bnsin(nω0t))

Where ω0=2πT ,and the coefficient are

an=2TT/2T/2f(t)cos(nω0t)dt,bn=2TT/2T/2f(t)sin(nω0t)dt.

4.2. Complex exponential conversion

Using the formula of Euler’s, which  eix=cosx+isinx , write the following trigonometric functions:

cos(nω0t)=einω0t+einω0t2,sin(nω0t)=einω0teinω0t2i.

4.3. Combining terms

Substitute the exponential forms in to the trigonometric series:

f(t)=a0+n=1(aneinω0t+einω0t2+bneinω0teinω0t2i)

Combine coefficients into  Cn :

C0=a0,Cn=anibn2,Cn=an+ibn2(n1).

The final complex Fourier series becomes:

f(t)=n=Cneinω0t

With coefficients:

Cn=1TT/2T/2f(t)einω0tdt

Assuming that the fundamental frequency is  ω0  , the Fourier series can be stated as follows; the Fourier series representation of a periodic function is as follows:

(1)

Where the coefficients  Cn  are calculated as:

(2)

4.3.1. Extension to non-periodic functions

In the case of non-periodic functions, we consider them as the limiting case of periodic functions with T . Combining Equations (1) and (2):

(3)

Let  ω=nω0 , where as the causes are frequency interval becomes: Δω=(n+1)ω0nω0=ω0 

Using the period-frequency relationship  T=2πω0, Equation (3) can be rewritten as:

(3')

Rearranging constants and simplifying:

(4)

As  T:

Δωdω,ω

The discrete summation in Equation(4) transforms into a continuous Riemann integral:

(5)

Thus,

F(ω)=f(t)eiωtdt

4.4. Gamma function and its fourier transform

4.4.1. Relationship between exponential frequency modulated signal and Gamma function

An exponential frequency modulated (FM) signal can be stated as follows:

s(t)=Aejϕ(t)

Where the phase  ϕ(t)  is given by:

ϕ(t)=2πf0eαt1α

The Fourier transform of an exponentially frequency modulated signal can be used in some circumstances to include integrals of the form:

0eaxxbdx

Which can be expressed using the Gamma function. The Gamma function is defined as:

Γ(z)=0xz1exdx,Re(Z)>0

For  sC  with  (s)>0 :

Γ(s)=0ts1etdt,were ts1=e(s1)lnt

4.5. Fourier transform of the Gamma function

We test the integral in order to calculate its Fourier transform:

F(ω)=0xz1exeiωxdx

Combining the exponential terms:

F(ω)=0xz1e(1+iω)xdx

4.6. Variable substitution

Using the substitution  u=(1+iω)x , the integral simplifies to

F(ω)=(1+iω)zΓ(z)

4.6.1. Detailed substitution steps

Assume that  u=(1+iω)x , then  du=(1+iω)dx  or  dx=du1+iω  substituting the element in the integral:

F(ω)=0(u1+iω)z1eudu1+iω

F(ω)=(1+iω)z0uz1eudu=(1+iω)zΓ(z)

4.7. Asymptotic behavior for large z

For large z, Stirling’s approximation provides:

Γ(z)2πz(ze)z

5. Application in signal processing

5.1. Power-law decay in signals

The Fourier transform  F(ω)=(1+iω)zΓ(z) models power-law decay in signals.

For instance,in viscoelastic materials,this describes stress relaxation with a memory kernel proportional to tz1 .

5.1.1. Example1: polymer melts (natural rubber)

For polyisoprene rubber,stress relaxation under step strain follows:  σ(t)tz1,z(0,1) . The memory kernel ’ s Fourier transform matches the given expression [1].

5.1.2. Example2: automotive rubber dampers

Stress relaxation in car suspension components follows:

σ(t)=σ0Ez((t/τ)z)

Where  Ez((t/τ)z)  is the Mittag-Leffler function [2].

5.1.3. Example3: chewing gum viscoelasticity

Experimental measurements show:

G(t)=G0(t/t0)0.3

Matching the model when  z=0.7[3].

5.2. Communication systems

In order to improve the anti-interference ability and integrity of the signal, EFM signals are adopted in wireless communication. According to [4], in mobile communications, frequency modulated signals improve spectral efficiency and may reduce the impact of multi-path fading.

5.3. Radar systems

Radar systems use RFW (RF) wave forms to enhance target detection and resolution. This paper discusses the application of frequency-modulated continuous wave (FMCW) radar through [5], which often uses exponentially chirped signals to achieve better range resolution and clutter suppression.

5.4. Biomedical signal processing

In biomedical engineering, EFM signals are applied in medical imaging and neural signal analysis. Study [6] explores the use of frequency-modulated signals in functional magnetic resonance imaging (fMRI) to improve brain activity mapping.


References

[1]. Bagley, R.L., & Torvik, P.J.(1983).Fractional calculus—a different approach to the analysis of viscoelastically damped structures.AIAA Journal, 21(5), 741-748.

[2]. Metzler, R., Schick, W., Kilian, H. G., & Nonnenmacher, T.F.(1994). Generalized viscoelastic models: Their fractional equations with solutions. The Journal of Chemical Physics, 103(16), 7180-7186.

[3]. Stankovic, J., & Pajic-Lijakovic, I.(2020).Chewing gum rheology: Power-lawrelaxationandtime-temperaturesuperposition.Food Hydrocolloids, 102, 105591.

[4]. J.G.Proakis and M.Salehi, Digital Communications, 5thed., McGraw-Hill, 2007.

[5]. M.I. Skolnik, Radar Handbook, 3rded., McGraw-Hill, 2008.

[6]. A.Metin and C.Glover, "Frequency Modulated fMRI Signal Analysis, "NeuroImage, vol.150, pp.120-135, 2017.


Cite this article

Ni,W.;Ye,R.;Yu,R. (2025). Stirling’s Formula: Derivation and Applications. Applied and Computational Engineering,174,46-60.

Data availability

The datasets used and/or analyzed during the current study will be available from the authors upon reasonable request.

Disclaimer/Publisher's Note

The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of EWA Publishing and/or the editor(s). EWA Publishing and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

About volume

Volume title: Proceedings of CONF-CDS 2025 Symposium: Data Visualization Methods for Evaluatio

ISBN:978-1-80590-235-5(Print) / 978-1-80590-236-2(Online)
Editor:Marwan Omar, Elisavet Andrikopoulou
Conference date: 30 July 2025
Series: Applied and Computational Engineering
Volume number: Vol.174
ISSN:2755-2721(Print) / 2755-273X(Online)

© 2024 by the author(s). Licensee EWA Publishing, Oxford, UK. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license. Authors who publish this series agree to the following terms:
1. Authors retain copyright and grant the series right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this series.
2. Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the series's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial publication in this series.
3. Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See Open access policy for details).

References

[1]. Bagley, R.L., & Torvik, P.J.(1983).Fractional calculus—a different approach to the analysis of viscoelastically damped structures.AIAA Journal, 21(5), 741-748.

[2]. Metzler, R., Schick, W., Kilian, H. G., & Nonnenmacher, T.F.(1994). Generalized viscoelastic models: Their fractional equations with solutions. The Journal of Chemical Physics, 103(16), 7180-7186.

[3]. Stankovic, J., & Pajic-Lijakovic, I.(2020).Chewing gum rheology: Power-lawrelaxationandtime-temperaturesuperposition.Food Hydrocolloids, 102, 105591.

[4]. J.G.Proakis and M.Salehi, Digital Communications, 5thed., McGraw-Hill, 2007.

[5]. M.I. Skolnik, Radar Handbook, 3rded., McGraw-Hill, 2008.

[6]. A.Metin and C.Glover, "Frequency Modulated fMRI Signal Analysis, "NeuroImage, vol.150, pp.120-135, 2017.