Asymptotic Notation

advertisement
Closed form for n!
Mathematics for Computer Science
MIT 6.042J/18.062J
Asymptotic
Notation
Albert R Meyer,
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)
April 7, 2010
lec 9W.1
Closed form for n!
Albert R Meyer,
April 7, 2010
lec 9W.2
Closed form for n!
n
n
n ln + 1 ln(i)
e
Integral Method to bound
i=1
ln n
…
ln 5
ln 4
ln 3
ln 2
ln 2
1
2
n + 1
+ 0.6
(n + 1)ln
e reminder:
ln(x)
ln(x+1)
ln 3 ln 4
3
ln 5
4
Albert R Meyer,
…
5
ln
ln n
n-1
n–2
n–1
April 7, 2010
n
lec 9W.3
Closed form for n!
Albert R Meyer,
April 7, 2010
lec 9W.5
Stirling’s Formula
A precise approximation:
n! ~
exponentiating:
Albert R Meyer,
April 7, 2010
lec 9W.6
n
2n e
Albert R Meyer,
April 7, 2010
n
lec 9W.7
1
Little Oh:
o(·) Oh
Little
Little Oh:
n2 = o(n3 )
Asymptotically smaller :
Def: f(n) = o(g(n))
iff
because
n2
1
lim 3 = lim = 0
n n
n n
f(n)
lim
=0
n g(n)
Albert R Meyer,
Big Oh:
O(·)
Big
April 7, 2010
o(·)
Albert R Meyer,
lec 9W.13
Oh
April 7, 2010
lec 9W.14
Big Oh: O(·)
Asymptotic Order of Growth:
f(n) = O(g(n))
because
3n2
lim 2 = 3 < n n
f(n) limsup <
n g(n) a technicality -- ignore now
Albert R Meyer,
April 7, 2010
Same Order of Growth:
f ~ g:
f = o(g):
f = O(g):
f = (g):
f(n) = (g(n))
Def: f(n)=O(g(n))
and
g(n)=O(f(n))
April 7, 2010
April 7, 2010
lec 9W.16
Asymptotics: Intuitive
Summary
Theta: (·)
Albert R Meyer,
Albert R Meyer,
lec 9W.15
lec 9W.17
f & g nearly equal
f much less than g
f roughly g
f & g roughly equal
Albert R Meyer,
April 7, 2010
lec 9W.18
2
The Oh’s
The Oh’s
lemma:
If f = o(g) or f ~ g, then f = O(g)
lim = 0 or lim = 1 IMPLIES lim <
Albert R Meyer,
April 7, 2010
Big Oh:
If f = o(g), then g O(f)
lim
log
scale
c,n0 nn0.
f(n) c·g(n)
April 7, 2010
Albert R Meyer,
c· g(x)
f(x)
no
o(·)
April 7, 2010
Little Oh:
lec 9W.23
o(·)
Lemma:
1
0
xb-a
April 7, 2010
green stays
below purple
from here on
Albert R Meyer,
lec 9W.22
and b - a > 0
so as x ,
lec 9W.21
O(·)
ln c
xa = o(xb) for a < b
Proof:
April 7, 2010
f(x) = O(g(x))
f(n) = O(g(n))
Lemma:
= lim
Big Oh:
O(·)
Little Oh:
IMPLIES
Albert R Meyer,
lec 9W.19
Equivalent definition:
Albert R Meyer,
=0
lec 9W.24
ln x = o(x)
for > 0.
Albert R Meyer,
April 7, 2010
lec 9W.25
3
Little Oh:
o(·)
Little Oh:
Lemma:
proofs:
L’Hopital’s Rule,
McLaurin Series
(see a Calculus text)
xn = o(ax)
for a > 1.
Albert R Meyer,
April 7, 2010
lec 9W.29
“· = O(·)” defines a relation
Don’t write O(g) = f.
Otherwise: x = O(x), so O(x) = x.
But 2x = O(x), so
2x = O(x) = x,
therefore
2x = x.
Nonsense!
April 7, 2010
Albert R Meyer,
April 7, 2010
lec 9W.30
Team Problems
Big Oh Mistakes
Albert R Meyer,
o(·)
lec 9W.31
Problems
14
Albert R Meyer,
April 7, 2010
lec 9W.35
4
MIT OpenCourseWare
http://ocw.mit.edu
6.042J / 18.062J Mathematics for Computer Science
Spring 2010
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
Download