121 Week 13 - Sigma Notation Flashcards
What is sigma notation used for
It is a mathematical shorthand used for expressing sums where each
term is of the same form. It has the symbol: Σ
How is sigma notation used
Below sigma, the index is declared and set to its starting value e..g, i=1
Above sigma, the upper limit for the index is stated.
Next to sigma is the expression to be evaluated.
Example
5
Σ (i) = 1+2+3+4+5
i=1
Double summations
Multiple sigma’s can be used at once. In this case the inner sigma is evaluated first then the outer sigma is evaluated.
Summation formulas
(N)(i=1) Σ (i) = N(N+1) / 2
(N)(i=1) Σ (1) = N
(b)(i=a) Σ (1) = b-a+1
(b)(i=a) Σ (M) = M( (b)(i=a) Σ (1) )
(b)(i=a) Σ (Ai) = A ( (b)(i=a) Σ (i) )
(b)(i=a) Σ (Ai+B) = (b)(i=a) Σ (A*i) + (b)(i=a) Σ (B)
For loop general rule
Only if a for loop is in the format:
for (i = a; i <= b; i++)
and a and b are positive integers and a<b,
The number of instructions in the loop can be found by the summation:
(b)(i=a) Σ (1)
which is equal to (b-a+1)