Big O summation and additivity
up vote
1
down vote
favorite
I'm not sure whether the following equality is correct, or rather, whether my interpretation of it is correct:
$$sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i)) qquad (1)$$
The way I interpret the LHS is that $i$ is a function of $n$ and each $f(i)$ becomes essentially a function of n $f(i) = f(i(n))$, so now I am summing a bunch of functions in n and invoke the property:
$$O(f(n)) + O(g(n)) = O(f(n) + g(n))$$
Assuming all functions are positive. This also implies a change of variables; i.e., $O$ on RHS is with respect to $n$. Feels kinda wonky frankly.
Edit:
Here is one transformation from a book that made me think that (1) is a thing (ofc I don't know what their actual reasoning was 'cause they didn't provide any step by step solution):
$$sum_{i=0}^{lfloor{logn}rfloor}(lceil{nover2^{i+1}}rceil O(i)) = O(nsum_{i=0}^{lfloor{logn}rfloor}{iover2^{i+1}}) qquad (2)$$
Assuming I reduce the summation on the LHS to:
$$sum_{i=0}^{lfloor{logn}rfloor}O({niover2^{i+1}})$$
Then I end up with (1)..
As far as I understand, the line of reasoning that produced the LHS of (2) was you loop over $logn$ some levels of a complete binary tree, and on each height $i$ you have max $lceil{nover2^{i+1}}rceil$ nodes, and on each you invoke a function that runs in $O(i)$.
discrete-mathematics asymptotics
|
show 1 more comment
up vote
1
down vote
favorite
I'm not sure whether the following equality is correct, or rather, whether my interpretation of it is correct:
$$sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i)) qquad (1)$$
The way I interpret the LHS is that $i$ is a function of $n$ and each $f(i)$ becomes essentially a function of n $f(i) = f(i(n))$, so now I am summing a bunch of functions in n and invoke the property:
$$O(f(n)) + O(g(n)) = O(f(n) + g(n))$$
Assuming all functions are positive. This also implies a change of variables; i.e., $O$ on RHS is with respect to $n$. Feels kinda wonky frankly.
Edit:
Here is one transformation from a book that made me think that (1) is a thing (ofc I don't know what their actual reasoning was 'cause they didn't provide any step by step solution):
$$sum_{i=0}^{lfloor{logn}rfloor}(lceil{nover2^{i+1}}rceil O(i)) = O(nsum_{i=0}^{lfloor{logn}rfloor}{iover2^{i+1}}) qquad (2)$$
Assuming I reduce the summation on the LHS to:
$$sum_{i=0}^{lfloor{logn}rfloor}O({niover2^{i+1}})$$
Then I end up with (1)..
As far as I understand, the line of reasoning that produced the LHS of (2) was you loop over $logn$ some levels of a complete binary tree, and on each height $i$ you have max $lceil{nover2^{i+1}}rceil$ nodes, and on each you invoke a function that runs in $O(i)$.
discrete-mathematics asymptotics
It seems there is something wrong in that $sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i))$, in which context have you found that?
– gimusi
Nov 26 at 14:20
Well, that's the question. Is it wrong?
– zagortenay333
Nov 26 at 14:21
I'm not sure. In which context did you find that? What $f(1), f(2),...,f(n)$ would represent?
– gimusi
Nov 26 at 14:22
Well, I'm assuming context-free here. I.e., the those are just positive functions from naturals to reals let's say. I did find in some context where it seems like the bound was found that way. I'll give an example above.
– zagortenay333
Nov 26 at 14:25
So the functions are functions of the variable h? Maybe the index $n$ should be equal to $i$?
– gimusi
Nov 26 at 14:41
|
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm not sure whether the following equality is correct, or rather, whether my interpretation of it is correct:
$$sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i)) qquad (1)$$
The way I interpret the LHS is that $i$ is a function of $n$ and each $f(i)$ becomes essentially a function of n $f(i) = f(i(n))$, so now I am summing a bunch of functions in n and invoke the property:
$$O(f(n)) + O(g(n)) = O(f(n) + g(n))$$
Assuming all functions are positive. This also implies a change of variables; i.e., $O$ on RHS is with respect to $n$. Feels kinda wonky frankly.
Edit:
Here is one transformation from a book that made me think that (1) is a thing (ofc I don't know what their actual reasoning was 'cause they didn't provide any step by step solution):
$$sum_{i=0}^{lfloor{logn}rfloor}(lceil{nover2^{i+1}}rceil O(i)) = O(nsum_{i=0}^{lfloor{logn}rfloor}{iover2^{i+1}}) qquad (2)$$
Assuming I reduce the summation on the LHS to:
$$sum_{i=0}^{lfloor{logn}rfloor}O({niover2^{i+1}})$$
Then I end up with (1)..
As far as I understand, the line of reasoning that produced the LHS of (2) was you loop over $logn$ some levels of a complete binary tree, and on each height $i$ you have max $lceil{nover2^{i+1}}rceil$ nodes, and on each you invoke a function that runs in $O(i)$.
discrete-mathematics asymptotics
I'm not sure whether the following equality is correct, or rather, whether my interpretation of it is correct:
$$sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i)) qquad (1)$$
The way I interpret the LHS is that $i$ is a function of $n$ and each $f(i)$ becomes essentially a function of n $f(i) = f(i(n))$, so now I am summing a bunch of functions in n and invoke the property:
$$O(f(n)) + O(g(n)) = O(f(n) + g(n))$$
Assuming all functions are positive. This also implies a change of variables; i.e., $O$ on RHS is with respect to $n$. Feels kinda wonky frankly.
Edit:
Here is one transformation from a book that made me think that (1) is a thing (ofc I don't know what their actual reasoning was 'cause they didn't provide any step by step solution):
$$sum_{i=0}^{lfloor{logn}rfloor}(lceil{nover2^{i+1}}rceil O(i)) = O(nsum_{i=0}^{lfloor{logn}rfloor}{iover2^{i+1}}) qquad (2)$$
Assuming I reduce the summation on the LHS to:
$$sum_{i=0}^{lfloor{logn}rfloor}O({niover2^{i+1}})$$
Then I end up with (1)..
As far as I understand, the line of reasoning that produced the LHS of (2) was you loop over $logn$ some levels of a complete binary tree, and on each height $i$ you have max $lceil{nover2^{i+1}}rceil$ nodes, and on each you invoke a function that runs in $O(i)$.
discrete-mathematics asymptotics
discrete-mathematics asymptotics
edited Nov 26 at 14:57
asked Nov 26 at 13:27
zagortenay333
1147
1147
It seems there is something wrong in that $sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i))$, in which context have you found that?
– gimusi
Nov 26 at 14:20
Well, that's the question. Is it wrong?
– zagortenay333
Nov 26 at 14:21
I'm not sure. In which context did you find that? What $f(1), f(2),...,f(n)$ would represent?
– gimusi
Nov 26 at 14:22
Well, I'm assuming context-free here. I.e., the those are just positive functions from naturals to reals let's say. I did find in some context where it seems like the bound was found that way. I'll give an example above.
– zagortenay333
Nov 26 at 14:25
So the functions are functions of the variable h? Maybe the index $n$ should be equal to $i$?
– gimusi
Nov 26 at 14:41
|
show 1 more comment
It seems there is something wrong in that $sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i))$, in which context have you found that?
– gimusi
Nov 26 at 14:20
Well, that's the question. Is it wrong?
– zagortenay333
Nov 26 at 14:21
I'm not sure. In which context did you find that? What $f(1), f(2),...,f(n)$ would represent?
– gimusi
Nov 26 at 14:22
Well, I'm assuming context-free here. I.e., the those are just positive functions from naturals to reals let's say. I did find in some context where it seems like the bound was found that way. I'll give an example above.
– zagortenay333
Nov 26 at 14:25
So the functions are functions of the variable h? Maybe the index $n$ should be equal to $i$?
– gimusi
Nov 26 at 14:41
It seems there is something wrong in that $sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i))$, in which context have you found that?
– gimusi
Nov 26 at 14:20
It seems there is something wrong in that $sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i))$, in which context have you found that?
– gimusi
Nov 26 at 14:20
Well, that's the question. Is it wrong?
– zagortenay333
Nov 26 at 14:21
Well, that's the question. Is it wrong?
– zagortenay333
Nov 26 at 14:21
I'm not sure. In which context did you find that? What $f(1), f(2),...,f(n)$ would represent?
– gimusi
Nov 26 at 14:22
I'm not sure. In which context did you find that? What $f(1), f(2),...,f(n)$ would represent?
– gimusi
Nov 26 at 14:22
Well, I'm assuming context-free here. I.e., the those are just positive functions from naturals to reals let's say. I did find in some context where it seems like the bound was found that way. I'll give an example above.
– zagortenay333
Nov 26 at 14:25
Well, I'm assuming context-free here. I.e., the those are just positive functions from naturals to reals let's say. I did find in some context where it seems like the bound was found that way. I'll give an example above.
– zagortenay333
Nov 26 at 14:25
So the functions are functions of the variable h? Maybe the index $n$ should be equal to $i$?
– gimusi
Nov 26 at 14:41
So the functions are functions of the variable h? Maybe the index $n$ should be equal to $i$?
– gimusi
Nov 26 at 14:41
|
show 1 more comment
3 Answers
3
active
oldest
votes
up vote
0
down vote
In the left-hand side
$$sum_{i=0}^n O(f(i)),$$
the arguments of the $O$ terms are constants (they do not depend on $n$) so that the notation $$O(f(i))$$ is essentially meaningless.
E.g. let use take $f(i):= i^2$. Then
$$O(0)+O(1)+O(4)+O(9)+cdots O(n^2)$$ is absurd.
I agree it makes no sense. See the edit I added above that explains how I ended up with the expression on the LHS side.
– zagortenay333
Nov 26 at 14:58
@zagortenay333: not much better. All the $O(n f(i))$ terms can be replaced by $O(n)$, as multiplicative constants do not matter. This leads you nowhere.
– Yves Daoust
Nov 26 at 15:22
@YvesDaoust: A proper meaning is stated around formula (9.16) in Concrete Mathematics.
– Markus Scheuer
Dec 1 at 21:41
add a comment |
up vote
0
down vote
accepted
Alright, I did some research (should have done before I asked..). The above equality (1) out of context is meaningless. It seems that the convention is that:
$$sum_{i=0}^n O(f(i)) := sum_{i=0}^n g(i) qquad ,g(x) = O(f(x))$$
Where a all g's have the same constant. Then sometimes the above equality (1) appears to be "true":
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil O(i) = sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) ,g(x) =O(x)$$
Then $forall n > n_0$
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) le sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil ci = {cover2}nsum_{i=0}^{lfloor{logn}rfloor}lceil{iover2^i}rceil = O(nsum_{i=0}^{lfloor{logn}rfloor}{iover2^i})$$
Relevant link: https://cs.stackexchange.com/questions/63184/how-does-o-transform-this-sum-like-that?noredirect=1&lq=1
add a comment |
up vote
0
down vote
We assume $f$ is a non-negative function and consider
begin{align*}
sum_{i=0}^n O(f(i)) = Oleft(sum_{i=0}^n f(i)right)qquadqquad ngeq 0tag{1}
end{align*}
The left-hand side of (1) has the following meaning:
The expression $O(f(i))$ stands for the set of all two-variable functions of the form $g(f(i),n)$ such that there exists a constant $C>0$ with $|g(f(i),n)|leq Cf(i)$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $h(n)$ of the form
begin{align*}
h(n)&=sum_{i=0}^ng(f(i),n)\
&=g(f(0),n)+g(f(1),n)+cdots g(f(n),n)tag{2}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^ng(f(i),n)right|&leq left|sum_{i=0}^nCf(i)right|\
&=Csum_{i=0}^nf(i)
end{align*}
It follows all such functions $h(n)$ belong to the right-hand side of (1); therefore (1) is true.
The meaning of the left-hand side of (1) is stated in section 9.2 $O$ Notation of Concrete Mathematics
by R.L. Graham, D.E. Knuth and O. Patashnik. A corresponding sum is given as (9.16).
We are now ready to calculate
begin{align*}
sum_{i=0}^{leftlfloor log_2 nrightrfloor}left(leftlceilfrac{n}{2^{i+1}}rightrceil O(i)right)
=Oleft(nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}right)tag{2}
end{align*}
We use for convenient calculation $log_2$ as upper limit of the sum.
The summand at the left-hand side of (2) stands for the set of all two-variable functions of the form $leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)$ such that there exists a constant $C>0$ with $|f(i,n)|leq Ccdot i$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $g(n)$ of the form
begin{align*}
g(n)=sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)tag{3}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)right|
&leq left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil Ccdot iright|\
&= Cleft|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil iright|\
&leq 2C nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}tag{4}
end{align*}
It follows all such functions $g(n)$ belong to the right-hand side of (2) and the claim (2) follows.
Comment: In (4) we use that $frac{n}{2^{i+1}}geq frac{1}{2}$ if $0leq ileqleftlfloor log_2 nrightrfloor$, so that we can use a factor $2$ to get an upper bound.
This is definitely a different definition from the one I showed below. This definition assumes that the functions represented by $sum{O(g(n))}$ are already bounded for all $0le k le n$. This is weird..
– zagortenay333
Dec 2 at 10:57
Also, shouldn't in (1) $sum{O(f(n))}$ refer to the set of all functions of the form $g(i, n)$, not $g(f(i), n)$?
– zagortenay333
Dec 2 at 10:58
Also, the definition given by me refers to a single anonymous function, not a set.
– zagortenay333
Dec 2 at 11:00
add a comment |
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',
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3014335%2fbig-o-summation-and-additivity%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
In the left-hand side
$$sum_{i=0}^n O(f(i)),$$
the arguments of the $O$ terms are constants (they do not depend on $n$) so that the notation $$O(f(i))$$ is essentially meaningless.
E.g. let use take $f(i):= i^2$. Then
$$O(0)+O(1)+O(4)+O(9)+cdots O(n^2)$$ is absurd.
I agree it makes no sense. See the edit I added above that explains how I ended up with the expression on the LHS side.
– zagortenay333
Nov 26 at 14:58
@zagortenay333: not much better. All the $O(n f(i))$ terms can be replaced by $O(n)$, as multiplicative constants do not matter. This leads you nowhere.
– Yves Daoust
Nov 26 at 15:22
@YvesDaoust: A proper meaning is stated around formula (9.16) in Concrete Mathematics.
– Markus Scheuer
Dec 1 at 21:41
add a comment |
up vote
0
down vote
In the left-hand side
$$sum_{i=0}^n O(f(i)),$$
the arguments of the $O$ terms are constants (they do not depend on $n$) so that the notation $$O(f(i))$$ is essentially meaningless.
E.g. let use take $f(i):= i^2$. Then
$$O(0)+O(1)+O(4)+O(9)+cdots O(n^2)$$ is absurd.
I agree it makes no sense. See the edit I added above that explains how I ended up with the expression on the LHS side.
– zagortenay333
Nov 26 at 14:58
@zagortenay333: not much better. All the $O(n f(i))$ terms can be replaced by $O(n)$, as multiplicative constants do not matter. This leads you nowhere.
– Yves Daoust
Nov 26 at 15:22
@YvesDaoust: A proper meaning is stated around formula (9.16) in Concrete Mathematics.
– Markus Scheuer
Dec 1 at 21:41
add a comment |
up vote
0
down vote
up vote
0
down vote
In the left-hand side
$$sum_{i=0}^n O(f(i)),$$
the arguments of the $O$ terms are constants (they do not depend on $n$) so that the notation $$O(f(i))$$ is essentially meaningless.
E.g. let use take $f(i):= i^2$. Then
$$O(0)+O(1)+O(4)+O(9)+cdots O(n^2)$$ is absurd.
In the left-hand side
$$sum_{i=0}^n O(f(i)),$$
the arguments of the $O$ terms are constants (they do not depend on $n$) so that the notation $$O(f(i))$$ is essentially meaningless.
E.g. let use take $f(i):= i^2$. Then
$$O(0)+O(1)+O(4)+O(9)+cdots O(n^2)$$ is absurd.
answered Nov 26 at 14:45
Yves Daoust
123k668219
123k668219
I agree it makes no sense. See the edit I added above that explains how I ended up with the expression on the LHS side.
– zagortenay333
Nov 26 at 14:58
@zagortenay333: not much better. All the $O(n f(i))$ terms can be replaced by $O(n)$, as multiplicative constants do not matter. This leads you nowhere.
– Yves Daoust
Nov 26 at 15:22
@YvesDaoust: A proper meaning is stated around formula (9.16) in Concrete Mathematics.
– Markus Scheuer
Dec 1 at 21:41
add a comment |
I agree it makes no sense. See the edit I added above that explains how I ended up with the expression on the LHS side.
– zagortenay333
Nov 26 at 14:58
@zagortenay333: not much better. All the $O(n f(i))$ terms can be replaced by $O(n)$, as multiplicative constants do not matter. This leads you nowhere.
– Yves Daoust
Nov 26 at 15:22
@YvesDaoust: A proper meaning is stated around formula (9.16) in Concrete Mathematics.
– Markus Scheuer
Dec 1 at 21:41
I agree it makes no sense. See the edit I added above that explains how I ended up with the expression on the LHS side.
– zagortenay333
Nov 26 at 14:58
I agree it makes no sense. See the edit I added above that explains how I ended up with the expression on the LHS side.
– zagortenay333
Nov 26 at 14:58
@zagortenay333: not much better. All the $O(n f(i))$ terms can be replaced by $O(n)$, as multiplicative constants do not matter. This leads you nowhere.
– Yves Daoust
Nov 26 at 15:22
@zagortenay333: not much better. All the $O(n f(i))$ terms can be replaced by $O(n)$, as multiplicative constants do not matter. This leads you nowhere.
– Yves Daoust
Nov 26 at 15:22
@YvesDaoust: A proper meaning is stated around formula (9.16) in Concrete Mathematics.
– Markus Scheuer
Dec 1 at 21:41
@YvesDaoust: A proper meaning is stated around formula (9.16) in Concrete Mathematics.
– Markus Scheuer
Dec 1 at 21:41
add a comment |
up vote
0
down vote
accepted
Alright, I did some research (should have done before I asked..). The above equality (1) out of context is meaningless. It seems that the convention is that:
$$sum_{i=0}^n O(f(i)) := sum_{i=0}^n g(i) qquad ,g(x) = O(f(x))$$
Where a all g's have the same constant. Then sometimes the above equality (1) appears to be "true":
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil O(i) = sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) ,g(x) =O(x)$$
Then $forall n > n_0$
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) le sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil ci = {cover2}nsum_{i=0}^{lfloor{logn}rfloor}lceil{iover2^i}rceil = O(nsum_{i=0}^{lfloor{logn}rfloor}{iover2^i})$$
Relevant link: https://cs.stackexchange.com/questions/63184/how-does-o-transform-this-sum-like-that?noredirect=1&lq=1
add a comment |
up vote
0
down vote
accepted
Alright, I did some research (should have done before I asked..). The above equality (1) out of context is meaningless. It seems that the convention is that:
$$sum_{i=0}^n O(f(i)) := sum_{i=0}^n g(i) qquad ,g(x) = O(f(x))$$
Where a all g's have the same constant. Then sometimes the above equality (1) appears to be "true":
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil O(i) = sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) ,g(x) =O(x)$$
Then $forall n > n_0$
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) le sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil ci = {cover2}nsum_{i=0}^{lfloor{logn}rfloor}lceil{iover2^i}rceil = O(nsum_{i=0}^{lfloor{logn}rfloor}{iover2^i})$$
Relevant link: https://cs.stackexchange.com/questions/63184/how-does-o-transform-this-sum-like-that?noredirect=1&lq=1
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Alright, I did some research (should have done before I asked..). The above equality (1) out of context is meaningless. It seems that the convention is that:
$$sum_{i=0}^n O(f(i)) := sum_{i=0}^n g(i) qquad ,g(x) = O(f(x))$$
Where a all g's have the same constant. Then sometimes the above equality (1) appears to be "true":
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil O(i) = sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) ,g(x) =O(x)$$
Then $forall n > n_0$
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) le sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil ci = {cover2}nsum_{i=0}^{lfloor{logn}rfloor}lceil{iover2^i}rceil = O(nsum_{i=0}^{lfloor{logn}rfloor}{iover2^i})$$
Relevant link: https://cs.stackexchange.com/questions/63184/how-does-o-transform-this-sum-like-that?noredirect=1&lq=1
Alright, I did some research (should have done before I asked..). The above equality (1) out of context is meaningless. It seems that the convention is that:
$$sum_{i=0}^n O(f(i)) := sum_{i=0}^n g(i) qquad ,g(x) = O(f(x))$$
Where a all g's have the same constant. Then sometimes the above equality (1) appears to be "true":
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil O(i) = sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) ,g(x) =O(x)$$
Then $forall n > n_0$
$$sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil g(i) le sum_{i=0}^{lfloor{logn}rfloor}lceil{nover2^{i+1}}rceil ci = {cover2}nsum_{i=0}^{lfloor{logn}rfloor}lceil{iover2^i}rceil = O(nsum_{i=0}^{lfloor{logn}rfloor}{iover2^i})$$
Relevant link: https://cs.stackexchange.com/questions/63184/how-does-o-transform-this-sum-like-that?noredirect=1&lq=1
answered Nov 26 at 17:15
zagortenay333
1147
1147
add a comment |
add a comment |
up vote
0
down vote
We assume $f$ is a non-negative function and consider
begin{align*}
sum_{i=0}^n O(f(i)) = Oleft(sum_{i=0}^n f(i)right)qquadqquad ngeq 0tag{1}
end{align*}
The left-hand side of (1) has the following meaning:
The expression $O(f(i))$ stands for the set of all two-variable functions of the form $g(f(i),n)$ such that there exists a constant $C>0$ with $|g(f(i),n)|leq Cf(i)$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $h(n)$ of the form
begin{align*}
h(n)&=sum_{i=0}^ng(f(i),n)\
&=g(f(0),n)+g(f(1),n)+cdots g(f(n),n)tag{2}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^ng(f(i),n)right|&leq left|sum_{i=0}^nCf(i)right|\
&=Csum_{i=0}^nf(i)
end{align*}
It follows all such functions $h(n)$ belong to the right-hand side of (1); therefore (1) is true.
The meaning of the left-hand side of (1) is stated in section 9.2 $O$ Notation of Concrete Mathematics
by R.L. Graham, D.E. Knuth and O. Patashnik. A corresponding sum is given as (9.16).
We are now ready to calculate
begin{align*}
sum_{i=0}^{leftlfloor log_2 nrightrfloor}left(leftlceilfrac{n}{2^{i+1}}rightrceil O(i)right)
=Oleft(nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}right)tag{2}
end{align*}
We use for convenient calculation $log_2$ as upper limit of the sum.
The summand at the left-hand side of (2) stands for the set of all two-variable functions of the form $leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)$ such that there exists a constant $C>0$ with $|f(i,n)|leq Ccdot i$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $g(n)$ of the form
begin{align*}
g(n)=sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)tag{3}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)right|
&leq left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil Ccdot iright|\
&= Cleft|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil iright|\
&leq 2C nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}tag{4}
end{align*}
It follows all such functions $g(n)$ belong to the right-hand side of (2) and the claim (2) follows.
Comment: In (4) we use that $frac{n}{2^{i+1}}geq frac{1}{2}$ if $0leq ileqleftlfloor log_2 nrightrfloor$, so that we can use a factor $2$ to get an upper bound.
This is definitely a different definition from the one I showed below. This definition assumes that the functions represented by $sum{O(g(n))}$ are already bounded for all $0le k le n$. This is weird..
– zagortenay333
Dec 2 at 10:57
Also, shouldn't in (1) $sum{O(f(n))}$ refer to the set of all functions of the form $g(i, n)$, not $g(f(i), n)$?
– zagortenay333
Dec 2 at 10:58
Also, the definition given by me refers to a single anonymous function, not a set.
– zagortenay333
Dec 2 at 11:00
add a comment |
up vote
0
down vote
We assume $f$ is a non-negative function and consider
begin{align*}
sum_{i=0}^n O(f(i)) = Oleft(sum_{i=0}^n f(i)right)qquadqquad ngeq 0tag{1}
end{align*}
The left-hand side of (1) has the following meaning:
The expression $O(f(i))$ stands for the set of all two-variable functions of the form $g(f(i),n)$ such that there exists a constant $C>0$ with $|g(f(i),n)|leq Cf(i)$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $h(n)$ of the form
begin{align*}
h(n)&=sum_{i=0}^ng(f(i),n)\
&=g(f(0),n)+g(f(1),n)+cdots g(f(n),n)tag{2}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^ng(f(i),n)right|&leq left|sum_{i=0}^nCf(i)right|\
&=Csum_{i=0}^nf(i)
end{align*}
It follows all such functions $h(n)$ belong to the right-hand side of (1); therefore (1) is true.
The meaning of the left-hand side of (1) is stated in section 9.2 $O$ Notation of Concrete Mathematics
by R.L. Graham, D.E. Knuth and O. Patashnik. A corresponding sum is given as (9.16).
We are now ready to calculate
begin{align*}
sum_{i=0}^{leftlfloor log_2 nrightrfloor}left(leftlceilfrac{n}{2^{i+1}}rightrceil O(i)right)
=Oleft(nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}right)tag{2}
end{align*}
We use for convenient calculation $log_2$ as upper limit of the sum.
The summand at the left-hand side of (2) stands for the set of all two-variable functions of the form $leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)$ such that there exists a constant $C>0$ with $|f(i,n)|leq Ccdot i$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $g(n)$ of the form
begin{align*}
g(n)=sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)tag{3}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)right|
&leq left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil Ccdot iright|\
&= Cleft|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil iright|\
&leq 2C nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}tag{4}
end{align*}
It follows all such functions $g(n)$ belong to the right-hand side of (2) and the claim (2) follows.
Comment: In (4) we use that $frac{n}{2^{i+1}}geq frac{1}{2}$ if $0leq ileqleftlfloor log_2 nrightrfloor$, so that we can use a factor $2$ to get an upper bound.
This is definitely a different definition from the one I showed below. This definition assumes that the functions represented by $sum{O(g(n))}$ are already bounded for all $0le k le n$. This is weird..
– zagortenay333
Dec 2 at 10:57
Also, shouldn't in (1) $sum{O(f(n))}$ refer to the set of all functions of the form $g(i, n)$, not $g(f(i), n)$?
– zagortenay333
Dec 2 at 10:58
Also, the definition given by me refers to a single anonymous function, not a set.
– zagortenay333
Dec 2 at 11:00
add a comment |
up vote
0
down vote
up vote
0
down vote
We assume $f$ is a non-negative function and consider
begin{align*}
sum_{i=0}^n O(f(i)) = Oleft(sum_{i=0}^n f(i)right)qquadqquad ngeq 0tag{1}
end{align*}
The left-hand side of (1) has the following meaning:
The expression $O(f(i))$ stands for the set of all two-variable functions of the form $g(f(i),n)$ such that there exists a constant $C>0$ with $|g(f(i),n)|leq Cf(i)$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $h(n)$ of the form
begin{align*}
h(n)&=sum_{i=0}^ng(f(i),n)\
&=g(f(0),n)+g(f(1),n)+cdots g(f(n),n)tag{2}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^ng(f(i),n)right|&leq left|sum_{i=0}^nCf(i)right|\
&=Csum_{i=0}^nf(i)
end{align*}
It follows all such functions $h(n)$ belong to the right-hand side of (1); therefore (1) is true.
The meaning of the left-hand side of (1) is stated in section 9.2 $O$ Notation of Concrete Mathematics
by R.L. Graham, D.E. Knuth and O. Patashnik. A corresponding sum is given as (9.16).
We are now ready to calculate
begin{align*}
sum_{i=0}^{leftlfloor log_2 nrightrfloor}left(leftlceilfrac{n}{2^{i+1}}rightrceil O(i)right)
=Oleft(nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}right)tag{2}
end{align*}
We use for convenient calculation $log_2$ as upper limit of the sum.
The summand at the left-hand side of (2) stands for the set of all two-variable functions of the form $leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)$ such that there exists a constant $C>0$ with $|f(i,n)|leq Ccdot i$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $g(n)$ of the form
begin{align*}
g(n)=sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)tag{3}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)right|
&leq left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil Ccdot iright|\
&= Cleft|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil iright|\
&leq 2C nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}tag{4}
end{align*}
It follows all such functions $g(n)$ belong to the right-hand side of (2) and the claim (2) follows.
Comment: In (4) we use that $frac{n}{2^{i+1}}geq frac{1}{2}$ if $0leq ileqleftlfloor log_2 nrightrfloor$, so that we can use a factor $2$ to get an upper bound.
We assume $f$ is a non-negative function and consider
begin{align*}
sum_{i=0}^n O(f(i)) = Oleft(sum_{i=0}^n f(i)right)qquadqquad ngeq 0tag{1}
end{align*}
The left-hand side of (1) has the following meaning:
The expression $O(f(i))$ stands for the set of all two-variable functions of the form $g(f(i),n)$ such that there exists a constant $C>0$ with $|g(f(i),n)|leq Cf(i)$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $h(n)$ of the form
begin{align*}
h(n)&=sum_{i=0}^ng(f(i),n)\
&=g(f(0),n)+g(f(1),n)+cdots g(f(n),n)tag{2}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^ng(f(i),n)right|&leq left|sum_{i=0}^nCf(i)right|\
&=Csum_{i=0}^nf(i)
end{align*}
It follows all such functions $h(n)$ belong to the right-hand side of (1); therefore (1) is true.
The meaning of the left-hand side of (1) is stated in section 9.2 $O$ Notation of Concrete Mathematics
by R.L. Graham, D.E. Knuth and O. Patashnik. A corresponding sum is given as (9.16).
We are now ready to calculate
begin{align*}
sum_{i=0}^{leftlfloor log_2 nrightrfloor}left(leftlceilfrac{n}{2^{i+1}}rightrceil O(i)right)
=Oleft(nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}right)tag{2}
end{align*}
We use for convenient calculation $log_2$ as upper limit of the sum.
The summand at the left-hand side of (2) stands for the set of all two-variable functions of the form $leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)$ such that there exists a constant $C>0$ with $|f(i,n)|leq Ccdot i$ for $0leq ileq n$.
The sum of this set of functions, for $0leq ileq n$, is the set of all functions $g(n)$ of the form
begin{align*}
g(n)=sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)tag{3}
end{align*}
We obtain
begin{align*}
left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil f(i,n)right|
&leq left|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil Ccdot iright|\
&= Cleft|sum_{i=0}^{leftlfloor log_2 nrightrfloor}leftlceilfrac{n}{2^{i+1}}rightrceil iright|\
&leq 2C nsum_{i=0}^{leftlfloor log_2 nrightrfloor}frac{i}{2^{i+1}}tag{4}
end{align*}
It follows all such functions $g(n)$ belong to the right-hand side of (2) and the claim (2) follows.
Comment: In (4) we use that $frac{n}{2^{i+1}}geq frac{1}{2}$ if $0leq ileqleftlfloor log_2 nrightrfloor$, so that we can use a factor $2$ to get an upper bound.
edited Dec 1 at 21:44
answered Dec 1 at 21:38
Markus Scheuer
59.7k455142
59.7k455142
This is definitely a different definition from the one I showed below. This definition assumes that the functions represented by $sum{O(g(n))}$ are already bounded for all $0le k le n$. This is weird..
– zagortenay333
Dec 2 at 10:57
Also, shouldn't in (1) $sum{O(f(n))}$ refer to the set of all functions of the form $g(i, n)$, not $g(f(i), n)$?
– zagortenay333
Dec 2 at 10:58
Also, the definition given by me refers to a single anonymous function, not a set.
– zagortenay333
Dec 2 at 11:00
add a comment |
This is definitely a different definition from the one I showed below. This definition assumes that the functions represented by $sum{O(g(n))}$ are already bounded for all $0le k le n$. This is weird..
– zagortenay333
Dec 2 at 10:57
Also, shouldn't in (1) $sum{O(f(n))}$ refer to the set of all functions of the form $g(i, n)$, not $g(f(i), n)$?
– zagortenay333
Dec 2 at 10:58
Also, the definition given by me refers to a single anonymous function, not a set.
– zagortenay333
Dec 2 at 11:00
This is definitely a different definition from the one I showed below. This definition assumes that the functions represented by $sum{O(g(n))}$ are already bounded for all $0le k le n$. This is weird..
– zagortenay333
Dec 2 at 10:57
This is definitely a different definition from the one I showed below. This definition assumes that the functions represented by $sum{O(g(n))}$ are already bounded for all $0le k le n$. This is weird..
– zagortenay333
Dec 2 at 10:57
Also, shouldn't in (1) $sum{O(f(n))}$ refer to the set of all functions of the form $g(i, n)$, not $g(f(i), n)$?
– zagortenay333
Dec 2 at 10:58
Also, shouldn't in (1) $sum{O(f(n))}$ refer to the set of all functions of the form $g(i, n)$, not $g(f(i), n)$?
– zagortenay333
Dec 2 at 10:58
Also, the definition given by me refers to a single anonymous function, not a set.
– zagortenay333
Dec 2 at 11:00
Also, the definition given by me refers to a single anonymous function, not a set.
– zagortenay333
Dec 2 at 11:00
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3014335%2fbig-o-summation-and-additivity%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
It seems there is something wrong in that $sum_{i=0}^n O(f(i)) = O(sum_{i=0}^n f(i))$, in which context have you found that?
– gimusi
Nov 26 at 14:20
Well, that's the question. Is it wrong?
– zagortenay333
Nov 26 at 14:21
I'm not sure. In which context did you find that? What $f(1), f(2),...,f(n)$ would represent?
– gimusi
Nov 26 at 14:22
Well, I'm assuming context-free here. I.e., the those are just positive functions from naturals to reals let's say. I did find in some context where it seems like the bound was found that way. I'll give an example above.
– zagortenay333
Nov 26 at 14:25
So the functions are functions of the variable h? Maybe the index $n$ should be equal to $i$?
– gimusi
Nov 26 at 14:41