-1

I'd like to double-check my understanding of Big-Oh.

The definition is that $f(n) = O(g(n))$ if $|f(x)| ≤ M\,|g(x)|$ for a natural number $M$ and for sufficiently large values of $x$.

Now, if $g(n) = O(n^2) - O(n^2)$, may we conclude that $g(n) = 0$? If not, what can we say about $g(n)$?

David Richerby
  • 81,689
  • 26
  • 141
  • 235
  • Note that $O(n^2)$ is not a function, but a class of functions. (While writing $f(x) = O(n^2)$ is common, $f(x) \in O(n^2)$ would make more sense in my opinion). This makes the definition of $g(x)$ as $O(n^2) - O(n^2)$ unclear. Can you clarify what it should mean? (perhaps $g(x) = h(x) - f(x)$ where both $h(x) = O(n^2)$ and $f(x) = O(n^2)$?) – user53923 Apr 07 '17 at 14:51
  • See also http://cs.stackexchange.com/a/30599/65870 under Pitfalls of convention – user53923 Apr 07 '17 at 14:54
  • @user53923 I wish I could but that's an exercise of a book I'm reading and that's the full description of the problem. Also, thanks for the interesting link. – futtetennista Apr 07 '17 at 15:16
  • "Time complexity of g(x) = O(n²) − O(n²)" -- that's not a thing. 2) How does your book define "-" for Landau terms? Work from there -- unfold definitions.
  • – Raphael Apr 07 '17 at 20:40
  • @Raphael I re-wrote the question the way it was originally asked which is very different from the way I formulated it, I apologise. I have no clue whatsoever about Landau terms though. – futtetennista Apr 08 '17 at 07:19
  • 1
    @user53923 It's entirely standard to write things like $g(x) = x^2 + O(x)$ to mean $g(x)=x + h(x)$ for some function $x\in O(x)$. This is much more specific than just saying $g(x)=O(x^2)$, since $10x^2 + x^{1.999}$ is in $O(x^2)$ but is not of the form $x^2+O(x)$. So "$g(x)=O(x^2)-O(x^2)$" does indeed mean that $g(x)=h(x)-f(x)$ for some $h,f\in O(x^2)$. Allowing us to write things like $x^2+O(x)$ is exactly the reason why we abuse notation by saying $g=O(f)$, rather than $g\in O(f)$: pretending that $O(x)$ is a function lets us include it in arithmetic expressions, which is very useful. – David Richerby Apr 08 '17 at 09:10