10

What notation is used to discuss the coefficients of functions in big-O notation?

I have two functions:

  • $f(x) = 7x^2 + 4x +2$
  • $g(x) = 3x^2 + 5x +4$

Obviously, both functions are $O(x^2)$, indeed $\Theta(x^2)$, but that doesn't allow a comparison further than that. How do I discuss the the coefficients 7 and 3. Reducing the coefficient to 3 doesn't change the asymptotic complexity but it still makes a significant difference to runtime/memory usage.

Is it wrong to say that $f$ is $O(7x^2)$ and $g$ is $O(3x^2)$ ? Is there other notation that does take coefficients into consideration? Or what would be the best way to discuss this?

Raphael
  • 73,212
  • 30
  • 182
  • 400

2 Answers2

9

Big-$O$ and big-$\Theta$ notations hide coefficients of the leading term, so if you have two functions that are both $\Theta(n^2)$ you cannot compare their absolute values without looking at the functions themselves. It's not wrong per se to say that $7x^2 + 4x + 2 = \Theta(7x^2)$, but it's not informative because $7x^2 + 4x + 2 = \Theta(3x^2)$ is also true (and, in fact, it's $\Theta(kx^2)$ for any positive constant $k$).

There are other notations you might want to use instead. For example, $\sim$ notation is a much stronger claim than big-$\Theta$:

$\qquad \displaystyle f(x) \sim g(x) \iff \lim_{x \to \infty} \frac{f(x)}{g(x)} = 1$

For example, $7x^2 + 4x + 2 \sim 7x^2$, but the claim $7x^2 + 4x + 2 \sim 3x^2$ would be false. You can think of tilde notation as $\Theta$ notation that preserves the leading coefficients, which seems to be what you're looking for if you do care about the leading coefficient of the dominant growth term.

Raphael
  • 73,212
  • 30
  • 182
  • 400
templatetypedef
  • 9,302
  • 1
  • 32
  • 62
6

The tilde is one approach. If you want to stick with $O$, you could say

$\qquad f(x) = 7x^2 + O(x)$ and

$\qquad g(x) = 3x^2 + O(x)$.

Raphael
  • 73,212
  • 30
  • 182
  • 400