Definitions
Related Questions

# Summation

[suh-mey-shuhn]
For evaluation of sums in closed form see evaluating sums.
Summation is also a term used to describe a process in synapse biology.

Summation is the addition of a set of numbers; the result is their sum or total. The "numbers" to be summed may be natural numbers, complex numbers, matrices, or still more complicated objects. An infinite sum is a subtle procedure known as a series. Note that the term summation has a special meaning in the context of divergent series related to extrapolation.

## Notation

The summation of 1, 2, and 4 is 1 + 2 + 4 = 7. The sum is 7. Since addition is associative, it does not matter whether we interpret "1 + 2 + 4" as (1 + 2) + 4 or as 1 + (2 + 4); the result is the same, so parentheses are usually omitted in a sum. Finite addition is also commutative, so the order in which the numbers are written does not affect its sum. (For issues with infinite summation, see absolute convergence.)

If a sum has too many terms to be written out individually, the sum may be written with an ellipsis to mark out the missing terms. Thus, the sum of all the natural numbers from 1 to 100 is 1 + 2 + … + 99 + 100 = 5050.

### Capital-sigma notation

Mathematical notation has a special representation for compactly representing summation of many similar terms: the summation symbol, a large upright capital Sigma. This is defined thus:
$sum_\left\{i=m\right\}^n x_i = x_m + x_\left\{m+1\right\} + x_\left\{m+2\right\} +dots+ x_\left\{n-1\right\} + x_n.$

The subscript gives the symbol for an index variable, i. Here, i represents the index of summation; m is the lower bound of summation, and n is the upper bound of summation. Here i = m under the summation symbol means that the index i starts out equal to m. Successive values of i are found by adding 1 to the previous value of i, stopping when i = n. We could as well have used k instead of i, as in

$sum_\left\{k=2\right\}^6 k^2 = 2^2+3^2+4^2+5^2+6^2 = 90$.

Informal writing sometimes omits the definition of the index and bounds of summation when these are clear from context, as in

$sum x_i^2$
which is informally equivalent to
$sum_\left\{i=1\right\}^n x_i^2$.

One often sees generalizations of this notation in which an arbitrary logical condition is supplied, and the sum is intended to be taken over all values satisfying the condition. For example:

$sum_\left\{0le k< 100\right\} f\left(k\right)$
is the sum of f(k) over all (integer) k in the specified range,
$sum_\left\{xin S\right\} f\left(x\right)$
is the sum of f(x) over all elements x in the set S, and
$sum_\left\{d|n\right\};mu\left(d\right)$
is the sum of μ(d) over all integers d dividing n.

(Remark: Although the name of the dummy variable does not matter (by definition), one usually uses letters from the middle of the alphabet (i through q) to denote integers, if there is a risk of confusion. For example, even if there should be no doubt about the interpretation, it could look slightly confusing to many mathematicians to see x instead of k in the above formulae involving k. See also typographical conventions in mathematical formulae.)

There are also ways to generalize the use of many sigma signs. For example,

$sum_\left\{ell,ell\text{'}\right\}$
is the same as
$sum_ellsum_\left\{ell\text{'}\right\}.$

### Programming language notation

Summations can also be represented in a programming language. $sum_\left\{i=m\right\}^\left\{n\right\} x_\left\{i\right\}$ Some languages use a notation for summation similar to the mathematical one. For example, this is Python: sum(x[m:n+1]) and this is Fortran (or Matlab): sum(x(m:n))

and this is J :

`+/x`

In other languages loops are used, as in the following Visual Basic/VBScript program:

`Sum = 0`
`For I = M To N`
`    Sum = Sum + X(I)`
`Next I`
or the following C/C++/C#/Java code, which assumes that the variables `m` and `n` are defined as integer types no wider than `int`, such that `m` ≥ `n`, and that the variable `x` is defined as an array of values of integer type no wider than `int`, containing at least `m` − `n` + 1 defined elements: int i; int sum = 0; for (i = m; i <= n; i++)
`   sum += x[i];`

In some cases a loop can be written more concisely, as in this Perl code: \$sum = 0; \$sum += \$x[\$_] for (\$m..\$n); or these alternative Ruby expressions: x[m..n].inject{|a,b| a+b} x[m..n].inject(0){|a,b| a+b} or in C++, using its standard library: std::accumulate(&x[m], &x[n] + 1, 0) when x is an built-in array or a std::vector.

Note that most of these examples begin by initializing the sum variable to 0, the identity element for addition. (See "special cases" below).

Also note that the traditional $sum$ notation allows for the upper bound to be less than the lower bound. In this case, the index variable is initialized with the upper bound instead of the lower bound, and it is decremented instead of incremented. Since addition is commutative, this might also be accomplished by swapping the upper and lower bound and incrementing in a positive direction as usual.

Also note that the $sum$ notation evaluates to a definite value, while most of the loop constructs used above are only valid in an imperative programming language's statement context, requiring the use of an extra variable to hold the final value. It is the variable which would then be used in a larger expression.

The exact meaning of $sum$, and therefore its translation into a programming language, changes depending on the data type of the subscript and upper bound. In other words, $sum$ is an overloaded symbol.

In the above examples, the subscript of $sum$ was translated into an assignment statement to an index variable at the beginning of a `for` loop. But the subscript is not always an assignment statement. Sometimes the subscript sets up the iterator for a `foreach` loop, and sometimes the subscript is itself an array, with no index variable or iterator provided. Other times, the subscript is merely a Boolean expression that contains an embedded variable, implying to an intelligent human, but not to a dumb computer, that every value of the value should be used where the Boolean expression evaluates to true.

In the example below:

$sum_\left\{xin S\right\} f\left(x\right)$

$x$ is an iterator, which implies a `foreach` loop, but $S$ is a set, which is an array-like data structure that can store values of mixed type. The summation routine for a set would have to account for the fact that it is possible to store non-numerical data in a set.

The return value of $sum$ is a scalar in all examples given above.

### Special cases

It is possible to sum fewer than 2 numbers:

• If one sums the single term x, then the sum is x.
• If one sums zero terms, then the sum is zero, because zero is the identity for addition. This is known as the empty sum.

These degenerate cases are usually only used when the summation notation gives a degenerate result in a special case. For example, if m = n in the definition above, then there is only one term in the sum; if m = n + 1, then there is none.

## Approximation by definite integrals

Many such approximations can be obtained by the following connection between sums and integrals, which holds for any:

increasing function f:

$int_\left\{s=a-1\right\}^\left\{b\right\} f\left(s\right), ds le sum_\left\{i=a\right\}^\left\{b\right\} f\left(i\right) le int_\left\{s=a\right\}^\left\{b+1\right\} f\left(s\right), ds.$

decreasing function f:

$int_\left\{s=a\right\}^\left\{b+1\right\} f\left(s\right), ds le sum_\left\{i=a\right\}^\left\{b\right\} f\left(i\right) le int_\left\{s=a-1\right\}^\left\{b\right\} f\left(s\right), ds.$

For more general approximations, see the Euler–Maclaurin formula.

For functions that are integrable on the interval [a, b], the Riemann sum can be used as an approximation of the definite integral. For example, the following formula is the left Riemann sum with equal partitioning of the interval:

$frac\left\{b-a\right\}\left\{n\right\}sum_\left\{i=0\right\}^\left\{n-1\right\} fleft\left(a+ifrac\left\{b-a\right\}nright\right)approx int_a^b f\left(x\right),dx.$

The accuracy of such an approximation increases with the number n of subintervals, such that:

$lim_\left\{nrightarrow infty\right\} frac\left\{b-a\right\}\left\{n\right\}sum_\left\{i=0\right\}^\left\{n-1\right\} fleft\left(a+ifrac\left\{b-a\right\}nright\right) = int_a^b f\left(x\right),dx.$

## Identities

The following are useful identities:

• $sum_\left\{n=s\right\}^t Csdot f\left(n\right) = Csdot sum_\left\{n=s\right\}^t f\left(n\right)$, where 'C' is a distributed constant. (See Scalar multiplication)
• $sum_\left\{i=s\right\}^n f\left(C\right) = f\left(C\right)sdot f\left(n\right)$, where 'C' is a constant.
• $sum_\left\{n=s\right\}^t f\left(n\right) + sum_\left\{n=s\right\}^\left\{t\right\} g\left(n\right) = sum_\left\{n=s\right\}^t left\left[f\left(n\right) + g\left(n\right)right\right]$
• $sum_\left\{n=s\right\}^t f\left(n\right) = sum_\left\{n=s+p\right\}^\left\{t+p\right\} f\left(n-p\right)$
• $sum_\left\{n=s\right\}^j f\left(n\right) + sum_\left\{n=j+1\right\}^t f\left(n\right) = sum_\left\{n=s\right\}^t f\left(n\right)$
• $sum_\left\{i=m\right\}^n x = \left(n-m+1\right)x$
• $sum_\left\{i=1\right\}^n x = nx$, definition of multiplication where n is an integer multiplier to x
• $sum_\left\{i=m\right\}^n i = frac\left\{\left(n-m+1\right)\left(n+m\right)\right\}\left\{2\right\}$ (see arithmetic series)
• $sum_\left\{i=0\right\}^n i = sum_\left\{i=1\right\}^n i = frac\left\{\left(n\right)\left(n+1\right)\right\}\left\{2\right\}$ (Special case of the arithmetic series)
• $sum_\left\{i=1\right\}^n i^2 = frac\left\{n\left(n+1\right)\left(2n+1\right)\right\}\left\{6\right\} = frac\left\{n^3\right\}\left\{3\right\} + frac\left\{n^2\right\}\left\{2\right\} + frac\left\{n\right\}\left\{6\right\}$
• $sum_\left\{i=1\right\}^n i^3 = left\left(frac\left\{n\left(n+1\right)\right\}\left\{2\right\}right\right)^2 = frac\left\{n^4\right\}\left\{4\right\} + frac\left\{n^3\right\}\left\{2\right\} + frac\left\{n^2\right\}\left\{4\right\} = left\left[sum_\left\{i=1\right\}^n iright\right]^2$
• $sum_\left\{i=1\right\}^n i^4 = frac\left\{n\left(n+1\right)\left(2n+1\right)\left(3n^2+3n-1\right)\right\}\left\{30\right\} = frac\left\{n^5\right\}\left\{5\right\} + frac\left\{n^4\right\}\left\{2\right\} + frac\left\{n^3\right\}\left\{3\right\} - frac\left\{n\right\}\left\{30\right\}$
• $sum_\left\{i=0\right\}^n i^p = frac\left\{\left(n+1\right)^\left\{p+1\right\}\right\}\left\{p+1\right\} + sum_\left\{k=1\right\}^pfrac\left\{B_k\right\}\left\{p-k+1\right\}\left\{pchoose k\right\}\left(n+1\right)^\left\{p-k+1\right\}$

where $B_k$ is the kth Bernoulli number.

• $sum_\left\{i=m\right\}^n x^i = frac\left\{x^\left\{n+1\right\}-x^\left\{m\right\}\right\}\left\{x-1\right\}$ (see geometric series)
• $sum_\left\{i=0\right\}^n x^i = frac\left\{x^\left\{n+1\right\}-1\right\}\left\{x-1\right\}$ (special case of the above where m = 0)
• $sum_\left\{i=0\right\}^n i 2^i = 2+2^\left\{n+1\right\}\left(n-1\right)$
• $sum_\left\{i=0\right\}^n frac\left\{i\right\}\left\{2^i\right\} = frac\left\{2^\left\{n+1\right\}-n-2\right\}\left\{2^n\right\}$
• $sum_\left\{i=0\right\}^n i x^i = frac\left\{x\right\}\left\{\left(1-x\right)^2\right\} \left(x^n\left(n\left(x-1\right)-1\right)+1\right)$
• $sum_\left\{i=0\right\}^n i^2 x^i = frac\left\{x\right\}\left\{\left(1-x\right)^3\right\} \left(1+x-\left(n+1\right)^2x^n+\left(2n^2+2n-1\right)x^\left\{n+1\right\}-n^2x^\left\{n+2\right\}\right)$
• $sum_\left\{i=0\right\}^n \left\{n choose i\right\} = 2^n$ (see binomial coefficient)
• $sum_\left\{i=0\right\}^\left\{n-1\right\} \left\{i choose k\right\} = \left\{n choose k+1\right\}$
• $left\left(sum_i a_iright\right)left\left(sum_j b_jright\right) = sum_isum_j a_ib_j$
• $sum_\left\{n=a\right\}^b f\left(n\right) = sum_\left\{n=b\right\}^\left\{a\right\} f\left(n\right)$
• $sum_\left\{n=s\right\}^t f\left(n\right) = sum_\left\{n=-t\right\}^\left\{-s\right\} f\left(-n\right)$
• $sum_\left\{n=0\right\}^t f\left(2n\right) + sum_\left\{n=0\right\}^t f\left(2n+1\right) = sum_\left\{n=0\right\}^\left\{2t+1\right\} f\left(n\right)$
• $sum_\left\{n=0\right\}^t sum_\left\{i=0\right\}^\left\{z-1\right\} f\left(zsdot n+i\right) = sum_\left\{n=0\right\}^\left\{zsdot t+z-1\right\} f\left(n\right)$
• $widehat\left\{b\right\}^\left\{left\left[sum_\left\{n=s\right\}^t f\left(n\right) right\right]\right\} = prod_\left\{n=s\right\}^t widehat\left\{b\right\}^\left\{f\left(n\right)\right\}$ (See Product of a series)
• $lim_\left\{trightarrow infty\right\} sum_\left\{n=a\right\}^t f\left(n\right) = sum_\left\{n=a\right\}^infty f\left(n\right)$ (See Infinite limits)
• $\left(a + b\right)^n = sum_\left\{i=0\right\}^n \left\{n choose i\right\}a^\left\{\left(n-i\right)\right\} b^i$, for binomial expansion
• $sum_\left\{n=b+1\right\}^\left\{infty\right\} frac\left\{b\right\}\left\{n^2 - b^2\right\} = sum_\left\{n=1\right\}^\left\{2b\right\} frac\left\{1\right\}\left\{2n\right\}$
• $left\left(sum_\left\{i=1\right\}^\left\{n\right\} f_i\left(x\right)right\right)^prime = sum_\left\{i=1\right\}^\left\{n\right\} f_i^prime\left(x\right)$

## Growth rates

The following are useful approximations (using theta notation):

• $sum_\left\{i=1\right\}^n i^c in Theta\left(n^\left\{c+1\right\}\right)$ for real c greater than -1
• $sum_\left\{i=1\right\}^n frac\left\{1\right\}\left\{i\right\} in Theta\left(log n\right)$
• $sum_\left\{i=1\right\}^n c^i in Theta\left(c^n\right)$ for real c greater than 1
• $sum_\left\{i=1\right\}^n log\left(i\right)^c in Theta\left(n cdot log\left(n\right)^\left\{c\right\}\right)$ for nonnegative real c
• $sum_\left\{i=1\right\}^n log\left(i\right)^c cdot i^d in Theta\left(n^\left\{d+1\right\} cdot log\left(n\right)^\left\{c\right\}\right)$ for nonnegative real c, d
• $sum_\left\{i=1\right\}^n log\left(i\right)^c cdot i^d cdot b^i in Theta \left(n^d cdot log\left(n\right)^c cdot b^n\right)$ for nonnegative real b > 1, c, d