I've been working on trying to figure out the titular sum, $\sum_{i = 1}^{n} \sum_{j = i + 1}^{n} (j - i)$, which has an analytical solution by the Wolfram-Alpha output here. However, I have not been able to replicate this fully." line2 = "I began by swapping the order of summation and splitting terms, which lead me to the following: $$ \begin{align*} \sum_{i = 1}^{n} \sum_{j = i + 1}^{n} (j - i) &= \left(\sum_{i = 1}^{n} \sum_{j = i + 1}^{n} j\right) - \left(\sum_{i = 1}^{n} \sum_{j = i + 1}^{n} i\right) \\ &= \left(\sum_{j = i + 1}^{n}\sum_{i = 1}^{n} j\right) - \left(\sum_{i = 1}^{n} \sum_{j = i + 1}^{n} i\right) \\ &= \left(\sum_{j = i + 1}^{n} nj \right) - \left(\sum_{i = 1}^{n} (n - i) i\right) \\ &= n\sum_{j = i + 1}^{n} j - \left(n\sum_{i = 1}^{n}i \right) + \left(\sum_{i = 1}^{n} i^2 \right) \end{align*} $$ However, I do not know how to proceed further from here. I know the last two terms have closed form expressions (sum of integers/sum of squares), but I am not able to get the expression that Wolfram has produced. The first term, in particular, I am not sure how to handle. I considered using the arithmetic series formula, but could not get it to cancel.
1 Answers
As Gary says in the comments, you have an error on line 2.
We can do the following. Let $k = j-i$. Then the inner summations goes from $k = 1$ to $k = n-i$. Thus, we have that
$$ \sum_{i=1}^n\sum_{j = i+1}^n(j-i) = \sum_{i=1}^n \sum_{k=1}^{n-i}k = \sum_{i=1}^n \frac{(n-i)(n-i+1)}{2} = \sum_{i=1}^n \frac{n^2+i^2-2ni+n-i}{2}. $$
Lets evaluate each of these.
$$\sum_{i=1}^n \frac{n^2}{2} = \frac{n^3}{2}.$$
$$\sum_{i=1}^n \frac{n}{2} = \frac{n^2}{2}.$$
$$-\sum_{i=1}^n ni = -\frac{n^2(n+1)}{2} = -\frac{n^3+n^2}{2}.$$
$$ -\sum_{i=1}^n \frac{i}{2} = -\frac{n^2+n}{4}.$$
$$\sum_{i=1}^n \frac{i^2}{2} = \frac{n(n+1)(2n+1)}{12} = \frac{2n^3+3n^2+n}{12}.$$
Note that the terms in the first three equations cancel completely. Finally, we have
$$\frac{2n^3+3n^2+n}{12} - \frac{n^2+n}{4} = \frac{2n^3-2n}{12} =\frac{1}{6}n(n^2-1).$$
- 1,906