Section 6.3 Summation
In many contexts both practical and theoretical we would like to add together the terms of a sequence. This process occurs frequently enough to earn its own notation.
Definition 6.3.1.
The sum of the sequence \((a_i)_m^n\) is denoted
where the index \(i\) ranges from the lower bound of the sum, \(m\text{,}\) to the upper bound \(n\text{.}\) That is,
Example 6.3.2.
The sum
is the sum of the sequence \((i^2)_1^4\text{,}\) where the lower bound is \(1\) and the upper bound is \(4\text{.}\) To calculate this sum, we calculate each term of the finite sequence \((i^2)_1^4\) and then add them all together.
For the reader who has had some experience with programming, the expression
can be thought of as a for loop:
sum = 0 for i in range(m:n) sum = sum + a(i) return sum
We can have sums of sums, and sums of sums of sums, etc. Double sums are common in computer science when evaluating the runtimes of doubly-nested for loops.
Example 6.3.3.
Consider the sum
This sum is rectangular in the sense that the bounds of one sum are not determined by the other, and so we could do this sum in either order.
In one order, you may choose to sum over \(n\) first.
Alternatively, you could iterate over \(m\) first.
In the above calculation, each individual sum over \(n\) is calculated vertically. So the first column is the sum of \((1+n)\) from \(2\) to \(4\text{,}\) etc.
You can see that either way, the value of the sum is \(45\text{.}\)
Example 6.3.4.
Take the sum
This time, the bounds of the \(j\)-sum are dependent on the value of \(i\text{.}\) When this happens, the best approach is to calculate the independent sum first. In this case, it means we'll start by iterating over \(i\text{.}\)
Notice that when one sum depends on the index of the other, the shape of the terms when written out is no longer “rectangular”, hence that language. This is because, for instance, the sum of \(2^{j+1}\) from \(j=1\) to \(1\) only has one term, whereas the sum of \(2^{j+4}\) from \(j=1\) to \(4\) has four terms.
Example 6.3.5.
Calculate the sum
Notice that this time, both the lower and upper bounds of the \(n\) sum depend on the value of \(m\text{.}\)