Lesson illustration

Evaluating Finite Sums in Sigma Notation

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,

2+4+6+8+102+4+6+8+10

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:

k=152k\sum_{k=1}^{5} 2k

Read this as:

“The sum of 2k2k, for kk from 11 to 55.”

The symbol \sum is the capital Greek letter sigma. It means “add up.”

{"type":"image","url":"https://mathsux.org/wp-content/uploads/2021/01/Screen-Shot-2021-01-27-at-2.25.31-PM-1024x487.png","caption":"A sigma expression with \\(n+1\\) as the term rule, \\(n=1\\) as the lower limit, and \\(3\\) as the upper limit. These parts tell us exactly which values of \\(n\\) to substitute and then add.","isV2":true,"blockId":"09fe9a55-1e45-4233-afcc-f927aaa9762a","lessonId":"78b96570-e9ea-4ffd-bdda-61fc1ab71192"}



In general, a sum has four parts:

k=LUexpression involving k\sum_{k=L}^{U} \text{expression involving } k
PartExample in k=152k\displaystyle\sum_{k=1}^{5}2kMeaning
Sigma symbol\sumAdd the terms
IndexkkA temporary counting variable
Lower limit11Start by substituting k=1k=1
Upper limit55Finish by substituting k=5k=5
Summand2k2kThe expression to calculate for each value of kk

The index is just a placeholder. It could be ii, jj, kk, or nn; the letter does not alter the calculation. What matters is using the specified index values consistently.

This notation means:

k=152k=2(1)+2(2)+2(3)+2(4)+2(5)\sum_{k=1}^{5}2k = 2(1)+2(2)+2(3)+2(4)+2(5)

Then evaluate:

2+4+6+8+10=302+4+6+8+10=30

So,

k=152k=30\sum_{k=1}^{5}2k=30

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.

{"type":"video","title":"Sigma notation for sums | Sequences, series and induction | Precalculus | Khan Academy","learning_duration":231,"video_id":"5jwXThH6fg4","par_intro":"Watch “Sigma notation for sums” from Khan Academy for a visual introduction to sigma notation and its expansion into individual terms.","par_directions":"Watch <span data-type=\"resource_video_timerange\" data-resource-subitem-id=\"e79c0c41\" data-range-start=\"0\" data-range-end=\"52\">the motivation</span> for why repeated addition needs shorthand. Then watch <span data-type=\"resource_video_timerange\" data-resource-subitem-id=\"d32aeb35\" data-range-start=\"86\" data-range-end=\"140\">the basic expansion</span>, 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 <span data-type=\"resource_video_timerange\" data-resource-subitem-id=\"06799e6f\" data-range-start=\"140\" data-range-end=\"265\">the second example</span>; notice that the term for the upper limit is included before the sum stops.","video_duration":266,"isV2":true,"blockId":"f4d9ca0c-bb54-4ea4-bc1c-6ddc361e7193","lessonId":"78b96570-e9ea-4ffd-bdda-61fc1ab71192"}




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:

  1. Identify the index and its lower limit.
  2. Identify the upper limit.
  3. Substitute every index value from the lower limit through the upper limit, including both endpoints.
  4. Evaluate the terms and add them.

Consider:

k=37k2\sum_{k=3}^{7}k^2

The lower limit is 33, the upper limit is 77, and the summand is k2k^2. Therefore, use the five index values:

k=3, 4, 5, 6, 7k=3,\ 4,\ 5,\ 6,\ 7

Expand before calculating:

k=37k2=32+42+52+62+72\sum_{k=3}^{7}k^2 = 3^2+4^2+5^2+6^2+7^2

Now evaluate each square:

9+16+25+36+499+16+25+36+49

Finally, add:

k=37k2=135\sum_{k=3}^{7}k^2=135

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.

{"type":"reading","par_intro":"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.","par_directions":"In the section “Using Summation Notation,” read <span data-type=\"resource_reading_textrange\" data-resource-subitem-id=\"5882fa7b\" data-range-start=\"Summation notation is used to represent series.\" data-range-end=\"the number used to generate the last term in a series.\">the explanation of the notation</span>. 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 <span data-type=\"resource_reading_textrange\" data-resource-subitem-id=\"4cdb8a41\" data-range-start=\"This notation tells us to find the sum of\" data-range-end=\"Add to find the sum.\">the four-step method</span> and follow the expansion of \\(\\sum_{k=3}^{7}k^2\\).","learning_duration":"8 minutes","url":"https://math.libretexts.org/Bookshelves/Precalculus/Precalculus_1e_(OpenStax)/11:_Sequences_Probability_and_Counting_Theory/11.04:_Series_and_Their_Notations","title":"11.4: Series and Their Notations","isV2":true,"blockId":"11605efb-b8ea-4b05-80a4-8a6e215f1305","lessonId":"78b96570-e9ea-4ffd-bdda-61fc1ab71192"}




The limits are inclusive

The lower and upper limits are both included. This is the most important habit to establish.

For example,

n=13(n+1)\sum_{n=1}^{3}(n+1)

means substitute n=1n=1, then n=2n=2, then n=3n=3:

(1+1)+(2+1)+(3+1)(1+1)+(2+1)+(3+1) 2+3+4=92+3+4=9

Therefore,

n=13(n+1)=9\sum_{n=1}^{3}(n+1)=9

Notice that the sum contains three terms, not two. Both boundary values appear.

For integer limits, the number of terms is:

number of terms=upper limitlower limit+1\text{number of terms}=\text{upper limit}-\text{lower limit}+1

For the previous example, this gives:

31+1=33-1+1=3

For the sum from k=3k=3 to k=7k=7, it gives:

73+1=57-3+1=5

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 11. It can be 00, as in:

i=04(2i+1)\sum_{i=0}^{4}(2i+1)

Start at i=0i=0, not i=1i=1:

(2(0)+1)+(2(1)+1)+(2(2)+1)+(2(3)+1)+(2(4)+1)(2(0)+1)+(2(1)+1)+(2(2)+1)+(2(3)+1)+(2(4)+1) 1+3+5+7+9=251+3+5+7+9=25

So,

i=04(2i+1)=25\sum_{i=0}^{4}(2i+1)=25

The first term is 11 because the index starts at zero. If you began at 11, you would incorrectly leave out the first term.

{
  "type": "exercise",
  "id": "6ad5b57d-4062-4c3a-b297-1f05b0f6359c"
}

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:

j=25(3j1)\sum_{j=2}^{5}(3j-1)

The index values are 2,3,4,52,3,4,5. Expand:

(3(2)1)+(3(3)1)+(3(4)1)+(3(5)1)(3(2)-1)+(3(3)-1)+(3(4)-1)+(3(5)-1)

Evaluate each term:

5+8+11+145+8+11+14

Then add:

j=25(3j1)=38\sum_{j=2}^{5}(3j-1)=38

A clear layout prevents a subtle but frequent mistake. The expression is 3j13j-1, so the subtraction belongs inside every term. It is not correct to calculate 3(2+3+4+5)13(2+3+4+5)-1, because that subtracts 11 only once rather than once per term.

Similarly, parentheses matter in a squared expression. Compare:

i=13(i+1)2\sum_{i=1}^{3}(i+1)^2

with

i=13(i2+1)\sum_{i=1}^{3}(i^2+1)

For the first expression:

(1+1)2+(2+1)2+(3+1)2(1+1)^2+(2+1)^2+(3+1)^2 4+9+16=294+9+16=29

For the second:

(12+1)+(22+1)+(32+1)(1^2+1)+(2^2+1)+(3^2+1) 2+5+10=172+5+10=17

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 ii, let eie_i be its prediction error. The total squared error can be written as:

i=14ei2\sum_{i=1}^{4}e_i^2

If the errors are:

e1=1,e2=2,e3=0,e4=3e_1=1,\qquad e_2=-2,\qquad e_3=0,\qquad e_4=3

then the total squared error is:

12+(2)2+02+321^2+(-2)^2+0^2+3^2 1+4+0+9=141+4+0+9=14

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.

{
  "type": "exercise",
  "id": "809f9562-1c6f-4642-aff8-44d74ea18d04"
}

Checking a sigma sum in Python

Python can verify a finite sum directly. Its built-in sum() function plays the same role as \sum, while range() creates the index values.

For example, calculate:

k=37k2\sum_{k=3}^{7}k^2
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) excludes stop.

So the mathematical range from 33 through 77 becomes:

range(3, 8)

The stop value is 88 because Python stops just before it.

Here is the earlier linear summand in Python:

j=25(3j1)\sum_{j=2}^{5}(3j-1)
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.

{
  "type": "exercise",
  "id": "b96a0555-0528-4d51-918f-73aae585a287"
}

Common mistakes to avoid

Stopping before the upper limit

i=14i\sum_{i=1}^{4}i

includes:

1+2+3+41+2+3+4

not merely 1+2+31+2+3.

Starting at the wrong lower limit

i=03i2\sum_{i=0}^{3}i^2

begins with 020^2. Its expansion is:

02+12+22+320^2+1^2+2^2+3^2

Even if the first term happens to be zero, it is still part of the sum.

Forgetting to substitute into the entire summand

For

k=13(2k+5)\sum_{k=1}^{3}(2k+5)

the terms are:

(2(1)+5)+(2(2)+5)+(2(3)+5)(2(1)+5)+(2(2)+5)+(2(3)+5)

The +5+5 occurs in every term.

Confusing an exponent with multiplication

In

k=13k2\sum_{k=1}^{3}k^2

the summand is “kk squared,” not “2k2k.” The expansion is:

12+22+321^2+2^2+3^2

not 2(1)+2(2)+2(3)2(1)+2(2)+2(3).

Copying sigma limits directly into range()

For a sum ending at 55, range(..., 5) stops at 44. Use range(..., 6) instead.


Key takeaways

Sigma notation is compact repeated addition.

  • \sum 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