Contents
Deep Breakdown
What it tells me (Situation Awareness): This limit defines Euler's number . It is the base of natural logarithms and the natural base for exponential growth/decay. The form represents steps of compounding a return of , totaling an initial return of 1 — and as the number of compounding steps grows to infinity, the result converges to . Equivalent form: (discrete version). This limit is foundational for continuous compounding in finance, the exponential distribution in ML (Poisson processes, survival analysis), and for proving that and . In ML: the Boltzmann factor in softmax and simulated annealing; the normalization constant in Gaussian and exponential family distributions; the natural base of cross-entropy loss.
Flowchart
Real-world use
Where it is used
Continuous compounding formula: , derived from ; exponential distribution CDF — the base rate comes from this limit; softmax temperature: as converges to argmax and as to uniform — both via the exponential ; natural logarithm has derivative because ; proof that is unique among all bases.
Problem it solves
What happens when interest is compounded infinitely frequently? Or what is the "natural" base for exponential growth where the function equals its own derivative? Both questions lead to the number , and this limit is its original definition.
How it solves the problem
Each step: compound at rate for steps. Product of identical factors . As (infinitely many infinitesimally small compounding steps), the product converges to . The limit resolves the indeterminate form by taking logs and applying L'Hôpital.
Example in a business
A DS models customer churn using a survival function (exponential survival model). The rate is estimated by MLE. The probability of surviving beyond steps when per-step hazard is for steps is as — directly using this limit (with replaced by ). The continuous-time model is the limit of the discrete model.
The formula, piece by piece
- : the growth factor per step (1 unit return of )
- : number of compounding periods (steps), going to
- : compound growth over steps
- : Euler's number,
- Equivalent forms: ; ;
- General:
- Indeterminate form: — the base , but the exponent ; neither alone gives the answer
The formula in words
"If you compound a tiny growth rate over periods, and let the number of periods go to infinity (making each step infinitesimally small), the total growth converges to Euler's number ." Tiny trace: : . : . : . :
Critical Concepts
- The natural base is unique: is the unique base for which (derivative equals itself). For any other base : . The factor only when . This is why is "natural" — it simplifies calculus.
- Connection to the exponential function: . This is the same limit with replaced by . It provides an alternative definition of the exponential function via iterated compounding. In numerical work: for very large or very small ,
np.exp(x)is more stable than trying to compute for large . - Continuous vs. discrete compounding: discrete: ; continuous: . The difference: daily compounding () gives , which is close to but not equal. Continuous compounding is the limit. In ML: exponential decay is the continuous-time limit of geometric decay .
- The number appears naturally in probability: for independent Bernoulli trials with , the probability of zero successes is as . This is the limiting probability in a Poisson process with rate 1 over unit time. Poisson distribution: — the normalization comes from this limit.
- Numerical convergence: the sequence converges to from below.
It converges slowly: even at , the error is . A better approximation: . In practice, always use math.e or np.e (or exp(1)) rather than computing this limit.
Step-by-step calculation (tiny example)
Evaluate .
Step 1: Recognize the general form. .
Step 2: Use the standard limit with , . (from general form with ).
Step 3: Apply power. . Verify: at : .
Code examples
Beginner example (Python)
import numpy as np
E_VALUE = np.e # 2.718281828459045
print("Standard Limit: lim_{x->inf}(1 + 1/x)^x = e")
print(f"\ne = {E_VALUE:.10f}")
print(f"\n{'n':>10} {'(1+1/n)^n':>14} {'Error from e':>14}")
for n in [1, 2, 5, 10, 100, 1_000, 10_000, 100_000, 1_000_000]:
val = (1 + 1/n)**n
error = abs(val - E_VALUE)
print(f"{n:>10} {val:>14.9f} {error:>14.2e}") # Generalization: lim(1 + a/x)^(bx) = e^(ab)
print(f"\n--- General form: lim_{{x->inf}}(1+a/x)^(bx) = e^(ab) ---")
print(f"{'a':>5} {'b':>5} {'e^(ab)':>10} {'(1+a/1e6)^(b*1e6)':>20}")
for a, b in [(1, 1), (2, 1), (1, 3), (-0.5, 2), (0.1, 10)]:
x = 1_000_000
numerical = (1 + a/x)**(b*x)
analytic = np.exp(a * b)
print(f"{a:>5.2f} {b:>5.2f} {analytic:>10.5f} {numerical:>20.5f}") # Continuous vs discrete compounding
print(f"\n--- Continuous compounding: A = P*e^(rt), P=1000, r=0.05, t=10 ---")
P, r, t_fin = 1000.0, 0.05, 10.0
continuous = P * np.exp(r * t_fin)
print(f"Continuous: A = {continuous:.4f}")
for n in [1, 4, 12, 52, 365, 8760]:
discrete = P * (1 + r/n)**(n * t_fin)
print(f" n={n:>5} periods/year: A = {discrete:.4f} (diff from continuous: {continuous-discrete:.4f})")Beginner example (R)
# Standard limit: lim_{n->inf}(1 + 1/n)^n = e
cat("Standard Limit: lim_{n->inf}(1 + 1/n)^n = e\n")
cat(sprintf("e = %.10f\n\n", exp(1)))
cat(sprintf("%-10s %-14s %-14s\n", "n", "(1+1/n)^n", "Error from e"))
for (n in c(1, 2, 5, 10, 100, 1000, 10000, 1000000)) { val <- (1 + 1/n)^n
error <- abs(val - exp(1))
cat(sprintf("%-10d %-14.9f %-14.2e\n", n, val, error))
} # General form: lim(1 + a/x)^(bx) = e^(ab)
cat("\nGeneral form: lim_{x->inf}(1+a/x)^(bx) = e^(ab)\n")
cat(sprintf("%-5s %-5s %-10s %-20s\n", "a", "b", "e^(ab)", "numerical (x=1e6)"))
params <- list(c(1,1), c(2,1), c(1,3), c(-0.5,2), c(0.1,10))
for (ab in params) { a <- ab[1]; b <- ab[2]
x <- 1e6
numerical <- (1 + a/x)^(b*x)
analytic <- exp(a * b)
cat(sprintf("%-5.2f %-5.2f %-10.5f %-20.5f\n", a, b, analytic, numerical))
}Professional example (Python)
import numpy as np
from sklearn.preprocessing import StandardScaler
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
np.random.seed(42) # -- Euler's number limit: exponential survival analysis (Kaplan-Meier approximation) --
# Use case: A DS models customer churn with an exponential survival model.
# The continuous-time survival function S(t) = e^(-lambda*t) is the limit
# of discrete survival: (1 - lambda/n)^(n*t) as n -> infinity.
# We show numerically that increasingly fine discrete models converge to e^(-lambda*t).
LAMBDA = 0.3 # churn rate per unit time
T_VALS = [1.0, 2.0, 5.0]
N_STEPS = [1, 2, 5, 10, 50, 100, 1000]
def discrete_survival(lam: float, t: float, n: int) -> float:
"""(1 - lam/n)^(n*t): discrete survival with n sub-periods per unit time."""
return (1.0 - lam / n) ** (n * t)
def continuous_survival(lam: float, t: float) -> float:
"""e^(-lam*t): continuous-time exponential survival."""
return float(np.exp(-lam * t))
print("Euler's Number Limit: Discrete -> Continuous Survival Model")
print(f"\nExponential survival model: S(t) = e^(-lambda*t), lambda = {LAMBDA}")
print(f"Discrete model: (1 - lambda/n)^(n*t) --> e^(-lambda*t) as n -> inf")
print(f"\nThis uses: lim_{{n->inf}}(1 + a/n)^n = e^a with a = -lambda*t\n")
for t in T_VALS:
s_continuous = continuous_survival(LAMBDA, t)
print(f"t = {t} --> S_continuous = e^(-{LAMBDA}*{t}) = e^(-{LAMBDA*t}) = {s_continuous:.6f}")
print(f" {'n':>8} {'S_discrete':>12} {'Error':>12}")
for n in N_STEPS:
s_disc = discrete_survival(LAMBDA, t, n)
error = abs(s_disc - s_continuous)
print(f" {n:>8} {s_disc:>12.6f} {error:>12.2e}")
print() # Error convergence: show O(1/n) convergence rate
print("Convergence rate: |S_discrete - S_continuous| ~ C/n (first-order in 1/n)")
t_demo = 1.0
s_cont = continuous_survival(LAMBDA, t_demo)
for n in [10, 100, 1000, 10000]:
err = abs(discrete_survival(LAMBDA, t_demo, n) - s_cont)
print(f" n = {n:>6}: error = {err:.2e} (n*error = {n*err:.4f} should be approx const)")Source: 1300 p. 217