Is it true that $O(M^3 + NM^2) \, = \, O(M^3 + N)$, where $M$ and $N$ are variables of the function?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
[Throughout this answer, I'm going to use set notation in order to be pedantic.]
It is true that $O(M^3+N)\subset O(M^3+NM^2)$, since for $M$ sufficiently large, $c(M^3+N)<c(M^3+NM^2)$. It's worth noting that for $M$ sufficiently close to $0$, $M^3+N>M^3+NM^2$.
For the reverse inclusion, consider $f(M,N)=M^3+NM^2$. Clearly $f\in O(M^3+NM^2)$. We now need to show that for all $c$ and arbitrarily large $M,N$ that $f(M,N)>c(M^3+N)$. We can do this by setting $M=\log N$. We then have $f(\log N,N)=\log^3 N + N\log^2 N$, which is clearly larger than $c(\log^3 N + N)$ for all sufficiently large $N$. So $f(M,N)\not\in O(M^3+N)$.