Can you operate on and draw conclusions on functions described asymptotically?

This question is homework based (not using actual problem though)!

Say you have a function described as:

$$f(n) \in O(2n^2) \, .$$

Can you then go on the treat this as:

$$f(n) = 2n^2$$

and performs mathematics on it and keep its asymptotic meaning?

In the above case could I conjecture that $f(n) \in O(2n^2)$ implies $f(n) / 2 \in O(n^2)$ (assuming coefficients matter in this example)?

• You would need to be very careful. Recall that O() is a set of functions. Taking one representative only might lead to false conclusions. – adrianN Sep 26 '16 at 15:00
• "Can you then go on the treat this as:" -- no. "keep its asymptotic meaning" -- what do you mean by that? Some information carries over, some doesn't. "In the above case could I conjecture" -- you can conjecture whatever you want; what is interesting is whether you can prove anything. See here for how to prove asymptotic relations. You can also directly go to the definitions: what is the claim after unfolding $O$? What do you know about $f$ after unfolding $O$? Fill the space in between. – Raphael Sep 26 '16 at 16:12

For some operations, such as addition, multiplication, you can operate directly on the asymptotic notation. For example, if $\small g(n) = \mathcal{O}(n^2)$ and $\small f(n) = \mathcal{O}(n^2)$, then $\small g(n) + f(n) = \mathcal{O}(n^2)$ and $\small g(n) \cdot f(n) = \mathcal{O}(n^4)$. For some other operations, such as division, it depends then. For example, for $\small g(n) = \mathcal{O}(n^2)$ and $\small f(n) = \mathcal{O}(n^2)$, it is not correct to say $\small \frac{g(n)}{f(n)} = \mathcal{O}(1)$ (consider $\small g(n) = n^2$ and $\small f(n) = n$). However, if $c$ is a fixed constant, then $\small \frac{g(n)}{c} = \mathcal{O}(n^2)$.

• is there some documentation on which operations are generally "allowed" for asymptotic notation? Or can you just infer that exponentiation is always allowed (multiplication), and logarithmic is dependent (division)? – Tyler Kelly Sep 26 '16 at 15:42
• @user3470987 While there might be a list somewhere, you can also generate it on-the-fly. This is an excellent exercise. – Yuval Filmus Sep 26 '16 at 15:55
• @user3470987 This is a matter of taste. People like me would advise you to never do this as it can easily lead to confusion and mistakes. – Raphael Sep 26 '16 at 16:13

To answer questions like your conjecture, use the definition of $O$. Paraphrasing from wikipedia at time of writing:

$f \in O(g)$ iff $f(x) \leq M\times g(x)$ for all $x > x_0$, for some constants $M$ and $x_0$.

So if $f(n) \in O(2n^2)$, then $f(n) \leq C \times 2n^2 \ \ \forall n > n_0$ for some constants $C$ and $n_0$ (I'm calling it $C$ instead of $M$ to avoid confusion later). You'll notice we can combine the $2C$ into one constant, which tells you $O(2n^2) = O(n^2)$.

What can we say about $f(n)/2$? We can now use normal algebra on the inequality, such as dividing both sides by 2 to get:

$f(n)/2 \leq Cn^2 \ \ \forall n > n_0$

Is this still $O(n^2)$? To check this, we need to find constants $M$ and $x_0$ such that the definition above holds. In this case, $M = C$ and $x_0 = n_0$ works. Notice that $M = 327.6C$ is also valid; you can use whatever method you want to find these constants, as long as you know they are constant.

In the real world you'll be able to "shortcut" most of this when doing your analysis, as NP-hard does in his answer, but those are just shortcuts for writing it out rigorously like this (which is what I would expect on homework specifically about $O$). If you're not sure whether it's valid, get the $O$s out by using the definition, perform algebra on the inequality, then get it back into $O$ by finding the appropriate constants (or simply showing that they do exist).