Here is an asymptotic notation problem:
Let g(n) = 27n^2 + 18n and let f(n) = 0.5n^2 − 100. Find positive constants n0, c1 and c2 such that c1f(n) ≤ g(n) ≤ c2f(n) for all n ≥ n0.
Is this solving for theta? Do I prove 27n^2 + 18n = Ω(0.5n^2 − 100) and then prove (27n^2 + 18n) = O(0.5n^2 − 100)?
In that case wouldn't c1 and c2 be 1 and 56 respectively, and n0 would be the higher of the two n0 that I find?
There are infinitely many solutions. We just need to fiddle with algebra to find one.
The first thing to note is that both g and f are positive for all n≥15. In particular, g(15) = 6345, f(15) = 12.5. (All smaller values of n make f<0.) This implies n0=15 might work fine as well as any larger value.
Next note g'(n) = 54n + 18 and f'(n) = n.
Since f(15) < g(15) and f'(n) < g'(n) for all n >= 15, choose c1 = 1.
Proof that this is a good choice:
0.5n^2 − 100 ≤ 27n^2 + 18n <=> 26.5n^2 + 18n + 100 ≥ 0
...obviously true for all n≥15.
What about c2? First, we want c2*f(n) to grow at least as fast as g: c2f'(n)≥g'(n), or c2*n ≥ 54n + 18 for n ≥ 15. So choose c2 ≥ 56, which obviously makes this true.
Unfortunately, c2=56 doesn't quite work with n0 = 15. There's the other criterion to meet: c2*f(15)≥g(15). For that, 56 isn't big enough: 56*f(15) is only 700; g(15) is much bigger.
It turns out by substitution in the relation above and a bit more algebra that c2 = 508 does the trick.
Proof:
27n^2 + 18n ≤ 508 * (0.5n^2 − 100)
<=> 27n^2 + 18n ≤ 254n^2 − 50800
<=> 227n^2 - 18n - 50800 ≥ 0
At n=15, this is true by simple substitution. For all bigger values of n, note the lhs derivative 454n - 18 is positive for all n≥15, so the function is also non-decreasing over that domain. That makes the relation true as well.
To summarize, we've shown that n0=15, c1=1, and c2=508 is one solution.
Related
I was looking at this question:
Prove that 100𝑛+5 ∈ 𝑂(𝑛²) (Which is 100𝑛+5 is upper bounded by 𝑛²)
𝑓(𝑛) ≤ 𝑐𝑔(𝑛) for all 𝑛 ≥ 𝑛0
so it becomes 100𝑛+5 ≤ 𝑐𝑛²
The answer was:
𝑛0 ≈ 25.05 (the number where the 𝑛² algorithm intercepts the 𝑛 algorithm) and 𝑐 = 4 so that when 𝑛 increases above 25.05 no matter what it will
still prove that 100𝑛+5∈𝑂𝑛² is true
My question is: how do you derive that 𝑛0 = 25.05 and 𝑐 = 4? Is it a guess and trial method, or is there a proper way to get that particular answer? Or you just gotta start from 1 and work your way up to see if it works?
A good approach to tackle such kind of problems is to first fix the c
let's take 4 in this example
and then all you have to do is figure out n0 using a simple equality
100n + 5 = 4n^2 <=> 4n^2 - 100n - 5 = 0 <=> n = 25.05 or n = -0.05 and here you can remark that they intersect twice in -0.08 and 25.05 and as you want n0 such that after which 100n +5 is always below 4n^2 -0.05 is not the one as 25.05 > -0.05 and in 25.05 they intersect so n0 = 25.05 .
Before fixing c and trying to figure out n0 you could try big numbers for n0 to have an idea whether it's an upper bound or not.
There are infinitely many choices for n0 and c that can be used to prove this bound holds. We need to find n0 and c such that for n >= n0, f(n) <= c * g(n). In your case, we need 100n + 5 <= cn^2. We can rearrange this as follows using basic algebra:
cn^2 - 100n - 5 >= 0
We can use the quadratic formula to find the roots:
n1, n2 = [100 +- sqrt(10000 + 20c)]/2c
Because c is positive we know the sqrt term will be greater than 100 once evaluated and since we are only interested in n > 0 we can discard the smaller of these solutions and focus on this:
n0 = [100 + sqrt(10000 + 20c)]/2c
We can simplify this a bit:
n0 = [100 + sqrt(10000 + 20c)]/2c
= [100 + 2*sqrt(2500 + 5c)]/2c
= [50 + sqrt(2500 + 5c)]/c
At this point, we can choose either a value for c or a value for n0, and solve for the other one. Your example chooses c = 4 and gets the approximate answer n0 ~ 25.05. If we'd prefer to choose n0 directly (say we want n0 = 10) then we calculate as follows:
10 = [50 + sqrt(2500 + 5c)]/c
10c = 50 + sqrt(2500 + 5c)
(10c - 50) = sqrt(2500 + 5c)
(100c^2 - 1000c + 2500) = (2500 + 5c)
100c^2 - 1005c = 0
c(100c - 1005) = 0
c = 0 or c = 1005/100 ~ 10.05
Because the solution c=0 is obviously no good, the solution c ~ 10.05 appears to work for our choice of n0 = 10. You can choose other n0 or c and find the corresponding constant in this way.
I have a few asymptotic notation problems I do not entirely grasp.
So when proving asymptotic complexity, I understand the operations of finding a constant and the n0 term of which the notation will be true for. So, for example:
Prove 7n+4 = Ω(n)
In such a case we would pick a constant c, such that it is lower than 7 since this regarding Big Omega. Picking 6 would result in
7n+4 >= 6n
n+4 >= 0
n = -4
But since n0 cannot be a negative term, we pick a positive integer, so n0 = 1.
But what about a problem like this:
Prove that n^3 − 91n^2 − 7n − 14 = Ω(n^3).
I picked 1/2 as the constant, reaching
1/2n^3 - 91n^2 - 7n -14 >= 0.
But I am unsure how to continue. Also, a problem like this, I think regarding theta:
Let g(n) = 27n^2 + 18n and let f(n) = 0.5n^2 − 100. Find positive constants n0, c1 and c2 such
that c1f(n) ≤ g(n) ≤ c2f(n) for all n ≥ n0.
In such a case am I performing two separate operations here, one big O comparison and one Big Omega comparison, so that there is a theta relationship, or tight bound? If so, how would I go about that?
To show n3 − 91n2 − 7n − 14 is in Ω(n3), we need to exhibit some numbers n0 and c such that, for all n ≥ n0:
n3 − 91n2 − 7n − 14 ≥ cn3
You've chosen c = 0.5, so let's go with that. Rearranging gives:
n3 − 0.5n3 ≥ 91n2 + 7n + 14
Multiplying both sides by 2 and simplifying:
182n2 + 14n + 28 ≤ n3
For all n ≥ 1, we have:
182n2 + 14n + 28 ≤ 182n2 + 14n2 + 28n2 = 224n2
And when n ≥ 224, we have 224n2 ≤ n3. Therefore, the choice of n0 = 224 and c = 0.5 demonstrates that the original function is in Ω(n3).
I'm trying to find the n0 (n not) of a function with a big omega size of n^3 where c=2.25
𝑓(𝑛) = 3𝑛^3 − 39𝑛^2 + 360𝑛 + 20. In order to prove that 𝑓(𝑛) is Ω(𝑛^3), we need constants 𝑐, 𝑛0 > 0 such that 𝑓(𝑛) ≥ 𝑐𝑛^3 for every 𝑛 ≥ 𝑛0
If c=2.25, how do I find the smallest integer that satisfies n0?
My first thought was to plug in n=1, because n>0, and if the inequality worked n=1 would be the smallest n (therefore n0). But, the inequality has to be satisfied for every n>=n0, and if i plug in, for example, n=15 the inequality doesn't work.
You can solve this mathematically.
To make sure that I understand what you want, I will summarize what you are asking. You want to find the smallest integer n so that:
3𝑛^3 − 39𝑛^2 + 360𝑛 + 20 ≥ 2.25𝑛^3 (1)
And any other integers bigger than n must also satisfy the equation (1).
So here is my solution:
(1) <=> 0.75𝑛^3 − 39𝑛^2 + 360𝑛 + 20 ≥ 0
Let f(n) = 0.75𝑛^3 − 39𝑛^2 + 360𝑛 + 20
f(n) = 0 <=> n1 = -0.05522 or n2 = 12.079 or n3 = 39.976
If n < n1, f(n) < 0 (try this yourself)
If n1 < n < n2, f(n) > 0 (the sign will alternate)
If n2 < n < n3, f(n) < 0 (the sign will alternate, again)
If n > n3, f(n) > 0
So to satisfy your requirements, the minimum value of n must be 40
Think about it like this. After a certain point 3𝑛^3 − 39𝑛^2 + 360𝑛 + 20 will always be greater than or equal to n^3 for the simple fact that eventually 3n^3 will beat out the -39n^2. So F(n) will never dip below n^3 for an extremely large number. You don't have to put the minimum nO, just choose an extremely large number for nO, since the question is asking after a certain value for n, the statement will hold true for ever. Choose nO, for example, to be an extremely large number X, and then use an inductive proof where X is the base case.
I am trying to prove that a function is in Ω(𝑛^3), however the constant C is fixed to 3.
The function is:
𝑓(𝑛) = 3𝑛^3 − 39𝑛^2 + 360𝑛 + 20
In order to prove that 𝑓 is Ω(𝑛^3), we need constants 𝑐, 𝑛_0 > 0 such that
|𝑓(𝑛)| ≥ C|𝑛^3|
for every 𝑛 ≥ 𝑛_0.
When plugging in C = 3, you would get the inequality
3𝑛^3 − 39𝑛^2 + 360𝑛 + 20 ≥ 3𝑛^3
which would equal
−39𝑛^2 + 360𝑛 + 20 ≥ 0
I'm stuck here, because I can't find an n_0 that satisfies the equation for every 𝑛 ≥ 𝑛0.
Also, if c = 2.25 fixed, how do I find the smallest integer that satisfies n_0 ?
How to prove it in general
Proving 𝑓 in Ω(𝑛^3) with 𝑓(𝑛) = 3𝑛^3 − 39𝑛^2 + 360𝑛 + 20 is pretty simple.
The exact definition (from Wikipedia) is:
In words you need to find a constant c such that c * g will always be smaller than f (from a given n_0). You are of course allowed to choose this c small and the n_0 big.
We first drop some unnecessary stuff in order to estimate f:
−39𝑛^2 is greater than -n^3 for all n >= 39
360𝑛 is obviously greater than 0
20 is also greater than 0
Okay, putting that together we receive:
f(n) >= 3n^3 - n^3 + 0 + 0
= 2n^3
for n >= 39.
We choose C = 2 (or something smaller), n_0 = 39 (or something greater) and follow that
C * |g(n)| = 2 * |n^3| <= |2 * n^3| <= |f(n)|
<=> C * |g(n)| <= |f(n)|
for all n > n_0. By definition this means 𝑓 in Ω(𝑛^3).
Your specific scenario
For C = 3 fixed this is obviously not possible since 3 * n^3 is always greater than 3𝑛^3 − 39𝑛^2 + 360𝑛 + 20 (for some n_0). This is due to the second summand −39𝑛^2.
Take a look at the plot:
You see that 3n^3 grows beyond f, for all n >= n_0 with n_0 at about 9.286. The exact value is:
n >= (2 / 39) * (90 + 8295^(0.5))
Here is the query at Wolfram Alpha.
But it is possible for a fixed C = 2.25 as you can see at this query. It is true for all n >= 40.
I'm trying to explain to my friend why 7n - 2 = O(N). I want to do so based on the definition of big O.
Based on the definition of big O, f(n) = O(g(n)) if:
We can find a real value C and integer value n0 >= 1 such that:
f(n)<= C . g(n) for all values of n >= n0.
In this case, is the following explanation correct?
7n - 2 <= C . n
-2 <= C . n - 7n
-2 <= n (C - 7)
-2 / (C - 7) <= n
if we consider C = 7, mathematically, -2 / (C - 7) is equal to negative infinity, so
n >= (negative infinity)
It means that for all values of n >= (negative infinity) the following holds:
7n - 2 <= 7n
Now we have to pick n0 such that for all n >= n0 and n0 >= 1 the following holds:
7n - 2 <= 7n
Since for all values of n >= (negative infinity) the inequality holds, we can simply take n0 = 1.
You're on the right track here. Fundamentally, though, the logic you're using doesn't work. If you are trying to prove that there exist an n0 and c such that f(n) ≤ cg(n) for all n ≥ n0, then you can't start off by assuming that f(n) ≤ cg(n) because that's ultimately what you're trying to prove!
Instead, see if you can start with the initial expression (7n - 2) and massage it into something upper-bounded by cn. Here's one way to do this: since 7n - 2 ≤ 7n, we can (by inspection) just pick n0 = 0 and c = 7 to see that 7n - 2 ≤ cn for all n ≥ n0.
For a more interesting case, let's try this with 7n + 2:
7n + 2
≤ 7n + 2n (for all n ≥ 1)
= 9n
So by inspection we can pick c = 9 and n0 = 1 and we have that 7n + 2 ≤ cn for all n ≥ n0, so 7n + 2 = O(n).
Notice that at no point in this math did we assume the ultimate inequality, which means we never had to risk a divide-by-zero error.