TITLE: If $f(n)$ is $O(g(n))$ and $g(n)$ is $O(f(n))$, is $f(n) = g(n)$?
QUESTION [6 upvotes]: Question: If $f(n)$ is $O(g(n))$ and $g(n)$ is $O(f(n))$, is $f(n) = g(n)$?

I'm studying for a discrete mathematics test, and I'm not sure if this is true or false.  Since Big-OH ignores constant multiples, wouldn't $f(n) = c\, g(n)$?

REPLY [2 votes]: Consider
$f(n) = an^2$
and
$g(n) = bn^2$
where $a$ and $b$ are 
distinct positive reals.
Both
$f(n) = O(g(n))$
and
$g(n) = O(f(n))$
are true,
but $f(n) \ne g(n)$
for $n > 0$.
This is often written as
$f(n) = \Theta(g(n))$.