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{n\over2^{i+1}}\rceil O(i)) = O(n\sum_{i=0}^{\lfloor{logn}\rfloor}{i\over2^{i+1}}) \qquad (2)$$
Assuming I reduce the summation on the LHS to: $$\sum_{i=0}^{\lfloor{logn}\rfloor}O({ni\over2^{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{n\over2^{i+1}}\rceil$ nodes, and on each you invoke a function that runs in $O(i)$.
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{n\over2^{i+1}}\rceil O(i) = \sum_{i=0}^{\lfloor{logn}\rfloor}\lceil{n\over2^{i+1}}\rceil g(i) ,g(x) =O(x)$$
Then $\forall n > n_0$
$$\sum_{i=0}^{\lfloor{logn}\rfloor}\lceil{n\over2^{i+1}}\rceil g(i) \le \sum_{i=0}^{\lfloor{logn}\rfloor}\lceil{n\over2^{i+1}}\rceil ci = {c\over2}n\sum_{i=0}^{\lfloor{logn}\rfloor}\lceil{i\over2^i}\rceil = O(n\sum_{i=0}^{\lfloor{logn}\rfloor}{i\over2^i})$$
Relevant link: https://cs.stackexchange.com/questions/63184/how-does-o-transform-this-sum-like-that?noredirect=1&lq=1