Work with functionsLesson 24 of 48 · 7 min
Sum a family of terms
Represent a finite symbolic sum and evaluate its closed form.
Maths refresher: Sigma notation
The symbol Σ instructs you to add one term for each integer index in the specified range, including both endpoints here.
For , the terms are , and the formula gives .
A finite sum adds terms indexed by an integer. SymPy Sum can retain the summation object before evaluating it with doit. This separates the mathematical definition from the closed form a symbolic algorithm can obtain.
- First term
- Add the second
- Add the third
- Add the fourth
The upper endpoint is included in the sum below. Declaring n as a positive integer matches the intended finite-count model. Product uses an analogous notation for multiplication rather than addition.
Compare the symbolic formula with a small hand-checkable case. When moving to infinite sums, convergence becomes an additional mathematical requirement; a finite-sum identity should not be extended by simply replacing n with infinity without checking that requirement.
Does sp.Sum(k,(k,1,4)) include the term ?
Write a prediction (optional)
Exact symbolic investigation
Select Run Python with the code unchanged.
Your saved draft is open. To use the published code, select Restore example in Tools. Use Recover draft to bring back your code.
Tools
About Python
Python and the course packages can load while you read. Each run starts with fresh user variables; imported modules stay loaded. Stop replaces the worker. Runtime details ↗
Ctrl+Enter or ⌘+Enter runs Python.
Execution error
Technical error details
Your result
Python text output
Compare with the worked example
Executed from the published Python during the site build. Your own run appears above. Build environment ↗
Worked text output
Defined sum: Sum(k, (k, 1, n)) Closed form: n**2/2 + n/2 Sum at n=4: 10 Finite product at 4: 24
Read the starter result
The starter Sum at n=4 is 10, while Finite product at 4 is 24. Similar index notation can describe different operations.
Edit and compare
Replace term = k with term = k**2 and check_n = 4 with check_n = 3. Select Run Python. Compare Sum at n=3 with the hand calculation 1² + 2² + 3² and connect it to the new Closed form.
Scope. This lesson establishes finite indexed operations; infinite-series convergence requires further analysis.
Try a fresh case
Before interpreting an infinite-series result, what extra question matters?
Need a hint?
Hint 1
Finite and infinite addition are different mathematical claims.
Hint 2
Check the conditions under which the infinite total exists.