Also called the summation notation, capital Sigma notation is the mathematical way of expressing the sum of a function iterated over a variable.
The notation and its parts
The Sigma notation can be a bit confusing or intimidating at first, but it's actually really simple. It's a short way of expressing a formula applied iteratively to a range of numbers.
If you understand the loop construct in programming, Sigma notation is very easy to grasp.
Here's the notation.
It's best explained broken down into the different components. In the example above, there's the:
- Index of summation, $i$.
- First value, $1$.
- Last value, $10$. It sits on top of the Sigma.
- Formula, the actual operation we will apply to every iteration. In this case we are just adding, which is implict through the Sigma notation itself.
In this expression, we are adding up every number from one to ten.
In this expression, we are adding up the squares of every number from one to ten. The actual addition of each iteration is implied by the Sigma.
Here it is implemented with a while loop.
Here I have changed the index of summation from an i to an r, just to make it clear that the letter used is irrelevant.
I have retained the first value to be one, but have changed the last value to be five. Finally, the formula is a bit more complex, as it includes addition and multiplication.