Sigma Notation

The for loop is a useful control structure common to many programming languages. It repeats some code for each value of a variable in a given range. In C, a for loop might look like this:

for (x=1; x<=10; x=x+1)
{
    /* do something ten times */
}

The initial parameter, x=1, starts a counter at one. The second parameter, x<=10, means the loop repeats until the counter reaches ten. The last parameter, x=x+1 (sometimes written x++), explains how to do the counting: add one to the counter each time through the loop.

In math, sometimes it may be necessary to add up a bunch of a related terms. For example, rather than write out 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10, the problem can be expressed with sigma notation as a sort of loop:

sum_{x=1}^{10}{x}

The x=1 below the big sigma starts the counter at one. The number 10 above the Σ specifies the final value of the counter. The Σ itself means to add up multiple copies of whatever follows, using integer values of x ranging from the initial 1 to the maximum 10 for each copy.

(The sum is 55.)

For simple arithmetic, this notation is hardly a simplification. However, if the terms to add are complicated, or if there are many instances of them, you’ll find this is clearly a compact and convenient way to express the sum. Plus, the Σ symbol is wicked fun to write.

The dweebs at Wikipedia have beat the programming-a-sum example to death.

Posted on Wednesday, April 16th, 2008. Tags: .