Mathematics for AI I
Jan-Michael Holzinger
JOHANNES KEPLER
UNIVERSITY LINZ
Altenbergerstraße 69
4040 Linz, Austria
jku.at
Sigma- and Pi-Notation for
Sums and Products
WS 2024 2/30
Indices
Indices are used in mathematics for various purposes, specifying
the elements in a tuple (vector, array) is just one (but an important
one).
Example
s A vector a of length 7 may be given as
a = (a1 , a2 , a3 , a4 , a5 , a6 , a7 ).
s If b = (5, –3), then b = 5 and b = –3.
1 2
s If c = (1, 2, 3, 4), then c = 1, c = 2, c = 3 and c = 4.
1 2 3 4
s ∀i ∈ {1, 2, 3, 4} : c = i.
i
s For i = 1, . . . , 4 : c = i.
i
Sigma- and Pi-Notation for Sums and
WS 2024 Products 3/30
Indices
Being able to work with indices is also a core feature in many
programming languages. E.g.
1 for i in range(0,4):
2 c[i] = i
(In most programming languages, the first index of a
list/array/tuple with n entries is 0 and the last index is n-1.)
Sigma- and Pi-Notation for Sums and
WS 2024 Products 4/30
Indices
Indices allow us to write complex formulae/expressions in a
compact way.
Example
Let A1 , A2 , . . . , An be non-empty sets. The Cartesian product
A1 × A2 × · · · × An := {(a1 , a2 , . . . , an ) : ai ∈ Ai ∀i = 1, 2, . . . , n}.
Example
Let V1 , V2 , . . . , Vn be sets, s.t.
Vi ∩ Vj = ∅ for all i, j ∈ {1, 2, . . . , n} with i ̸= j.
Sigma- and Pi-Notation for Sums and
WS 2024 Products 5/30
Indices
Until now, we only used indices that were taken from a subset of
the natural numbers N0 . We might however also use different
index sets.
Example
Given a function f : R → R, and any α ∈ R, we define
Lα (f ) = {x ∈ R : f (x) = α}.
Sigma- and Pi-Notation for Sums and
WS 2024 Products 6/30
Summation
Very common task in programming: given a list/array/tuple of
numbers, we have to sum (some of) them up.
1 s = 0
2 for i in range(0,len(c)):
3 s = s + c[i]
A corresponding mathematical expression is s = c1 + c2 + · · · + cn .
Sigma- and Pi-Notation for Sums and
WS 2024 Products 7/30
Summation
We already know, a problem of the “dot” notation is possible
ambiguity, but in many cases it is not feasible to write down every
summand explicitly. A solution is the so-called “Sigma”-notation.
Σ is the upper case Greek letter “S” - “S” stands for sum.
Example
X
n
s ci = c1 + c2 + · · · + cn .
i=1
X
5
s i = 1 + 2 + 3 + 4 + 5 = 15.
i=1
Sigma- and Pi-Notation for Sums and
WS 2024 Products 8/30
Summation
X
u
How to use the Sigma-notation? ai
i=ℓ
i . . . (summation) index,
ℓ . . . lower bound (start value),
u . . . upper bound (end value),
ai . . . summation term.
Sigma- and Pi-Notation for Sums and
WS 2024 Products 9/30
Summation
X
u
How to use the Sigma-notation? ai
i=ℓ
1 Set res = 0 and i = ℓ.
2 While i ≤ u:
2.a Replace every occurrence of i in the term ai by the current value of
i.
2.b Add the resulting term to res: res ← res + ai .
2.c Increment i by 1: i ← i + 1.
3 The result is the value of res.
Remark
Such a sum has (u – ℓ + 1) summands.
Sigma- and Pi-Notation for Sums and
WS 2024 Products 10/30
Summation
Example
X
5
We compute 2i.
i=2
We notice: The sum index is i, the lower bound is 2, the upper
bound is 5 and the summation term is 2i.
i i ≤ 5? res (old) ai res (new) i +1
2 Yes. 0 2·2=4 0+4=4 3
3 Yes. 4 2·3=6 4 + 6 = 10 4
4 Yes. 10 2·4=8 10 + 8 = 18 5
5 Yes. 18 2 · 5 = 10 18 + 10 = 28 6
6 No. 28 - - -
Sigma- and Pi-Notation for Sums and
WS 2024 Products 11/30
Summation
Example
X
10
i
+ 1.
2
i=6
The sum index is i. The lower bound is 6, the upper bound is 10.
The summation term is 2i + 1.
Written down explicitly, the sum is
6 7 8 9 10
+1 + +1 + +1 + +1 + + 1 = 25
2 2 2 2 2
Sigma- and Pi-Notation for Sums and
WS 2024 Products 12/30
Summation
Example
X
3
2 · j + j 2.
j=1
The sum index is j. The lower bound is 1, the upper bound is 3.
The summation term is 2 · j + j 2 .
Written down explicitly, the sum is
2 · 1 + 12 + 2 · 2 + 22 + 2 · 3 + 32 = 26.
Sigma- and Pi-Notation for Sums and
WS 2024 Products 13/30
Summation
Example
X
2
Attention: 1 + j.
i=0
The sum index is i. The lower bound is 0, the upper bound is 2.
The summation term is 1 + j.
As i does not occur in the summation term: written down explic-
itly, the sum is
(1 + j) + (1 + j) + (1 + j) = 3 + 3j.
Sigma- and Pi-Notation for Sums and
WS 2024 Products 14/30
Summation
X
Similar notation, given an index set A: ai .
i∈A
Example
Let A := {2, 4, 8, 16}, then
X1 1 1 1 1 15
= + + + = .
i 2 4 8 16 16
i∈A
Sigma- and Pi-Notation for Sums and
WS 2024 Products 15/30
Summation - further properties
s empty sum,
s change of variable,
s distributive law,
s sums with same limits,
s decomposition,
s index reflection,
s index shift,
s summation term that does not depend on variable.
Sigma- and Pi-Notation for Sums and
WS 2024 Products 16/30
Empty sum
Example
X
1
i 2 = 0.
i=2
Remark
If the lower summation index is bigger than the upper index, then
X
u
the sum is 0. I.e., if ℓ > u, then ai = 0 .
i=ℓ
(Other authors may define the case u < ℓ differently. Be careful
when you refer to other literature.)
Sigma- and Pi-Notation for Sums and
WS 2024 Products 17/30
Change of variable
Example
X
5
a1 + a2 + a3 + a4 + a5 = ai .
i=1
X5
a1 + a2 + a3 + a4 + a5 = aj .
j=1
Remark
If we replace the summation index and all its occurrences in
the summation term by another index/variable, then the result-
X
u Xu
ing sums are the same. ai = aj .
i=ℓ j=ℓ
Sigma- and Pi-Notation for Sums and
WS 2024 Products 18/30
Distributive law
Example
X
5
(1) c · ai = c · a1 + c · a2 + c · a3 + c · a4 + c · a5 .
i=1
X
5
(2) c· ai = c · (a1 + a2 + a3 + a4 + a5 ) .
i=1
Remark
By distributivity of multiplication over addition, to multiply a sum
by a factor, each summand is multiplied by the factor and the
X u Xu
resulting products are added. I.e., ∀c ∈ R, c · ai = c · ai .
i=ℓ i=ℓ
Sigma- and Pi-Notation for Sums and
WS 2024 Products 19/30
Sums with same limits
Example
X X
5 5
ai + bi = (a1 + a2 + · · · + a5 ) + (b1 + b2 + · · · + b5 )
i=1 i=1
= (a1 + b1 ) + (a2 + b2 ) + · · · + (a5 + b5 )
X
5
= ai + bi .
i=1
Sigma- and Pi-Notation for Sums and
WS 2024 Products 20/30
Sums with same limits
Remark
Using commutativity and associativity of summation, we are
able to “merge” or “split” sums (if lower and upper index of sum-
X
u Xu Xu
mation fit). ai + bi = (ai + bi ).
i=ℓ i=ℓ i=ℓ
Sigma- and Pi-Notation for Sums and
WS 2024 Products 21/30
Decomposition
Example
X X
2 5
ai + ai = (a1 + a2 ) + (a3 + a4 + a5 )
i=1 i=3
= a1 + a2 + a3 + a4 + a5
X
5
= ai .
i=1
Remark (for ℓ ≤ m ≤ u)
Using associativity, we may compute intermediate results (or
X
m X
u X
u
“glue” together certain sums). ai + ai = ai .
i=ℓ i=m+1 i=ℓ
Sigma- and Pi-Notation for Sums and
WS 2024 Products 22/30
Index reflection
Example
X
5
ai = a1 + a2 + a3 + a4 + a5
i=1
= a5 + a4 + a3 + a2 + a1
X
5
= a5–i+1 .
i=1
Remark
Using commutativity, the result is the same, if we sum from
X
u X
u
lower to upper limit or vice versa. ai = au–i+ℓ .
i=ℓ i=ℓ
Sigma- and Pi-Notation for Sums and
WS 2024 Products 23/30
Index shift
Example
X
5
ai = a1 + a2 + a3 + a4 + a5
i=1
X
7
ai–2 = a(3–2) + a(4–2) + a(5–2) + a(6–2) + a(7–2) .
i=3
Remark
If we change the summation bounds, we have to change the
X
u X
u+m
summation term accordingly. ai = ai–m .
i=ℓ i=ℓ+m
Sigma- and Pi-Notation for Sums and
WS 2024 Products 24/30
Summation term that does not depend on variable
Example
X
5
a=a a + a + a} = 5 · a
| + a + {z
i=1 5–times
(5 – 1 + 1) · a = 5 · a.
Remark (for u ≥ ℓ)
If the summation term does not depend on the index/variable (i.e.
does not change when we iterate through all values between the
X
u
lower and upper index), we may simplify a = (u – ℓ + 1) · a.
i=ℓ
Sigma- and Pi-Notation for Sums and
WS 2024 Products 25/30
Double summation
X
u X
v
How can we compute the following sum? ai, j .
i=ℓ j=m
Remark
X
u X
v X
v X
v X
v
ai, j = aℓ, j + aℓ+1, j + · · · + au, j
i=ℓ j=m j=m j=m j=m
= (aℓ, m + aℓ, m+1 + · · · + aℓ, v )
+ (aℓ+1, m + aℓ+1, m+1 + · · · + aℓ+1, v )
+ ...
+ (au, m + au, m+1 + · · · + au, v ).
Sigma- and Pi-Notation for Sums and
WS 2024 Products 26/30
Products
Similar to the Sigma-notation for sums, we use Pi-Notation for
products.
Π is the upper case Greek letter “P” - “P” stands for product.
Example
Y
n
s ai = a1 · a2 · . . . · an .
i=1
Y5
s i = 1 · 2 · 3 · 4 · 5 = 120 (= 5!).
i=1
Sigma- and Pi-Notation for Sums and
WS 2024 Products 27/30
Products
Y
u
How to use the Pi-notation? ai
i=ℓ
i . . . (multiplication) index,
ℓ . . . lower bound (start value),
u . . . upper bound (end value),
ai . . . multiplication term.
Sigma- and Pi-Notation for Sums and
WS 2024 Products 28/30
Products
Y
u
How to use the Pi-notation? ai
i=ℓ
1 Set res = 1 and i = ℓ.
2 While i ≤ u:
2.a Replace every occurrence of i in the term ai by the current value of
i.
2.b Multiply the resulting term to res: res ← res · ai .
2.c Increment i by 1: i ← i + 1.
3 The result is the value of res.
Sigma- and Pi-Notation for Sums and
WS 2024 Products 29/30
Products - properties
Similar as for summation, e.g.
Q
u Q
u
∀c ∈ R, c · ai = c u–ℓ+1 · ai .
i=ℓ i=ℓ
Example
Q
5 Q
5
(2 · i) = (2 · 2) · (2 · 3) · (2 · 4) · (2 · 5) = 24 i (= 1920).
i=2 i=2
Sigma- and Pi-Notation for Sums and
WS 2024 Products 30/30