15
$\begingroup$

On the wikipedia page, we have the following property:

If $f_1(x) = O(g_1(x))$ and $f_2(x) = O(g_2(x))$ then $f_1(x) + f_2(x) = O(|g_1(x)| + |g_2(x)|)$.

But in my textbook, I also see the following sum property:

If $f_1(x) = O(g_1(x))$ and $f_2(x) = O(g_2(x))$ then $f_1(x) + f_2(x) = O(\max(g_1(x), g_2(x)))$.

Are these two properties equivalent? If not, which sum property do I use in general?

$\endgroup$
22
$\begingroup$

They are equivalent (assuming that $g_1,g_2$ are assumed non-negative in your textbook). Note that $$ \max(a,b)\leq a+b \leq 2\max(a,b) $$ for any $a,b\geq 0$, and that the constant $2$ can be "hidden" in the $O(\cdot)$ notation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.