Generalizing $n cdot m = O(n^2) iff m = O(n)$ to any two-variable function












0












$begingroup$


I came across the following statement in my Computer Science high-school textbook (I translated it to English).



There was some for loop that runs $m$ times nested inside a for loop that runs $n$ times, and it said:



"The function is $n cdot m$, and since $n$ and $m$ are as large as we want, we can set $m$ equal to $n$ and say that the complexity is $O(n^2).$"



Obviously I was suspicious, because $m$ in this case didn't depend on $n$.



So I started thinking about the problem with the big-$O$ definition.



Using the definition of for multiple variables, I proved the statement is false by contradiction.



I also thought about using the definition for a single variable, with $m$ as a function of $n$. I was able to prove that $n cdot m = O(n^2)$ if and only if $m=O(n)$.



My question is, is it possible to somehow generalize this thought and say that $f(n,m) = O(f(n,n))$ if some properties hold? Is this even legal, with Big-$O$ notation?



I'm also not sure if my original proofs are correct, so here they are:



Using the multiple variable definition, prove $n cdot m neq O(n^2)$.



Suppose $n cdot m = O(n^2)$, then there exist $c,n_0,m_0 in mathbb{R}_{>0}$ so that $n geq n_0, m geq m_0$ implies $n cdot m leq cn^2$.
But if we look at $n=n_0,m=max(m_0,cn_0+1)$, we have
$$n cdot m = n_0 cdot max(m_0,cn_0+1) geq n_0 cdot (cn_0+1) = cn_0^2+n_0 > cn_0^2$$
This is a contradiction, because $n=n_0 geq n_0$ and $m=max(m_0,cn_0+1) geq m_0$ and so we should have $n cdot m leq cn^2 = cn_0^2$.



Using the single variable definition, prove $n cdot m = O(n^2) iff m=O(n)$.



Suppose $n cdot m = O(n^2)$, then there exist $c,n_0 in mathbb{R}_{>0}$ so that $n geq n_0$ implies $n cdot m leq cn^2$. Divide both sides by $n$, and we have $m leq cn$ for $n geq n_0$, which directly means (by definition) that $m=O(n)$.



Suppose $m = O(n)$, then there exist $c,n_0 in mathbb{R}_{>0}$ so that $n geq n_0$ implies $m leq cn$. Now let's prove $n cdot m = O(n^2)$.
For every $n$ and specifically for every $n geq n_0$,
$$n cdot m leq n cdot cn = cn^2$$
Which directly means (by definition) that $n cdot m = O(n^2)$.










share|cite|improve this question









$endgroup$












  • $begingroup$
    $m$ must depend on $n$ in some way, otherwise $mn=O(n)ne O(n^2)$
    $endgroup$
    – Exodd
    Nov 30 '18 at 9:34










  • $begingroup$
    Yes. As I wrote, we think of m as a function of n.
    $endgroup$
    – user554564
    Nov 30 '18 at 10:18
















0












$begingroup$


I came across the following statement in my Computer Science high-school textbook (I translated it to English).



There was some for loop that runs $m$ times nested inside a for loop that runs $n$ times, and it said:



"The function is $n cdot m$, and since $n$ and $m$ are as large as we want, we can set $m$ equal to $n$ and say that the complexity is $O(n^2).$"



Obviously I was suspicious, because $m$ in this case didn't depend on $n$.



So I started thinking about the problem with the big-$O$ definition.



Using the definition of for multiple variables, I proved the statement is false by contradiction.



I also thought about using the definition for a single variable, with $m$ as a function of $n$. I was able to prove that $n cdot m = O(n^2)$ if and only if $m=O(n)$.



My question is, is it possible to somehow generalize this thought and say that $f(n,m) = O(f(n,n))$ if some properties hold? Is this even legal, with Big-$O$ notation?



I'm also not sure if my original proofs are correct, so here they are:



Using the multiple variable definition, prove $n cdot m neq O(n^2)$.



Suppose $n cdot m = O(n^2)$, then there exist $c,n_0,m_0 in mathbb{R}_{>0}$ so that $n geq n_0, m geq m_0$ implies $n cdot m leq cn^2$.
But if we look at $n=n_0,m=max(m_0,cn_0+1)$, we have
$$n cdot m = n_0 cdot max(m_0,cn_0+1) geq n_0 cdot (cn_0+1) = cn_0^2+n_0 > cn_0^2$$
This is a contradiction, because $n=n_0 geq n_0$ and $m=max(m_0,cn_0+1) geq m_0$ and so we should have $n cdot m leq cn^2 = cn_0^2$.



Using the single variable definition, prove $n cdot m = O(n^2) iff m=O(n)$.



Suppose $n cdot m = O(n^2)$, then there exist $c,n_0 in mathbb{R}_{>0}$ so that $n geq n_0$ implies $n cdot m leq cn^2$. Divide both sides by $n$, and we have $m leq cn$ for $n geq n_0$, which directly means (by definition) that $m=O(n)$.



Suppose $m = O(n)$, then there exist $c,n_0 in mathbb{R}_{>0}$ so that $n geq n_0$ implies $m leq cn$. Now let's prove $n cdot m = O(n^2)$.
For every $n$ and specifically for every $n geq n_0$,
$$n cdot m leq n cdot cn = cn^2$$
Which directly means (by definition) that $n cdot m = O(n^2)$.










share|cite|improve this question









$endgroup$












  • $begingroup$
    $m$ must depend on $n$ in some way, otherwise $mn=O(n)ne O(n^2)$
    $endgroup$
    – Exodd
    Nov 30 '18 at 9:34










  • $begingroup$
    Yes. As I wrote, we think of m as a function of n.
    $endgroup$
    – user554564
    Nov 30 '18 at 10:18














0












0








0





$begingroup$


I came across the following statement in my Computer Science high-school textbook (I translated it to English).



There was some for loop that runs $m$ times nested inside a for loop that runs $n$ times, and it said:



"The function is $n cdot m$, and since $n$ and $m$ are as large as we want, we can set $m$ equal to $n$ and say that the complexity is $O(n^2).$"



Obviously I was suspicious, because $m$ in this case didn't depend on $n$.



So I started thinking about the problem with the big-$O$ definition.



Using the definition of for multiple variables, I proved the statement is false by contradiction.



I also thought about using the definition for a single variable, with $m$ as a function of $n$. I was able to prove that $n cdot m = O(n^2)$ if and only if $m=O(n)$.



My question is, is it possible to somehow generalize this thought and say that $f(n,m) = O(f(n,n))$ if some properties hold? Is this even legal, with Big-$O$ notation?



I'm also not sure if my original proofs are correct, so here they are:



Using the multiple variable definition, prove $n cdot m neq O(n^2)$.



Suppose $n cdot m = O(n^2)$, then there exist $c,n_0,m_0 in mathbb{R}_{>0}$ so that $n geq n_0, m geq m_0$ implies $n cdot m leq cn^2$.
But if we look at $n=n_0,m=max(m_0,cn_0+1)$, we have
$$n cdot m = n_0 cdot max(m_0,cn_0+1) geq n_0 cdot (cn_0+1) = cn_0^2+n_0 > cn_0^2$$
This is a contradiction, because $n=n_0 geq n_0$ and $m=max(m_0,cn_0+1) geq m_0$ and so we should have $n cdot m leq cn^2 = cn_0^2$.



Using the single variable definition, prove $n cdot m = O(n^2) iff m=O(n)$.



Suppose $n cdot m = O(n^2)$, then there exist $c,n_0 in mathbb{R}_{>0}$ so that $n geq n_0$ implies $n cdot m leq cn^2$. Divide both sides by $n$, and we have $m leq cn$ for $n geq n_0$, which directly means (by definition) that $m=O(n)$.



Suppose $m = O(n)$, then there exist $c,n_0 in mathbb{R}_{>0}$ so that $n geq n_0$ implies $m leq cn$. Now let's prove $n cdot m = O(n^2)$.
For every $n$ and specifically for every $n geq n_0$,
$$n cdot m leq n cdot cn = cn^2$$
Which directly means (by definition) that $n cdot m = O(n^2)$.










share|cite|improve this question









$endgroup$




I came across the following statement in my Computer Science high-school textbook (I translated it to English).



There was some for loop that runs $m$ times nested inside a for loop that runs $n$ times, and it said:



"The function is $n cdot m$, and since $n$ and $m$ are as large as we want, we can set $m$ equal to $n$ and say that the complexity is $O(n^2).$"



Obviously I was suspicious, because $m$ in this case didn't depend on $n$.



So I started thinking about the problem with the big-$O$ definition.



Using the definition of for multiple variables, I proved the statement is false by contradiction.



I also thought about using the definition for a single variable, with $m$ as a function of $n$. I was able to prove that $n cdot m = O(n^2)$ if and only if $m=O(n)$.



My question is, is it possible to somehow generalize this thought and say that $f(n,m) = O(f(n,n))$ if some properties hold? Is this even legal, with Big-$O$ notation?



I'm also not sure if my original proofs are correct, so here they are:



Using the multiple variable definition, prove $n cdot m neq O(n^2)$.



Suppose $n cdot m = O(n^2)$, then there exist $c,n_0,m_0 in mathbb{R}_{>0}$ so that $n geq n_0, m geq m_0$ implies $n cdot m leq cn^2$.
But if we look at $n=n_0,m=max(m_0,cn_0+1)$, we have
$$n cdot m = n_0 cdot max(m_0,cn_0+1) geq n_0 cdot (cn_0+1) = cn_0^2+n_0 > cn_0^2$$
This is a contradiction, because $n=n_0 geq n_0$ and $m=max(m_0,cn_0+1) geq m_0$ and so we should have $n cdot m leq cn^2 = cn_0^2$.



Using the single variable definition, prove $n cdot m = O(n^2) iff m=O(n)$.



Suppose $n cdot m = O(n^2)$, then there exist $c,n_0 in mathbb{R}_{>0}$ so that $n geq n_0$ implies $n cdot m leq cn^2$. Divide both sides by $n$, and we have $m leq cn$ for $n geq n_0$, which directly means (by definition) that $m=O(n)$.



Suppose $m = O(n)$, then there exist $c,n_0 in mathbb{R}_{>0}$ so that $n geq n_0$ implies $m leq cn$. Now let's prove $n cdot m = O(n^2)$.
For every $n$ and specifically for every $n geq n_0$,
$$n cdot m leq n cdot cn = cn^2$$
Which directly means (by definition) that $n cdot m = O(n^2)$.







asymptotics computer-science computational-complexity






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Nov 30 '18 at 9:14







user554564



















  • $begingroup$
    $m$ must depend on $n$ in some way, otherwise $mn=O(n)ne O(n^2)$
    $endgroup$
    – Exodd
    Nov 30 '18 at 9:34










  • $begingroup$
    Yes. As I wrote, we think of m as a function of n.
    $endgroup$
    – user554564
    Nov 30 '18 at 10:18


















  • $begingroup$
    $m$ must depend on $n$ in some way, otherwise $mn=O(n)ne O(n^2)$
    $endgroup$
    – Exodd
    Nov 30 '18 at 9:34










  • $begingroup$
    Yes. As I wrote, we think of m as a function of n.
    $endgroup$
    – user554564
    Nov 30 '18 at 10:18
















$begingroup$
$m$ must depend on $n$ in some way, otherwise $mn=O(n)ne O(n^2)$
$endgroup$
– Exodd
Nov 30 '18 at 9:34




$begingroup$
$m$ must depend on $n$ in some way, otherwise $mn=O(n)ne O(n^2)$
$endgroup$
– Exodd
Nov 30 '18 at 9:34












$begingroup$
Yes. As I wrote, we think of m as a function of n.
$endgroup$
– user554564
Nov 30 '18 at 10:18




$begingroup$
Yes. As I wrote, we think of m as a function of n.
$endgroup$
– user554564
Nov 30 '18 at 10:18










0






active

oldest

votes











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3019857%2fgeneralizing-n-cdot-m-on2-iff-m-on-to-any-two-variable-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown
























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3019857%2fgeneralizing-n-cdot-m-on2-iff-m-on-to-any-two-variable-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Le Mesnil-Réaume

Ida-Boy-Ed-Garten

web3.py web3.isConnected() returns false always