Sum Operator
The sum operator or also sometimes called sigma operator or summation is a mathematical operator that represents the addition of a sequence of objects, most commonly numbers but can also be other mathematical objects that support addition.
When the series of numbers is defined such as we commonly write the summation as:
However most often a series is defined by some pattern/formula or function. In this case we use the sum operator to represent the sum of the series. The sum operator is written as a capital sigma and then usually has a lower and upper bound. The lower bound is the starting index of the series and the upper bound is the ending index of the series. The index is usually a natural number. This index is then used in the formula to represent the current element of the series.
more generally the sum operator is defined as the following where is the i-th element of the sequence.
Because a sequence can be defined by a function, the sum operator can also be used to represent the sum of a function. For computer scientists it can also be useful to think of the sum operator as a loop. The lower bound is the starting index of the loop and the upper bound is the ending index of the loop. The formula inside the sum operator is then the body of the loop.
int sum = 0;
for (int i = 1; i <= n; i++) {
sum += f(i);
}
Depending on the context the upper and/or lower bound are sometimes omitted. If the lower bound is omitted it is assumed to be 1 and if the upper bound is omitted it is assumed to be infinity or the length of the sequence . Other common notations are or where is a set.
When a infinite sequence is summed up it is called a series.
Special Cases
There are some special cases of the sum operator that are worth mentioning:
- Empty Sum: The sum of an empty sequence is defined to be 0. This is because there are no elements to sum.
- Single Element Sum: The sum of a sequence with only one element is equal to that element. This is because there is only one element to sum.
Nested Sums
The sum operator can also be nested. This means we can sum over multiple indices. This is useful when working with multi-dimensional sequences or functions.
Just like with nested loops in programming languages, the inner sum is executed for each iteration of the outer sum.
int sum = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
sum += f(i, j);
}
}
Properties
We can derive some properties of the sum operator from the properties of addition and multiplication that can make it easier to work with sums.
Finding Closed Forms
Story of Gauss and the sum of the first 100 numbers.
By induction?
This probably also relates to big O notation and the time complexity of algorithms i think?