Hello again. In the previous lesson, you solved linear inequalities by isolating a variable and interpreting the result as a range of valid values. This lesson shifts from comparisons to a compact notation for repeated addition.
In data science, many quantities are totals over observations: total error across training examples, total revenue across transactions, or total counts across categories. Sigma notation is the standard mathematical shorthand for such totals. By the end of this lesson, you will be able to read a finite sigma expression, expand it into its individual terms, and calculate its value reliably.
Sigma notation: instructions for repeated addition
A finite sum means adding a limited, known number of terms. For example,
is a finite sum.
Writing every term is manageable here, but becomes cumbersome when there are many terms or when each term follows a rule. Sigma notation gives a compact way to write that repeated addition:
Read this as:
“The sum of , for from to .”
The symbol is the capital Greek letter sigma. It means “add up.”

In general, a sum has four parts:
| Part | Example in | Meaning |
|---|---|---|
| Sigma symbol | Add the terms | |
| Index | A temporary counting variable | |
| Lower limit | Start by substituting | |
| Upper limit | Finish by substituting | |
| Summand | The expression to calculate for each value of |
The index is just a placeholder. It could be , , , or ; the letter does not alter the calculation. What matters is using the specified index values consistently.
This notation means:
Then evaluate:
So,
The key idea is simple: start at the lower limit, substitute every whole-number index value up to and including the upper limit, then add the resulting terms.
Sigma notation for sums | Sequences, series and induction | Precalculus | Khan Academy
Watch “Sigma notation for sums” from Khan Academy for a visual introduction to sigma notation and its expansion into individual terms.
Watch the motivation for why repeated addition needs shorthand. Then watch the basic expansion, focusing on how the starting and ending index values determine the terms included. If you want one additional example with a nonstandard starting value, watch the second example; notice that the term for the upper limit is included before the sum stops.
A dependable evaluation method
When you encounter a finite sum, do not try to infer a shortcut immediately. For the small sums used at this stage, expand it carefully.
Use this four-step method:
- Identify the index and its lower limit.
- Identify the upper limit.
- Substitute every index value from the lower limit through the upper limit, including both endpoints.
- Evaluate the terms and add them.
Consider:
The lower limit is , the upper limit is , and the summand is . Therefore, use the five index values:
Expand before calculating:
Now evaluate each square:
Finally, add:
Writing the expansion is worth the extra line. It makes two common errors visible: omitting an endpoint and accidentally applying the exponent to the wrong part of an expression.
The OpenStax-based reading below gives the same process in a concise formal form, followed by this worked example.
11.4: Series and Their Notations
Read “Series and Their Notations” from LibreTexts/OpenStax to reinforce the meaning of the index, lower limit, upper limit, and summand before following its direct evaluation procedure.
In the section “Using Summation Notation,” read the explanation of the notation. Focus on the role of the index and on the fact that the lower and upper limits produce the first and last terms. Then, in the following explanation and “Example 1: Using Summation Notation,” read the four-step method and follow the expansion of \sum_{k=3}^{7}k^2.
The limits are inclusive
The lower and upper limits are both included. This is the most important habit to establish.
For example,
means substitute , then , then :
Therefore,
Notice that the sum contains three terms, not two. Both boundary values appear.
For integer limits, the number of terms is:
For the previous example, this gives:
For the sum from to , it gives:
This quick count is useful as a check. If you expanded only four terms in the latter example, you would know an index value was skipped.
The lower limit does not have to be . It can be , as in:
Start at , not :
So,
The first term is because the index starts at zero. If you began at , you would incorrectly leave out the first term.
Evaluate the whole expression each time
The expression to the right of sigma is called the summand. Treat it like any algebraic expression: substitute the index value everywhere it appears, use parentheses when helpful, then follow the order of operations.
Consider:
The index values are . Expand:
Evaluate each term:
Then add:
A clear layout prevents a subtle but frequent mistake. The expression is , so the subtraction belongs inside every term. It is not correct to calculate , because that subtracts only once rather than once per term.
Similarly, parentheses matter in a squared expression. Compare:
with
For the first expression:
For the second:
They look similar, but the parentheses change the summand, so they produce different totals.
A data-science interpretation: totals across observations
Sigma notation becomes practical when the same calculation is applied to many data points.
Suppose a model makes predictions for four observations. For each observation , let be its prediction error. The total squared error can be written as:
If the errors are:
then the total squared error is:
The square ensures that positive and negative errors do not cancel each other. Later, mean squared error will divide a total like this by the number of observations. For now, the central point is that sigma notation says: apply the same rule to each indexed observation and aggregate the results.
In real datasets, writing all the terms would be impractical. Sigma notation communicates the rule and the range compactly.
Checking a sigma sum in Python
Python can verify a finite sum directly. Its built-in sum() function plays the same role as , while range() creates the index values.
For example, calculate:
terms = [k**2 for k in range(3, 8)]
total = sum(terms)
print(terms)
print(total)
The expected output is:
[9, 16, 25, 36, 49]
135
There is one important difference between mathematical notation and Python:
- In sigma notation, the upper limit is included.
- In Python,
range(start, stop)excludesstop.
So the mathematical range from through becomes:
range(3, 8)
The stop value is because Python stops just before it.
Here is the earlier linear summand in Python:
terms = [3*j - 1 for j in range(2, 6)]
total = sum(terms)
print(terms)
print(total)
This produces:
[5, 8, 11, 14]
38
For now, use Python as a check after expanding at least a few sums manually. The manual expansion teaches you what the notation means; the code becomes especially useful when the upper limit is large.
Common mistakes to avoid
Stopping before the upper limit
includes:
not merely .
Starting at the wrong lower limit
begins with . Its expansion is:
Even if the first term happens to be zero, it is still part of the sum.
Forgetting to substitute into the entire summand
For
the terms are:
The occurs in every term.
Confusing an exponent with multiplication
In
the summand is “ squared,” not “.” The expansion is:
not .
Copying sigma limits directly into range()
For a sum ending at , range(..., 5) stops at . Use range(..., 6) instead.
Key takeaways
Sigma notation is compact repeated addition.
- means “add.”
- The lower limit gives the first index value.
- The upper limit gives the last index value, and it is included.
- Substitute each index value into the entire summand, simplify the resulting terms, and add them.
- For integer limits, the number of terms is upper limit minus lower limit plus one.
- In Python, use
range(lower, upper + 1)to match the inclusive mathematical upper limit.
Next, you will translate algebraic expressions into equivalent Python code. The connection is direct: algebra states a rule symbolically, while Python lets you evaluate that rule for concrete values or entire collections of values.
Can't find a good explanation? Sign up and we'll make it for you
Sign up