I've stumbled upon this sum while I was studying Knuth's Concrete Mathematics: $$\sum_{0 \le k \lt n} (\sqrt {\lfloor k \rfloor})$$
The derivation the book makes is
$$\sum_{0 \le k \lt n} (\sqrt {\lfloor k \rfloor}) = \sum_{k,m \ge 0}(m[k\lt n][m = \lfloor k \rfloor]) = \sum_{k,m \ge 0}(m[k\lt n][m^2 \le k \lt (m+1)^2) = \sum_{k,m \ge 0}(m[m^2 \le k \lt (m+1)^2 \le n]) + \sum_{k,m \ge 0}(m[m^2 \le k \lt n \lt (m+1)^2])$$
Edit: the square bracket notation (Iversion's notation) means: $$[P(x)] = \begin{cases} 0 & \text{if $P(x)$ is false} \\ 1 & \text{if $P(x)$ is true} \end{cases}$$
I read the book's derivation, but I still find some points difficult to grasp:
- I don't understand why this equivalence holds: $\sum_{k,m \ge 0}(m[k\lt n][m^2 \le k \lt (m+1)^2) = \sum_{k,m \ge 0}(m[m^2 \le k \lt (m+1)^2 \le n]) + \sum_{k,m \ge 0}(m[m^2 \le k \lt n \lt (m+1)^2])$
- I don't understand (or at least I cannot see it at first glance) why if $n=a^2$, $\sum_{k,m \ge 0}(m[m^2 \le k \lt n \lt (m+1)^2]) = 0$
The rest of the reasoning is clear.
Could you please help me understanding those two points?
holds because for each $m$, we can write the set $\{k:m^2\leq k < (m+1)^2\}$ as the disjoint union of the sets $\{k:m^2\leq k < (m+1)^2\leq n\}$ and $\{k:m^2\leq k <n< (m+1)^2\}$ (because exactly one of $(m+1)^2\leq n$ or $n<(m+1)^2$ holds)
holds because there can be no perfect square strictly between $m^2$ and $(m+1)^2$ (because it would imply there is an integer strictly between $m$ and $m+1$)