Proving big O of statement [closed] - math

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am having a hard time proving that n^k is O(2^n) for all k. I tried taking lg2 of both sides and have k*lgn=n, but this is wrong. I am not sure how else I can prove this.

To show that nk is O(2n), note that
nk = (2lg n)k = 2k lg n
So now you want to find an n0 and c such that for all n ≥ n0,
2k lg n ≤ c 2n
Now, let's let c = 1 and then consider what happens when n = 2m for some m. If we do this, we get
2k lg n ≤ c 2n = 2n
2k lg 2m ≤ 22m
2km ≤ 22m
And, since 2n is a monotonically-increasing function, this is equivalent to
km ≤ 2m
Now, let's finish things off. Let's suppose that we let m = max{k, 4}, so k ≤ m. Thus we have that
km ≤ m2
We also have that
m2 ≤ 2m
Since for any m ≥ 4, m2 ≤ 2m, and we've ensured by our choice of m that m = max{k, 4}. Combining this, we get that
km ≤ 2m
Which is equivalent to what we wanted to show above. Consequently, if we pick any n ≥ 2m = 2max{4, k}, it will be true that nk ≤ 2n. Thus by the formal definition of big-O notation, we get that nk = O(2n).
I think this math is right; please let me know if I'm wrong!
Hope this helps!

I can't comment yet, so I will make this an answer.
Instead of reducing the equation like you have been trying to do, you should try to find an n0 and a M that satisfy the formal definition of big O notation found here: http://en.wikipedia.org/wiki/Big_O_notation#Formal_definition
Something along the lines of n0=M=k might work (I haven't written it out so maybe that doesn't work, thats just to give you an idea)

Related

How can I proof a difficult big o notation? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 5 years ago.
Improve this question
I can easily understand how to proof a simple big o notation like n5 + 3n3 ∈ O(n5).
But how can I proof something more complex like 3n or 2n ∉ O(nk)?
Use a proof by contradiction.
Let's prove that 2n ∉ O(n2). We assume the opposite, and deduce a contradiction from a consequence.
So: assumption: there exists M and n0 such that 2n < M n2 for all n >= n0.
Let x be an number such that x > 5, and x > n0 and 2x > 4 M. Do you agree that such a number must exist?
Finish off the proof by deducing a contradiction based on the inequality that 22x < 4 M x2 by assumption.
Now do the analogous proof for k = 3. Then do it for k = 4. Then generalize your result for all k.

What is "h" in numerical differentiation? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 6 years ago.
Improve this question
I would like to know what h from the numerical differentiation formulas is and how I can calculate it when I have a function.
I am speaking about this formulas:
f'(x0) = (f(x0 + h) - f(x0)) / h
f'(x0) = (f(x0) - f(x0 - h)) / h
f'(x0) = (f(x0 + h) - f(x0 - h)) / 2*h
I would really appreciate any kind of help!
In such formulae h is usually a "very small number", similar to epsilon in Calculus.
For example, the derivative of f at a is defined as:
Note how h is defined as approaching 0.
When programming, e.g. doing numerical gradient computation, it usually works to set h to something very small - many programming environments have an "epsilon" quantity; lacking that, you can just use a very small floating-point number.
Using the usual 8 byte floats, sensible values for h are 1e-8 for the first and second formula and 1e-5 for the third central difference quotient. This is valid for medium values of x, for larger x one would have to include the scale of x in some way.
In general, for a kth order difference quotient with error order p, the balance between floating point noise and numerical error is reached for h about pow(2e-16, 1.0/(p+k)).

Recurrence relations and asymptotic complexity

I am trying to understand the recurrence relation of f(n) = n^cos n and g(n) = n. I am told that this relation has no asymptotic behavior related to Big O, little o, Big Omega, little omega, or Theta. Something about the oscillations of cos n? Can I receive a little more understanding on this behavior?
When I use L' Hospital rule on my calculator, I get undefined.
The function ncos n is O(n). Since -1 ≤ cos n ≤ 1, the function ncos n is always bounded between n-1 and n1, so in particular it's always upper-bounded by O(n). However, it's not Ω(n), because for any number n0 and any constant c, you can find an n > n0 where ncos n < cn. One way to do this is to look for choices of n where cos n is negative; the value of n-ε for any ε > 0 will eventually be smaller than cn for any c.
Hope this helps!

homework: Proving n <= 2^(n/4)? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
So I have an assignment question where I have to prove:
n^4 is in O(2^n)
Just by looking at the graphs of the functions I know that with c=1 and n[0] = 16 this is true.
While trying to prove it on paper I managed to reduce the inequality down to n <= 2^(n/4), however, I cannot figure out how to simplify this further or adequately prove from here that with n[0]=16 the big-O assertion holds.
Any help?
The title is incorrect, and the error is important.
You are not trying to prove that n ≤ 2n/4, you are trying to prove that n ∊ O(2n/4), which is a strictly weaker claim. It is impossible to prove that n ≤ 2n/4 because at n=2, the inequality is false.
By taking the logarithm of both sides, we can reduce the problem to that of showing that log n ∊ O(n), which is easy to show because d/dn log n ≤ 1 for n ≥ 1.
It is easy to prove that the inequality holds for n >= 16 using induction, no calculus required:
First, for n=16 you have 164=216.
If the inequality holds for n=k, for n=k+1 you have (k+1)4 = (####)·k4 < 2k4 &leq; 2·2k = 2k+1.
QED.
Since this is homework, I'll leave leave the crucial step, finding what goes in place of ####, to the reader.

Big-O of a function taking on a negative value? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Hello I was wondering what would be my Big-Oh for this function: f(n) = 7n – 3nlogn+100000. I checked other similar questions. Some say that since nlogn is -3 we can ignore it and as such the result is O(n). I check with my professor and he said no we don't ignore the negative and still choose the largest of them all and as such the Big-Oh would be O(nlogn). Not ignoring the negative I end up with this. Am I right??
7n – 3nlogn+100000 ≤ (7+3+10000) nlogn where c= 100010 & n≥n0
7n – 3nlogn+100000 ≤ 100010 nlogn n0= 2
O(nlogn) – Linear logarithmic or linearithmic
or is it more like
7n - 3nlogn + 100000 ≤ 100010 n where c= 100010 & n≥n0 & n0 = 1
Thanks alot
If you look at the formal definition of big-O notation, you'll notice that f(x) = O(g(x)) iff there are constants c and x0 such that
∀x > x0. |f(x)| ≤ c|g(x)|
Notice that there are absolute value bars here. Consequently, while it's true that
7n - 3nlogn + 100000 ≤ 100010 n
under the circumstances you mentioned, you would really need to show that
|7n - 3nlogn + 100000| ≤ 100010 |n|
which is not in general true. Using the fact that you need to have absolute value bars, you can prove that this function is Θ(n log n) by repeating your analysis, but taking care to watch for the sign flip. One way to do this is to use the triangle inequality:
|7n - 3n log n + 100000|
≤ |7n| + |-3n log n| + |100000|
= 7|n| + 3|n log n| + |100000|
≤ 7n + 3n log n + 100000
< 7n log n + 3n log n + 100000 n log n (when n > 10, say)
= 100010 n log n
So the function is O(n log n). You can repeat this analysis to get a matching lower bound as well.
Hope this helps!

Resources