2

I found the formulas below on a website of a New Zealand university. This is the solution part to a question on big O formulas and wether they are right or wrong, and I wanted to check if these are actually correct.

Image

I specifically have doubts about the fourth staement

$5n+8n^2+100n^3 =O(n^4)$

This is assumed correct. Since we usually take the highest leading element, should it not be $O(n^3)$ as opposed to $O(n^4)$?

Are the other proofs correct?

RobPratt
  • 50,938
  • 2
    The problem is the abuse of notation using "$=$" here: Writing $f=O(g)$ actually means $f\in O(g)$. In your case $O(n^3)$ is a subset of $O(n^4)$ so that any $f$ in $O(n^3)$ is also in $O(n^4)$. – Christoph Jul 14 '20 at 17:48

2 Answers2

7

They are correct. Anything that is $O(n^3)$ is also $O(n^4)$.

Robert Israel
  • 470,583
  • But doesn't that overestimate the upper bound of the function? – samislearning Jul 14 '20 at 17:56
  • 2
    @legalalien Do you know the definition of $O(\ldots)$? – Robert Israel Jul 14 '20 at 18:28
  • I've been studying it in a computer science context and my understanding is that it provides the maximum running time of an algorithm, or "worst-case" runnig time. Mathematically, my understanding is that it provides the upper bound of a function. I'm new to the concept so I can't say I have mastery. – samislearning Jul 14 '20 at 18:35
  • 2
    The definition is: $f(n) = O(g(n))$ if there is some constant $M$ such that $|f(n)| \le M g(n)$ for all sufficiently large $n$. In particular, if you say $f(n) = O(n^k)$ this does not in any way imply $k$ is the least power that works. Since $n^3 \le n^4$, $f(n) = O(n^3)$ implies $f(n)=O(n^4)$. – Robert Israel Jul 14 '20 at 19:26
0

To avoid any misunderstanding and ambiguity I'll write fully here what I mean: $$5n+8n^2+100n^3 \notin O(n^2 \log n)$$ To prove it's enough to consider reverse inequality: $$5n+8n^2+100n^3 > n^3 > n^2 \log n \Leftrightarrow n> \log n$$

It's big difference between $f=O(g)$, which mean $f \in O(g)$, and $O(f)=O(g)$, which often is understand as $O(f) \subset O(g)$, but in all your general formulas, rules of sums and products, holds $O(f) \subset O(g) \land O(g) \subset O(f)$, so equality here behaves exactly as equality between sets. Some of proofs, for example, rule of summation, I wrote here Arithmetic rules for big O notation, little o notation and so on...

Now, for example, let's take transitivity. For simplicity I consider non negative functions. Strict definition is:

$$O(g) = \left\lbrace f:\exists C > 0, \exists N \in \mathbb{N}, \forall n (n > N \& n \in \mathbb{N}) (f(n) \leqslant C \cdot g(n)) \right\rbrace$$ Obviously, we have: $$O(f) \subset O(g) \land O(g) \subset O(h) \Rightarrow O(f) \subset O(h)$$

Now, let's notice, that $$f \in O(g) \Rightarrow O(f) \subset O(g)$$ So $$f \in O(g) \land g \in O(h) \Rightarrow f \in O(h)$$

But $g \in O(f) \land h \in O(f)$ doesn't give information about $h$ and $g$ mutual comparison.

zkutch
  • 14,313
  • Why would that be wrong? $100n^3$ is definitely not in $O(n^2 \log n)$. – vonbrand Jul 14 '20 at 21:21
  • Sorry, seems we speak about one and same, that it's definitely not in O(n \log n) I wrote and added proof. Or you mean something else? – zkutch Jul 14 '20 at 21:54
  • The statement is already flagged as false. Saying the statement is incorrect is confusing, because you could mean that the statement is false, or that saying that it is false is incorrect. (But if you're claiming that the last one is the only false statement, then are you claiming that the first and third should be true?) – Teepeemm Jul 15 '20 at 02:35
  • @Teepeemm. Confusing is flags in the middle. What I wrote, I wrote about formulas - not flags. Anyway I change text to avoid ambiguity. And which one would you like to discuss - first, third from left or right column? Confusing without specification. – zkutch Jul 15 '20 at 09:18
  • The third row ("Transitivity") is listed as false. Are you saying that statement should be true? The first row ("Rule of Sums") is listed as false. Are you saying that statement should be true? (I'm actually inclined to believe that the Rule of Sums as given is a true statement, but haven't wanted to put in the effort to actually prove it.) In general, it seems like you are responding to the first column of the table, and ignoring the rest of the table and the rest of the post. – Teepeemm Jul 15 '20 at 12:02
  • @Teepeemm. I added my considerations about transitivity to answer and change first sentence to avoid conjectures. Rule for sum is proved in link brought. Please, feel free to ask exactly about each statement you are interested in. – zkutch Jul 15 '20 at 13:33