4

On page 53 or CLRS it has said :

We can extend our notation to the case of two parameters n and m that can go to infinity independently at different rates. For a given function $g(n,m)$, we denote by $O(g(n,m))$ the set of functions $$\begin{align} O(g(n,m)) = \{ f(n,m) : &\text{there exist positive constants }c, n_0,\text{ and } m_0 \\ &\text{ such that } 0 \le f(n,m) \le cg(n,m)\\ &\text{ for all } n\ge n_0\text{ or } m \ge m_0 \} \end{align}$$

I think this definition has a problem cause if $n \ge n_0$ for some constant $n$ then we don't need to grow $m$! I feel something is Wrong! It must be the word "and" instead of "or" for example : $f(x , y ) = x^2 + y^2$
$g_2(x,y) = x^2 + y$
$g_1(x,y) = x^2 + x*y$

by the definition $f(x,y)$ is $O(g_1(x,y))$ ! or even $f(x,y)$ is $O(g_2(x,y))$ ?

please guide me .

Discrete lizard
  • 8,248
  • 3
  • 24
  • 53
  • related: https://math.stackexchange.com/questions/353461/big-mathcalo-notation-for-multiple-parameters and https://cs.stackexchange.com/questions/30036/can-a-big-oh-time-complexity-contain-more-than-one-variable – Neal Young Feb 23 '22 at 17:29

2 Answers2

2

Well, there is not really a completely satisfying way to have the big-O Notation with multiple variables. Therefore CLRS present one way of a generalization. Putting an and instead of the or would give a new definition with other problems.

See this article for a discussion on the subject.

A.Schulz
  • 12,167
  • 1
  • 40
  • 63
2

It looks like you misunderstood the definition.


To be more precise, the definition is read as the following.

$$\begin{align} O(g(n,m)) = \{ f(n,m) : &\text{there exist positive constants }c, n_0,\text{ and } m_0 \\ &\text{ such that } 0 \le f(n,m) \le cg(n,m)\\ &\text{ for all } (n,m)\text{ such that }n\ge n_0\text{ or } m \ge m_0 \} \end{align}$$


$f(x,y)\not\in O(g_1(x,y))$

For the sake of contradiction, suppose $f(x,y)\in O(g_1(x,y))$. Then there exist positive constants $c$, $n_0$, and $m_0$ such that $0 \le f(n,m) \le cg(n,m)$ for all $n\ge n_0$ or $m \ge m_0$.

$$ \lim_{m\to\infty}\frac{f(n_0,m)}{g_1(n_0,m)}=\lim_{m\to\infty}\frac{n_0^2 + m^2}{n_0^2 + m}=\lim_{m\to\infty}\frac{\frac{n_0^2}m + m}{\frac{n_0^2}m + 1}=\lim_{m\to\infty}\frac{m}{1}=\infty$$

So, there exists $m_1\ge m_0$, such that $f(n_0,m_1) > cg_1(n_0,m_1)$. This contradicts to the condition that $f(n,m) \le cg_1(n,m)$ for all $n\ge n_0$. Q.E.D.


There is no way to define the big-$O$ notation for functions on more than one variable in a way that implies all properties commonly used in algorithm analysis. You can read this long paper by Kalle Rutanen, March 15, 2018, O-notation in Algorithm Analysis (updated) for details. So one has to be somewhat wary using the big-O notation in the case of multiple variables.

On the other hand, if the functions inside the notation are nondecreasing in each variable, then most properties used in algorithm analysis do hold for some natural definitions of the big $O$-notation for multivariate functions. This is the case in the question, when we can be more comfortable. In fact, that paper claims that "computer scientists have used the O-notation correctly intuitively" by providing "a solid mathematical foundation" (quoted from its chapter 7, conclusion).


Exercise 1. Show that $g_1(x,y)\in O(f(x,y))$ and $g_2(x,y)\in O(f(x,y))$

Exercise 2. Show that $f(x,y)\not\in O(g_2(x,y))$.

Exercise 3. Show that $f(x,y)\in O(2x^2+3y^4)$ and $f(x,y)\in O(\max(x^2,y^2))$.

John L.
  • 38,985
  • 4
  • 33
  • 90
  • http://mathwiki.cs.ut.ee/asymptotics/04_multiple_variables what do you say about this one ? – Becoming Algebra Mar 17 '19 at 11:45
  • In fact, the definition of big $O$ for functions of two variables at mathwiki.cs.ut.ee is basically the same as the definition given in the same book introduction to algorithms but in its second edition. There can be a lot more to say about these two definitions. – John L. Mar 18 '19 at 15:59
  • I am surprised that you have accepted the other answer that does not analyze your question closely. In particular, I suspect its author did not even bother to check the last several statements in the question. – John L. Mar 18 '19 at 16:00
  • Also, the article mentioned in the other answer is, I believe, superseded by the paper mentioned in this answer. (Of course, it is still a nice article to read.) – John L. Mar 18 '19 at 16:08
  • I could show why the definition was changed from "$n\ge n_0$ and $m\ge m_0$" to "$n\ge n_0$ or $m\ge m_0$" if you are interested. – John L. Mar 20 '19 at 15:53
  • please explain more , I am got confused . I am really interest to know exactly why "and" is not complete , and the definition changed from "and" to "or" . . we know that if we accept this definition "n≥n0 and m≥m0" set of functions is subset of set of functions if we accept "n≥n0 or m≥m0" definition .

    A = { set of ... when n≥n0 and m≥m0 } B = { set of ... when n≥n0 or m≥m0 }

    A ⊆ B

    – Becoming Algebra Mar 21 '19 at 14:55
  • "There is no way to define the big-O notation for functions on more than one variable in a way that implies all properties commonly used in algorithm analysis.". This is incorrect. The whole point of my thesis is that there is exactly one definition of O-notation suitable for algorithm analysis: there exists $\alpha > 0$ such that $f \leq \alpha g$. Under suitable conditions you can deduce this relation by other means. The thesis also shows why Howell's paper does not show what it claims to show: the axioms are too strong; they reduce right back to asymptotic linear dominance. (Kalle) – kaba Apr 25 '20 at 23:26
  • @kaba By your proposed definition is it the case that $mn + 1 = O(mn)$? Not if you allow $m=0$ and/or $n=0$. So suppose you restrict to $n\ge 1$ and $m\ge1$. Then is it the case that $mn = O((m-1)(n-1))$? Not unless you restrict to $n\ge 2$ and $m\ge 2$. Your proposed definition is ambiguous as it doesn't specify for what values of the variables the inequality should hold, but this matters. – Neal Young Feb 23 '22 at 17:06
  • @NealYoung The domain set is part of the O-notation. See here for detailed answers. – kaba Feb 23 '22 at 19:52