# Math notation for sum of the last $n$ numbers in a vector

I have a vector of numbers, $x_0, x_1, x_2, \dots, x_n$. I'm trying to figure out how I can denote the sum of the last 3 numbers in the vector. For example, consider the vector:

x = [1, 2, 3, 4, 5, 6]


I'm looking for the notation that produces, $4+5+6 = 15$

Is this correct?

$$\sum_{i=0}^n x_{n-i}$$

-
The $n$ over the $\Sigma$ should be replaced by $2$. As it is now it is not even well-defined unless the vector starts with $x_0$. – Stefan Hamcke Sep 2 '13 at 16:17
Thanks, I updated the question with an example problem, which should make things clearer. – turtle Sep 2 '13 at 16:22
@turtle: Stefan's comment about replacing the $n$ at the top of the sum with $2$ is still correct. – Zev Chonoles Sep 2 '13 at 16:26

Your suggestion is $$\sum_{i=0}^{n}x_{n-i}=x_{n}+x_{n-1}+\ldots+x_{0},$$ which is equal to the sum of all terms. Instead, use $$\sum_{i=0}^{m-1}x_{n-i}=x_{n}+x_{n-1}+\ldots+x_{n-\left(m-1\right)}$$ to get the sum of the last $m$ terms in the vector. For example, for the last $3$ terms, $m=3$ and $$\sum_{i=0}^{2}x_{n-i}=x_{n}+x_{n-1}+x_{n-2},$$ as desired.

-

Since your vector $x$ is a vector, you can represent linear quantities in terms of matrix multiplication. I will write your vector as a column $x = \left[ \begin{smallmatrix} x_1 \\ \vdots \\ x_n \end{smallmatrix}\right]$, so that I can multiply it on the left by operators.

Consider the matrix $$A = \left[ \begin{matrix} 1 & 1 & \cdots & 1 \\ 0 & 1 & \ddots & \vdots \\ \vdots & \ddots & \ddots & 1 \\ 0 & \cdots & 0 & 1 \end{matrix} \right]$$ which consists of $1$s on and above the diagonal, and $0$s below the diagonal. Then the product $Ax$ is the vector $$Ax = \left[ \begin{matrix} x_1 + x_2 + \cdots + x_n \\ x_2 + \cdots + x_n \\ \ddots \\ x_{n-1} + x_n \\ x_n \end{matrix}\right]$$ consisting of all the answers to your question.

If you want, say, the $j$th entry in the vector $Ax$, then you can use the $j$th row $A_j$ of $A$ in place of $A$ itself. This is the row with $j-1$ zeros and $n-j+1$ ones. So in your particular case with $n=6$ and $n-j+1 = 3$, you want the 4th row:

$$A_4 x = \left[ \begin{matrix} 0 & 0 & 0 & 1 & 1 & 1 \end{matrix}\right] \left[ \begin{matrix} x_1 \\ x_2 \\ x_3 \\ x_4 \\ x_5 \\ x_6 \end{matrix}\right] = x_4 + x_5 + x_6$$

Here I have adopted the standard abuse of notation in which $1\times 1$ matrices are identified with numbers.

Of course, this answer requires explaining lots of extra notation. It's good if you're planning on doing a lot of manipulation with such sums, but bad if you're just trying to communicate to someone "$x_4 + x_5 + x_6$" or even "$x_m + x_{m+1} + \cdots + x_n$", either of which is completely fine notation.

-

There is nothing special about $i = 0$ so while

$$\sum_{i = 0}^{2} x_{n-i} = x_n + x_{n-1}+x_{n-2}$$

Will give you the sum you want you could also write

$$\sum_{i = n-2}^{n} x_i = x_{n-2}+x_{n-1}+x_n$$

and get the same result.

-