HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to discuss coefficients in big-O notation

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
discusscoefficientsbignotationhow

Problem

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?

Solution

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.

Context

StackExchange Computer Science Q#16346, answer score: 9

Revisions (0)

No revisions yet.