09.12.2012 Views

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

436 ASYMPTOTICS<br />

9.3 0 MANIPULATION<br />

Like any mathematical <strong>for</strong>malism, the O-notation has rules of manipulation<br />

that free us from the grungy details of its definition. Once we<br />

prove that the rules are correct, using the definition, we can hence<strong>for</strong>th work<br />

on a higher plane and <strong>for</strong>get about actually verifying that one set of functions<br />

is contained in another. We don’t even need to calculate the constants C that The secret of beinn<br />

are implied by each 0, as long as we follow rules that guarantee the existence a bore is to tell<br />

everything.<br />

of such constants.<br />

- Voltaire<br />

For example, we can prove once and <strong>for</strong> all that<br />

nm = O(n”‘), when m 6 m’;<br />

O(f(n)) +0(9(n)) = O(lf(n)l+ lg(n)l) .<br />

(9.21)<br />

(9.22)<br />

Then we can sayimmediateby that $n3+in2+in = O(n3)+O(n3)+O(n3) =<br />

O(n3), without the laborious calculations in the previous section.<br />

Here are some more rules that follow easily from the definition:<br />

f(n) = O(f(n)) ;<br />

c. O(f(n)) = O(f(n)) ,<br />

O(O(f(n))) = 0(+(n)) ;<br />

O(f(n))O(g(n)) = O(f(n)s(n)) ;<br />

O(f(n) s(n)) = f(n)O(s(n)) .<br />

if c is constant;<br />

(9.23)<br />

(9.24)<br />

(9.25)<br />

(9.26)<br />

(9.27)<br />

Exercise 9 proves (g.22), and the proofs of the others are similar. We can<br />

always replace something of the <strong>for</strong>m on the left by what’s on the right,<br />

regardless of the side conditions on the variable n.<br />

Equations (9.27) and (9.23) allow us to derive the identity O(f(n)2) =<br />

0 (f(n)) 2. This sometimes helps avoid parentheses, since we can write<br />

O(logn)’ instead of O((logn)2).<br />

Both of these are preferable to ‘O(log2 n)‘, which is ambiguous because some<br />

authors use it to mean ‘O(loglogn)‘.<br />

Can we also write<br />

0 (log n) -- ’ instead Iof O((logn))‘) ?<br />

(Note: The <strong>for</strong>mula<br />

O(f(n))2 does not<br />

denote the set of<br />

all functions g(n)’<br />

where g(n) is in<br />

O(f(n)); such<br />

functions g(n)2<br />

cannot be negative,<br />

but the set<br />

O(f(n))’ includes<br />

negative functions.<br />

In genera/, when<br />

S is a set, the notation<br />

S2 stands<br />

<strong>for</strong> the set of all<br />

No! This is an abuse of notation, since the set of functions l/O(logn) is<br />

neither a subset nor a superset of 0 (1 /log n). We could legitimately substitute<br />

fI(logn)--’ <strong>for</strong> 0 ((logn)-‘), but this would be awkward. So we’ll restrict our<br />

products s’s2 with<br />

sl and s2 in S,<br />

not <strong>for</strong> the set of<br />

all squares Sz w;th<br />

use of “exponents outside the 0” to constant, positive integer exponents. s E S.)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!