Asymptotics & Stirling’s Approximation Mathematics for Computer Science MIT 6.042J/18.062J Asymptotics & Stirling’s Approximation Copyright © Albert Meyer, 2002. Prof. Albert Meyer & Dr. Radhika Nagpal
Factorial defines a product: Integral Method Factorial defines a product: Turn product into a sum taking logs: ln(n!) = ln(1 · 2 · 3 · · · (n – 1) · n) = ln 1 + ln 2 +· · · + ln(n – 1) + ln(n) =
… bound by integral method Integral Method ln (x) … ln (x+1) ln ln n 2 3 1 4 5 n–2 n–1 n … ln (x+1) ln (x) … ln 2 ln 3 ln 4 ln 5 ln n-1 ln n
Integral Method Reminder:
Integral Method Bounds on ln(n!)
In-Class Problem Problem 1
Stirling’s Formula So
Stirling’s Formula A precise approximation: Stirling’s Formula
Asymptotic Equivalence f(n) ~ g(n)
Little Oh Asymptotically smaller: f(n) = o(g(n))
Big Oh Asymptotic Order of Growth: f(n) = O(g(n))
The Oh’s If f = o(g) or f ~ g then f = O(g) lim = 0 lim = 1 lim <
The Oh’s If f = o(g), then g O(f) lim = lim = 0
c,n0 0 n n0 |f(n)| c·g(n) Big Oh Equivalently, f(n) = O(g(n)) c,n0 0 n n0 |f(n)| c·g(n)
Asymptotic Notation f(x) = O(g(x)) +c c g(x) blue stays below red f(x)
Lemma: xa = o(xb) for a < b Little Oh Lemma: xa = o(xb) for a < b Proof: and b - a > 0. So as x , xb-a and .
Lemma: ln x = o(x) for > 0. Little Oh Lemma: ln x = o(x) for > 0. Proof: for z 1.
Lemma: ln x = o(x) for > 0. Little Oh Lemma: ln x = o(x) for > 0. Proof: Let for > .
f(n) = O(g(n)) and g(n) = O(f(n)) Theta Same Order of Growth: f(n) = (g(n)) f(n) = O(g(n)) and g(n) = O(f(n))
In-Class Problem Problems 2--4
Big Oh Mistakes False Lemma: Of course really
= n· O(1) = O(n). 0 = O(1), 1 = O(1), 2 = O(1),… So each i = O(1). So Big Oh Mistakes False Lemma: False Proof: 0 = O(1), 1 = O(1), 2 = O(1),… So each i = O(1). So = n· O(1) = O(n).
In-Class Problem Problem 5