1

I am trying to come up with a fast partial sum for a big series in a program that I am writing in order to simplify some loops. However there is an internal sum inside that to me should be able to be simplified. What would be the partial sum of this be: $$\sum^h_{i=1}\sum^i_{j=1}ij$$

Any help would be much appreciated! Thanks in advance

yosmo78
  • 227

2 Answers2

4

$$ \begin{align*} \sum_{i = 1}^h \sum_{j = 1}^i ij &= \sum_{i = 1}^h i \sum_{j=1}^i j\\ &= \sum_{i=1}^h i \left ( \frac{i(i+1)}{2} \right )\\ &= \frac{1}{2} \sum_{i=1}^h i^3 + i^2\\ &= \frac{1}{2} \left ( \frac{h^2 (h+1)^2}{4} + \frac{h(h+1)(2h+1)}{6} \right ) \end{align*} $$

Of course, you can keep simplifying from here.


I hope this helps ^_^

3

First note that

$$ \begin{align} \left(\sum^h_{i=1}i\right)^2 &= \left(\sum^h_{i=1}i\right) \left(\sum^h_{j=1}j \right) \\ &= \sum^h_{i=1}\sum^h_{j=1}ij \\ &= \sum^h_{i=1}\sum^i_{j=1}ij + \sum^h_{i=1}\sum^h_{j=i}ij \\ &= 2 \sum^h_{i=1}\sum^i_{j=1}ij - \sum^h_{i=1}i^2.\tag1 \end{align} $$

On the other hand (see arithmetic progression)

$$ \sum^h_{i=1}i = \frac{h(h+1)}{2} $$

and (see square pyramidal numbers)

$$ \sum^h_{i=1}i^2 = \frac{h(h+1)(2h+1)}{6}. $$

Substituting into $(1)$

$$ \sum^h_{i=1}\sum^i_{j=1}ij = \frac{h^2(h+1)^2}{8} + \frac{h(h+1)(2h+1)}{12}. $$

Adam Zalcman
  • 3,524