# Why is $\sum_{n=0}^{k}|m-n|=\sum_{n=0}^{m}(m-n)+\sum_{n=m}^{k}(n-m)$? [closed]

The problem is:

Why is $$\sum_{n=0}^{k}|m-n|=\sum_{n=0}^{m}(m-n)+\sum_{n=m}^{k}(n-m)\;?$$

Note that $|m-n|=m-n$ for $n< m$ and $|m-n|=n-m$ for $n\ge m$.The given sum can thus be split as $$\sum_{n=0}^k|m-n|=\sum_{n=0}^{m-1}|m-n|+\sum_{n=m}^{k}|m-n|=\sum_{n=0}^{m-1}(m-n)+\sum_{n=m}^{k}(n-m).$$ The only remaining difference is that the summand for $n=m$ is missing from the first sum. But since $|m-m|=0$, this doesn't matter.

Implicitly, we used $0\le m\le k$ in the above. But the result also holds for $m>k$ or $m<0$, provided one interpretes sums with lower index greater than upper index accordingly.

Try to understand what it means.

The absolute value $| m - n |$ is $m - n$ when $n \le m$ and $n - m$ when $n \ge m$

• You can get $\le$ and $\ge$ with \le and \ge, respectively. Jan 14, 2015 at 15:45

Hint. Recall that $$|u| = \begin{cases} -u, & \text{if u \leq 0} \\ u, & \text{if u \geq 0} \end{cases}$$ thus $$|m-n| = \begin{cases} n-m, & \text{if m \leq n} \\ m-n, & \text{if m \geq n.} \end{cases}$$

\begin{align} \sum_{n=0}^{k}|m-n|&= \sum_{n=0, n \le m}^{k}|m-n| + \sum_{n=0, n \ge m}^{k}|m-n| \\ &= \sum_{n=0}^{m}|m-n| + \sum_{n= m }^{k}|m-n|\\ &= \sum_{n=0}^{m}(m-n) + \sum_{n= m}^{k}(n-m) \end{align}