prove that f(n)= n^4 + 3n^3 = θ(n^4) - complexity-theory

I want to prove some asymptotic notations. and want to get the values of c1,c2,n
prove that
f(n)= n^4 + 3n^3 = θ(n^4)
f(n)= n^4 + 3n^3 not equal to θ(n^3)
how can I get the values of C1, C2, and n??

First one
n^4 + 3n^3 = Theta(n^4)
Guess c1 = 1/2 and c2 = 2.
Find n0 that works.
(1/2)n^4 <= n^4 + 3n^3
0 <= (1/2)n^4 + 3n^3
0 <= (1/2)n + 3
-6 <= n
Any choice for n0 works there.
n^4 + 3n^3 <= 2n^4
3 <= n
The smallest choice for n0 is 3.
combined, guess n0 = 3.
Proof is by induction
Base: (1/2)3^4 <= 3^4+(3)3^3 <= (2)3^4
Hypothesis: true up to k
Step:
(1/2)(k+1)^4 <= (k+1)^4 + 3(k+1)^3 <= 2(k+1)^4
1/2(k+1) <= (k+1) + 3 <= 2(k+1)
(1/2)k + 1/2 <= (k+3)+1 <= 2k + 2
From hypothesis (1/2)k <= k+3 <= 2k
also 1/2 <= 1 <= 2
So checks out.
Second one
n^4 + 3n^3 is not Theta(n^3)
Proof of first one is proof of this too
Can't be theta of funcs that aren't theta of each other
Otherwise, it is Omega(n^3)
Show it's not O(n^3)
Assume it were
Then there exist c, n0 such that
n^4 + 3n^3 <= cn^3 for n >= n0
n + 3 <= c for n >= n0
but then for any constant c just choose n' > c - 3
this gives a contradiction
the only assumption was that f(n) = O(n^3)
must have been wrong

Related

Is it always possible to find a constant K to prove big O or big Omega?

So I have to figure out if n^(1/2) is Big Omega of log(n)^3. I am pretty sure that it is not, since n^(1/2) is not even in the bounds of log(n)^3; but I do not know how to prove it without limits. I know the definition without limits is
g(n) is big Omega of f(n) iff there is a constant c > 0 and an
integer constant n0 => 1 such that f(n) => cg(n) for n => n0
But can I really always find a constant c that will satisfy this?
for instance for log(n)^3=>c*n^(1/2) if c = 0.1 and n = 10 then we get 1=>0.316.
When comparing sqrt(n) with ln(n)^3 what happens is that
ln(n)^3 <= sqrt(n) ; for all n >= N0
How do I know? Because I printed out sufficient samples of both expressions as to convince myself which dominated the other.
To see this more formally, let's first assume that we have already found N0 (we will do that later) and let's prove by induction that if the inequality holds for n >= N0, it will also hold for n+1.
Note that I'm using ln in base e for the sake of simplicity.
Equivalently, we have to show that
ln(n + 1) <= (n + 1)^(1/6)
Now
ln(n + 1) = ln(n + 1) - ln(n) + ln(n)
= ln(1 + 1/n) + ln(n)
<= ln(1 + 1/n) + n^(1/6) ; inductive hypethesis
From the definition of e we know
e = limit (1 + 1/n)^n
taking logarithms
1 = limit n*ln(1 + 1/n)
Therefore, there exits N0 such that
n*ln(1 + 1/n) <= 2 ; for all n >= N0
so
ln(1 + 1/n) <= 2/n
<= 1
Using this above, we get
ln(n + 1) <= 1 + n^(1/6)
<= (n+1)^(1/6)
as we wanted.
We are now left with the task of finding some N0 such that
ln(N0) <= N0^(1/6)
let's take N0 = e^(6k) for some value of k that we will are about to find. We get
ln(N0) = 6k
N0^(1/6) = e^k
so, we only need to pick k such that 6k < e^k, which is possible because the right hand side grows much faster than the left.

Proving Big O notation

Prove 5n^2+ 2n -1 = O(n^2).
This is what I have attempted so far:
5n^2 + 2n -1 <= 5n^2 + 2n^2 -n2 for n>1
5n^2+ 2n -1 <= 6n^2 for n>1
5n^2+ 2n -1 = O(n^2) [ c = 6n^2, n0 = 1 ]
Is this the right way of proving Big O notation?
To prove that your expression is O(n^2), you need to show that it is bounded by M*n^2, for some constant M and some minimum n value. By inspection, we can show that your expression is bounded by 10*n^2, for n=10:
For n = 10:
5n^2 + 2n -1 <= 10*n^2
500 + 20 - 1 <= 1000
519 <= 1000
We can also show that the expression is bounded by 10*n^2 for any value n greater than 10:
For n > 10:
5n^2 + 2n -1 <= 10*n^2
5*(10+i)^2 + 2*(10+i) -1 <= 10*(10+i)^2
5*(i^2 + 20i + 100) + 2i + 19 <= 10*(i^2 + 20i + 100)
2i + 19 <= 5*(i^2 + 20i + 100)
2i + 19 <= 5i^2 + 100i + 500
5i^2 + 98i + 481 >= 0, which is true for `i > 0`
Here is a link to the Wikipedia article on Big-O notation:
https://en.m.wikipedia.org/wiki/Big_O_notation
Update:
Note that in practice in order to label your expression O(n^2) we won't resort to such an ugly written proof. Instead, we will just recognize that the n^2 term will dominate the expression for large n, and that the overall behavior will be O(n^2). And your expression is also O(n^3) (and O(n^4), etc.).
it looks fine , I'm thinking that if you are doing it for your assignment work or other formal work then you can also do it in more formal way like for selecting the value of constant ( c ) such as by f(n)/g(n).Otherwise it looks correct.
We have f(n) = 5*n^2+2*n-1 and g(n) = n^2
In order to prove f(n) = O(g(n)), we just need to find 2 constants, namely c > 0 and n_0, s.t. f(n) <= c.g(n) for all n >= n0.
Let's choose some value of c = 5.5 say. Let's evaluate and plot f(n) and c*g(n). As we can see from the plot and we can also show it theoretically since n^2/2 - 2*n + 1 = (n^2-4*n+2)/2 = ((n-2)^2-2)/2 >= 0 for all n >= 4, it implies that 5*n^2+2*n-1 <= 5.5*n^2 for all n >= n0 = 4. Hence, f(n) = O(g(n)). (proved)

Problems solving - Asymptotic analysis

I am new with running time. I couldn't solve this one.
Given
f(n) = log n^2 and g(n) = log n + 5
prove
f(n) = theta(g(n)).
can anyone help me?
This is trivial. From basic logarithm properties
f(n) = log(n^2) = 2*log(n)
You need
C1*g(n) <= f(n) <= C2*g(n)
i.e.
C1*(log(n) + 5) <= 2*log(n) (1)
and
2*log(n) <= C2*(log(n) + 5) (2)
If you rewrite (1) as
C1*log(n) + C1*5 <= log(n) + log(n)
it looks like C1 == 1 would be a good choice, so we get:
log(n) + 5 <= log(n) + log(n)
5 <= log(n)
n >= 32
So we get for C1 == 1 and for each n >= 32, (1) holds.
For (2), it's obvious that you can choose C2 == 2. At the end you get
for each n >= 32
g(n) <= f(n) <= 2*g(n)
QED.

Big-O/Big-Oh Notation Problem

I am going over the Big-Oh notation, and I have a problem understanding the solution to this question:
Is 2n + 10 ≡ O(n)?
Can we find c and n0?
2n + 10 <= cn
(c-2)n >= 10
n >= 10/(c-2)
Pick c = 3 and n0 = 10
There is also a graph used in this example:
I am confused as to how c = 3 and how n0 = 10? Can somebody please enlighten me?
I would solve 2n + 10 <= cn differently.
2n + 10 <= cn
2 + 10/n <= c //divide by n
c >= 2 + 10/n
Clearly c has to be bigger than 2. Now take your favorite number bigger than 2. Uhm. c=2.718. This gives
2n + 10 <= 2.718*n
10 <= 0.718*n //subtract 2n
13.93 <= n
Thus, 2n + 10 <= c*n. If we take c=2.718 and n bigger than 15. (15 because it's bigger than the limit, 13.93, and I like 15.)
Any c bigger than 2 works, c=100000000000000000000000 is fine too (but, it costs much ink and paper to write down.)
It might have been easier to take c=3. That would give
2n + 10 <= 3*n
10 <= n //subtract 2n
This makes 3 the most logical / natural solution.
To say a function f(n) is O(n) means you can find c and n0 such that for all n >= n0, f(n) <= cn.
To verify this in your case: if n >= 10, then:
f(n) = 2n + 10
<= 3n // because 10 <= n
= cn
So f(n) <= cn for all n >= 10, so f(n) is an O(n) function.
Note that other values for c and n0 work; you just need to find one pair.
In Big-O notation you drop numbers added and multiplied.
And also use the largest power.
10*N^3+ 23*N^2 + 43*N + 154 = O(N^3)
let f(n) = 2n+10
as per the Big-Oh notation,
f(n)<= c*g(n) ----->eq1(let)
2n+10 <= 2n+n
2n+10 <= 3n for n>=10 //here the constant 10 is replaced by n ---->eq2
comparing eq1 with eq2
c=3 and g(n)=n for value of n=10
f(n)= O(g(n)) = O(n)

Simple Big O with lg(n) proof

I'm attempting to guess and prove the Big O for:
f(n) = n^3 - 7n^2 + nlg(n) + 10
I guess that big O is n^3 as it is the term with the largest order of growth
However, I'm having trouble proving it. My unsuccesful attempt follows:
f(n) <= cg(n)
f(n) <= n^3 - 7n^2 + nlg(n) + 10 <= cn^3
f(n) <= n^3 + (n^3)*lg(n) + 10n^3 <= cn^3
f(n) <= N^3(11 + lg(n)) <= cn^3
so 11 + lg(n) = c
But this can't be right because c must be constant. What am I doing wrong?
For any base b, we know that there always exists an n0 > 0 such that
log(n)/log(b) < n whenever n >= n0
Thus,
n^3 - 7n^2 + nlg(n) + 10 < n^3 - 7n^2 + n^2 + 10 when n >= n0.
You can solve from there.
For your question, the proof of O(n^3) should look something like this:
f(n) <= n^3 + 7n^2 + nlg(n) + 10 for (n > 0)
f(n) <= n^3 + 7n^3 + nlg(n) + 10 for (n > 1)
f(n) <= n^3 + 7n^3 + n*n^2 + 10 for (n > 2)
f(n) <= n^3 + 7n^3 + n^3 + 10 for (n > 2)
f(n) <= n^3 + 7n^3 + n^3 + n^3 for (n > 3)
f(n) <= 10n^3 for (n > 3)
Therefore f(n) is O(n^3) for n > 3 and k = 10.

Resources