2

I have been trying to simplify $\sum_{i=1}^{n-2}i(n-1-i)$

i.e - remove the summation, put it in polynomial form

Since $i$ is the changing variable, I don't think this is possible.

I also know that the simplified answer should be in polynomial form with highest degree 3, as this stems from a nested loop time complexity problem in programming.

Is it possible if we rewrite this summation, as it has a kind of symmetrical property.

The second half of the summation is identical to the first half.

Gregory Peck
  • 1,717

4 Answers4

6

It can be written as: $$\sum_{i=1}^{n-2} i(n-1-i) = (n-1)\sum_{i=1}^{n-2} i - \sum_{i=1}^{n-2}i^2 = (n-1)\frac{(n-1)(n-2)}{2} - \frac{(n-2)(n-1)(2n-3)}{6}$$

$$= \frac{1}{6}n(n-1)(n-2) $$

GAVD
  • 7,296
  • 1
  • 16
  • 30
1

Maybe it's useful to see how to get the identities that GAVD gave to us. By partial summation we have $$\sum_{i\leq N}i=N^{2}-\sum_{i\leq N-1}i\left(i+1-i\right)=N^{2}-\sum_{i\leq N-1}i$$ hence $$2\sum_{i\leq N}i=N^{2}+N\Rightarrow\sum_{i\leq N}i=\frac{N^{2}+N}{2}=\frac{\left(N+1\right)N}{2}$$ and again by partial summation $$\sum_{i\leq N}i^{2}=N^{3}-\sum_{i\leq N-1}i\left(\left(i+1\right)^{2}-i^{2}\right)=N^{3}-2\sum_{i\leq N-1}i^{2}+\sum_{i\leq N-1}i$$ hence $$3\sum_{i\leq N}i^{2}=N^{3}+N^{2}+\frac{\left(N-1\right)^{2}+N-1}{2}\Rightarrow\sum_{i\leq N}i^{2}=\frac{2N^{3}+2N^{2}+\left(N-1\right)^{2}+N-1}{6}=\frac{N\left(N+1\right)\left(2N+1\right)}{6}.$$

Marco Cantarini
  • 33,062
  • 2
  • 47
  • 93
1

Here's a combinatorial argument:

Suppose you want to choose three distinct numbers $a<b<c$ among the $n$ numbers $\{1,2,\dots,n\}$. First pick the middle-sized number $$ b \in \{2,\dots,n-1\} . $$ Once $b$ is chosen, you have $b-1$ choices for the smallest number $$ a \in \{1,\dots,b-1\} $$ and you have $n-b$ choices for the largest number $$ c \in \{b+1,\dots,n\} . $$ The total number of ways to pick $a<b<c$ is therefore $$ \sum_{b=2}^{n-1} (b-1)(n-b) , $$ which becomes your sum $$ \sum_{i=1}^{n-2} i(n-1-i) $$ if we let $i=b-1$.

On the other hand, we know that there are $\binom{n}{3}=\frac{n(n-1)(n-2)}{3!}$ ways to choose three numbers out of $n$, so that's what the sum equals.

Hans Lundmark
  • 53,395
1

Using only binomial coefficients: $$\begin{align}\sum_{i=1}^{n-2} i(n+1-i)&=\sum_{i=1}^{n-2}\sum_{j=i}^{n-2}i\\\\ &=\sum_{1\leq i\leq j\leq n-2}i\\\\ &=\sum_{j=1}^{n-2}\sum_{i=1}^j\binom i1\\\\ &=\sum_{i=1}^{n-2}\binom {j+1}2\\\\ &=\binom n3\qquad\blacksquare\end{align}$$