Capital-sigma notation¶


  • Author: Diego Inácio
  • GitHub: github.com/diegoinacio
  • Notebook: capital-sigma-notation.ipynb

Brief notes and practical examples with the summation operator.

In [1]:
import numpy as np

Summation notation¶


From the Greek alphabet, the capital Sigma letter, represented by the symbol $\large \Sigma$, is mathematical notation for summation. This operator has as function the sum or addition of multiples elements of a sequence. It is commonly associated to another mathematical symbol (greek capital Pi, $\large \Pi$), but its functionality is easily memorized by the sound of the word "sum": Sssum = Sssigma.

$$ \large \sum_{i=m}^n x_i = x_m + x_{m+1} + x_{m+2} + \cdots + x_{n-2} + x_{n-1} + x_{n} $$

where:

  • $i$ is the index of summation;
  • $m$ is the lower bound of summation;
  • $n$ is the upper bound of summation;
  • $x_i$ is the indexed variable.

For example, given the explicit sequence [1, 3, 7, 9, 13], the summation of all 5 elements is denoted as:

$$ \large \begin{aligned} \sum_{i=1}^5 x_i &= x_1 + x_2 + x_3 + x_4 + x_5 \\ &= 1 + 3 + 7 + 9 + 13 \\ &= 33 \end{aligned} $$
In [2]:
seq = [1, 3, 7, 9, 13]

result = 0
for x in seq:
    result += x

print(result)
33

Notice that in many algorithms the lower and the upper bounds are represented by the interval $[0,N-1]$, which denote the index bound of a digital array. Although, the main idea is still the same.

$$ \large \sum_{k=0}^{N-1} = \sum_{k}^N $$
In [3]:
x = [1, 3, 7, 9, 13]

result = x[0] + x[1] + x[2] + x[3] + x[4]

print(result)
33

The library Numpy has a very convenient method that makes the summing process easier and much more readable.

In [4]:
x = np.array([1, 3, 7, 9, 13])

result = x.sum()  # or np.sum(x)

print(result)
33

Multidimensional¶


This operator can be nested:

$$ \large \begin{aligned} \sum_{i=2}^4 \sum_{j=5}^6 (i \cdot j) &= (2 \cdot 5 + 2 \cdot 6) + (3 \cdot 5 + 3 \cdot 6) + (4 \cdot 5 + 4 \cdot 6) \\ &= (10 + 12) + (15 + 18) + (20 + 24) \\ &= 22 + 33 + 44 \\ &= 99 \end{aligned} $$
In [5]:
result = 0
for i in range(2, 4+1):
    for j in range(5, 6+1):
        result += i*j

print(result)
99

Nested summations are very commonly used to notate multidimensional isotropic or anisotropic objects. For example, given the matrix:

$$ \large M = \begin{bmatrix} 1 & 2 \\ 2 & 3 \\ 3 & 4 \end{bmatrix} $$

The sum of all elements can be expressed as:

$$ \large \begin{aligned} \sum_i^M \sum_j^N M_{ij} &= 1 + 2 + 2 + 3 + 3 + 4 \\ &= 15 \end{aligned} $$
In [6]:
matrix = np.array([
    [1, 2], 
    [2, 3], 
    [3, 4]
])

M = len(matrix)
N = len(matrix[0])

result = 0
for i in range(M):
    for j in range(N):
        result += matrix[i][j]

print(result, np.sum(matrix))
15 15

Properties¶


Follow some basic properties and identities.

  • The summation of a constant $\large c$ is the same of its multiplication by the factor $N$:
$$ \large \sum_i^N c = N \cdot c $$
In [7]:
N = 10
c = 2

print(np.sum([c for _ in range(N)]))
print(N*c)
print(np.sum([c]*N))
20
20
20
  • The commutativity and associative properties are denoted as:
$$ \large \sum_i^N x_i \pm \sum_i^N y_i = \sum_i^N (x_i \pm y_i) $$
In [8]:
x = np.array([1, 20, 3, 40])
y = np.array([10, 2, 30, 4])

print(np.sum(x) - np.sum(y))
print(np.sum(x - y))
18
18

Examples¶


Follow some example of summation operator applications.

  • Infinity serie: An infinite serie is when the upper bound is infinity and its summation result converges to a known theoretical number. For example, the Basel problem:
$$ \large \sum_{k=1}^\infty \frac{1}{k^2} = \lim_{n \rightarrow \infty} \sum_{k=1}^n \frac{1}{k^2} = \frac{\pi^2}{6} $$
In [9]:
K = np.arange(1e6) + 1

result = np.sum(1/K**2)

print(result, np.pi**2/6)
1.6449330668487268 1.6449340668482264
  • Alternating serie: The signs of the general terms alternate between positive and negative and its infinite serie always converges.
$$ \large \sum_{k=1}^n=\frac{(-1)^{k+1}}{k^2} $$
In [10]:
K = np.arange(100) + 1

result = np.sum((-1)**(K+1)/K**2)

print(result)
0.8224175333741284