ABSTRACT

Factorials () grow extremely fast, making them difficult to compute directly for large . Stirling’s Approximation provides a way to estimate these values using continuous functions, while recursive partitioning helps us understand their combinatorial origin in permutations.


1. Stirling’s Approximation

When analyzing algorithm complexity (especially in Asymptotic Notation), we often need a “smooth” function to represent . Stirling’s formula provides a precise approximation:

Accuracy Comparison

As increases, the relative error of the approximation decreases, making it invaluable for large-scale system analysis.

nn! (Actual)Stirling’s ApproximationRelative Error
110.92~8.0%
5120118.02~1.6%
103,628,8003,598,695.62~0.8%

IMPORTANT

Because this is an approximation, it is not a closed-form equivalent for discrete calculations, but it is used to prove that .


2. Permutations: The Combinatorial Origin

To understand why appears in algorithms, we look at the number of ways to arrange a set of size , denoted as .

Recursive Partitioning

We can calculate by partitioning the set of all permutations based on their starting element. For a set :

  1. There are possible starting elements.
  2. Once the first element is chosen, we must arrange the remaining elements.
  3. This creates the recurrence relation: .

Unraveling the Recurrence

By “unrolling” this recursive definition, we arrive at the factorial:

(Note: By convention, , representing the single way to arrange an empty set.)


3. Computational Impact

In Runtime of Algorithms, factorials represent a “complexity wall.”

  • Polynomial Time: is usually manageable.
  • Factorial Time: is catastrophic. Even for , is approximately . On a 1 GHz processor, an algorithm would take over 70 years to complete for .

4. Connection to Other Identities

The factorial is the backbone of many Binomial Identities:

  • Symmetry Identity: Uses factorials to show .
  • r-Permutations: Defines the number of ways to pick and arrange elements from as .