I'm back! And today, we're going to be talking about how to apply calculus to solve big-oh notation type questions.
So, how would we prove that n is in O(2^n)?
Let's take a graphical look:
http://gyazo.com/50b4f15c85b4a932c322fb648be480d5
It seems that as x grows larger and larger, 2^x "overpowers" the rate of growth of n. So how can we formalize this "overpowering" factor? The way to do this comes from calculus. If 2^x grows much faster than x, then as x gets arbitrary large, 2^x/x would also get arbitrary large. So in calculus terms, the limit as x-> infinity of (2^x/x) must be infinity.
But that was just intuition, we need a proper definition of limit as x -> infinity of some f(x) = infinity, which would be: For all e in positive reals, there exists an n0 in naturals such that for every n in naturals greater than or equal to n0 would imply that 2n/n > e.
Side note: if the limit does exist for some f(x) (in other words the limit as x -> infinity of some f(x) = c), then the definition would be that for all e in positive reals, there exists an n0 in naturals such that for every n in naturals greater than or equal to n0 would imply that c-e<2n/n <c + e.
While this may seem wordy, it's just saying that as x gets arbitrarily large, it either grows without bounds, or that it is bounded.
So how does this help us solve something like n is in O(2^n)?
Well, we know that limit x -> infinity of n/2^n = 0.
Filling in our regular parameters for the definition of big-oh notation, which I remind you in the following.
g(n) is in O(f(n)) when:
There exists c in positive reals, there exists B in naturals such that for all natural n >= B => g(n) <= cf(n).
So here is the following proof for n in 2^n:
Assume B = 1, and c = 1.
Since we know that the limit is infinity, we can set e to be whatever we want, so I chose e = c.
Then there exists an n0 such that for every n >= n0 => n/2^n < 1
Let n0 be such that for every natural n >= n0 => 2^n/n > 1, and n' = max (B,n0) # I'll explain why we use the B later.
Then n' is in naturals, since it's either B, a natural, or n0, a natural.
Then n' >= B. This is why we use max (B,n0), so that we can satisfy the breakpoint condition of the original problem. If we didn't include B, then how would we know that n' >= B?
Then n < c*2^n, since n >0.
Then n' >= B and n' < 2^n' #since c = 1
Then there exists an n in naturals such that n >= B and g(n') < cf(n')
Then there exists c in positive real, there exists B in natural, for all n in natural, such that if n is greater than or equal to B then n <= c2^n
EDIT:
It's come to my attention that recently a lot of people (judging from the SLOGS) are having trouble with this idea of limits. Simply put, the idea is that at infinity, which one increases faster: f(x) or g(x) in f(x)/g(x)? If f(x), then the limit goes to infinity. If g(x), then the limit goes to 0. It's as simple as that.