Sequences and Series: Patterns, Sums and Limits

A complete, plain-language guide with worked examples, diagrams, tables and links to AI and machine learning

In this article
  1. Introduction
  2. What is a sequence?
  3. Arithmetic sequences
  4. Geometric sequences
  5. Series and sigma notation
  6. Arithmetic series
  7. Geometric series
  8. Infinite series and convergence
  9. Recursive sequences and Fibonacci
  10. Real-world patterns
  11. AI and machine learning
  12. Common mistakes
  13. Practice problems
  14. Conclusion

1. Introduction

Patterns are everywhere in numbers. The days of the week repeat, a savings balance climbs month by month, a bouncing ball rises a little less each time, and a model's error shrinks a little with every training step. Mathematics captures these patterns with two companion ideas: a sequence, an ordered list of numbers, and a series, the sum of such a list.

These ideas connect the other topics in this series. An arithmetic sequence is a linear function whose input is limited to whole numbers. A geometric sequence is an exponential function sampled at whole numbers. Adding up the terms leads to formulas that save enormous effort, and adding up infinitely many terms leads to one of the most surprising facts in mathematics: an endless sum can have a finite answer.

This article covers the two main types of sequence, the matching series formulas, infinite series and when they converge, recursive sequences such as Fibonacci, and practical applications. We finish with where these ideas appear in machine learning, from gradient descent to reinforcement learning.

2. What is a sequence?

A sequence is an ordered list of numbers called terms. We name the first term a₁, the second a₂, and the general term aₙ, where n is the position. Unlike a set, order matters and repeats are allowed. A sequence is really a function whose input is the positive whole numbers: n goes in and aₙ comes out.

A sequence can be described in two ways. An explicit rule gives aₙ directly from n, for example aₙ = 3n + 2, which produces 5, 8, 11, 14, and so on. A recursive rule says how each term follows from the previous one, for example a₁ = 5 and aₙ = aₙ₋₁ + 3. Both describe the same list.

Four small plots of arithmetic, geometric growth, geometric decay and alternating sequences
Four common sequence patterns, drawn term by term.
Sequence vocabulary
TermMeaningExample
Termone number in the lista₃ = 11
Index nthe position of a termn = 3
Explicit ruleformula for aₙ using naₙ = 3n + 2
Recursive ruleaₙ built from earlier termsaₙ = aₙ₋₁ + 3
Finite / infinitestops or goes on forever5, 8, 11 / 5, 8, 11, …
Examples of sequences
First termsRuleType
2, 4, 6, 8, …add 2arithmetic
3, 6, 12, 24, …multiply by 2geometric
1, 4, 9, 16, …aₙ = n²squares
1, 1, 2, 3, 5, 8, …add the previous twoFibonacci
10, −8, 6.4, −5.12, …multiply by −0.8alternating geometric

3. Arithmetic sequences

An arithmetic sequence changes by the same amount each time, the common difference d. Starting at a₁, the terms are a₁, a₁ + d, a₁ + 2d, …, so the nth term is aₙ = a₁ + (n − 1)d. The (n − 1) appears because the first term has had no steps added yet.

For 5, 8, 11, 14, …, we have a₁ = 5 and d = 3, so aₙ = 5 + 3(n − 1). The tenth term is 5 + 3(9) = 32. You can test whether a list is arithmetic by checking that all neighbouring differences are equal.

Bar chart of an arithmetic sequence with plus 3 steps
An arithmetic sequence climbs by equal steps, like a staircase.
The arithmetic sequence 5, 8, 11, …
nCalculationaₙ
15 + 3(0)5
25 + 3(1)8
35 + 3(2)11
45 + 3(3)14
55 + 3(4)17
65 + 3(5)20
75 + 3(6)23
85 + 3(7)26
95 + 3(8)29
105 + 3(9)32

An arithmetic sequence is a linear function with the input restricted to whole numbers: aₙ = dn + (a₁ − d) has slope d. That is why its dots lie on a straight line.

4. Geometric sequences

A geometric sequence multiplies by the same factor each time, the common ratio r. The terms are a₁, a₁r, a₁r², …, so aₙ = a₁ · rⁿ⁻¹. This is an exponential function sampled at whole numbers.

For 3, 6, 12, 24, …, a₁ = 3 and r = 2, so aₙ = 3 · 2ⁿ⁻¹ and the eighth term is 3 · 2⁷ = 384. Check by dividing neighbours: 6/3 = 12/6 = 2. If |r| > 1 the terms grow in size, if |r| < 1 they shrink toward zero, and a negative r makes the signs alternate.

Arithmetic versus geometric sequences
FeatureArithmeticGeometric
Stepadd dmultiply by r
nth terma₁ + (n − 1)da₁ · rⁿ⁻¹
Neighbour testequal differencesequal ratios
Matching functionlinearexponential
Graph of the dotsstraight linecurve
Long-run behaviourgrows steadilyexplodes or fades away
The geometric sequence 3, 6, 12, …
nCalculationaₙ
13 · 2^03
23 · 2^16
33 · 2^212
43 · 2^324
53 · 2^448
63 · 2^596
73 · 2^6192
83 · 2^7384

5. Series and sigma notation

A series is what you get by adding the terms of a sequence. The sum of the first n terms is the partial sum Sₙ = a₁ + a₂ + … + aₙ. Mathematicians abbreviate sums with the Greek letter sigma: Σ. The notation Σ (k = 1 to 5) k² means "add the value of k² as k runs from 1 to 5," which is 1 + 4 + 9 + 16 + 25 = 55.

Reading sigma notation
ExpressionExpandedValue
Σ (k=1 to 5) k²1 + 4 + 9 + 16 + 2555
Σ (k=1 to 4) (2k + 1)3 + 5 + 7 + 924
Σ (k=0 to 3) 2ᵏ1 + 2 + 4 + 815
Σ (k=1 to 3) 1/k1 + 1/2 + 1/311/6 ≈ 1.833

Three sums come up so often that their formulas are worth knowing: the sum of the first n whole numbers, of their squares, and of their cubes.

Three classic sums
SumFormulan = 10
1 + 2 + … + nn(n + 1)/255
1² + 2² + … + n²n(n + 1)(2n + 1)/6385
1³ + 2³ + … + n³[n(n + 1)/2]²3025

6. Arithmetic series

The story goes that a young schoolboy, Carl Friedrich Gauss, was asked to add the numbers 1 to 100 and found the answer in seconds. His idea was to write the sum twice, once forwards and once backwards. Every column then adds to the same total, 101, and there are 100 columns. So twice the sum is 100 × 101, and the sum is 5050.

Numbers 1 to 10 written forwards and backwards with every column summing to 11
Gauss's pairing trick, shown for 1 to 10.

The same trick works for any arithmetic series. Pair the first term with the last, the second with the second last, and so on: each pair has the same sum, a₁ + aₙ. This gives Sₙ = n/2 · (a₁ + aₙ), or equivalently Sₙ = n/2 · (2a₁ + (n − 1)d). In words: the number of terms times the average of the first and last.

For 5 + 8 + … + 32, there are 10 terms, so S₁₀ = 10/2 · (5 + 32) = 185. A slightly harder case: how many terms are in 7, 10, 13, …, 100? Solve 7 + 3(n − 1) = 100 to get n = 32, so the sum is 32/2 · (7 + 100) = 1712.

Partial sums of 5, 8, 11, …
naₙSₙ (running total)Formula n/2 (a₁ + aₙ)
1551/2 × (5 + 5) = 5
28132/2 × (5 + 8) = 13
311243/2 × (5 + 11) = 24
517555/2 × (5 + 17) = 55
103218510/2 × (5 + 32) = 185

7. Geometric series

For a geometric series, a different trick works. Write Sₙ = a₁ + a₁r + … + a₁rⁿ⁻¹. Multiply by r to get rSₙ = a₁r + … + a₁rⁿ. Subtracting, almost everything cancels, leaving Sₙ − rSₙ = a₁ − a₁rⁿ, so Sₙ = a₁(1 − rⁿ) / (1 − r), valid when r ≠ 1.

For 3 + 6 + 12 + … with 8 terms, S₈ = 3(2⁸ − 1)/(2 − 1) = 3 × 255 = 765. The same formula explains an old legend of grains of rice on a chessboard, doubling from 1 grain on the first square. Over all 64 squares the total is 2⁶⁴ − 1 = 18,446,744,073,709,551,615 grains, a number beyond any real harvest.

Partial sums of 3, 6, 12, …
naₙSₙ (running total)Formula 3(2ⁿ − 1)
1333 × 1 = 3
2693 × 3 = 9
312213 × 7 = 21
424453 × 15 = 45
83847653 × 255 = 765
Finite series formulas at a glance
SeriesFormulaExample result
ArithmeticSₙ = n/2 · (a₁ + aₙ)S₁₀ = 185
GeometricSₙ = a₁(1 − rⁿ)/(1 − r)S₈ = 765
Whole numbersn(n + 1)/2S₁₀₀ = 5050

8. Infinite series and convergence

What if a series never stops? An infinite series adds endless terms. We look at the partial sums S₁, S₂, S₃, …. If they settle toward a single number, the series converges to that number. If they grow without limit or never settle, it diverges.

For a geometric series with |r| < 1, rⁿ fades to zero, so the finite formula becomes S = a₁ / (1 − r). Take 1 + 1/2 + 1/4 + 1/8 + …. Here a₁ = 1 and r = 1/2, so S = 1/(1 − 1/2) = 2. Each term fills half of what remains between the running total and 2, so the total gets ever closer but never passes it.

Partial sums of one plus one half plus one quarter approaching 2
The partial sums approach 2 and never exceed it.

If |r| ≥ 1, the geometric series diverges. The series 1 + 2 + 4 + 8 + … does not equal −1, which the formula would wrongly suggest. The sum simply grows without limit. The formula is valid only when |r| < 1.

Infinite geometric series
Seriesa₁rSum a₁/(1 − r)
1 + 1/2 + 1/4 + …11/22
0.9 + 0.09 + 0.009 + …0.90.11 (so 0.999… = 1)
0.3 + 0.03 + 0.003 + …0.30.11/3 (so 0.333… = 1/3)
8 + 4 + 2 + …81/216
1 + 2 + 4 + …12diverges

A bouncing ball makes this concrete. Dropped from 10 metres, it rebounds to 60 percent of its previous height each time. The rebound heights are 6, 3.6, 2.16, and so on, a geometric series with sum 6/(1 − 0.6) = 15. The ball travels up and down each time, so the total distance is 10 + 2 × 15 = 40 metres, even though it bounces infinitely often.

Path of a bouncing ball with heights 10, 6, 3.6 and 2.16
Infinitely many bounces, finite distance.

Be careful: terms shrinking toward zero is necessary for convergence but not sufficient. The harmonic series 1 + 1/2 + 1/3 + 1/4 + … has terms that shrink to zero, yet it diverges, because its partial sums keep climbing, very slowly. By contrast, 1 + 1/4 + 1/9 + 1/16 + … converges to about 1.645.

Partial sums of the harmonic series rising versus the sum of reciprocal squares levelling off
Two series whose terms both shrink to zero, with opposite fates.
Partial sums of two series with shrinking terms
Terms added n1 + 1/2 + 1/3 + … (harmonic)1 + 1/4 + 1/9 + … (squares)
102.9291.550
1005.1871.635
1,0007.4851.644

9. Recursive sequences and Fibonacci

Sometimes a sequence is naturally defined by a recursive rule. The most famous example is the Fibonacci sequence: F₁ = 1, F₂ = 1, and Fₙ = Fₙ₋₁ + Fₙ₋₂. Each term is the sum of the two before it, giving 1, 1, 2, 3, 5, 8, 13, 21, and so on. It appears in the branching of plants and the spiral arrangement of seeds.

It is neither arithmetic nor geometric, yet it hides a geometric pattern. The ratio of neighbouring terms, Fₙ₊₁/Fₙ, settles toward the golden ratio, φ = (1 + √5)/2 ≈ 1.618. For large n, the Fibonacci numbers grow almost like a geometric sequence with ratio 1.618.

Ratios of consecutive Fibonacci numbers converging to 1.618
The ratio of neighbouring Fibonacci numbers converges to the golden ratio.
Fibonacci numbers and their ratios
nFₙFₙ₊₁ / Fₙ
111.0000
212.0000
321.5000
431.6667
551.6000
681.6250
8211.6190
10551.6182
143771.6180

10. Real-world patterns

Series formulas solve practical problems. Suppose a worker starts at 40,000 dollars and receives a 2,000 dollar raise every year. Her pay forms an arithmetic sequence, and over 10 years she earns a total of 10/2 · (2 · 40000 + 9 · 2000) = 490,000 dollars.

A savings plan is a geometric series. Deposit 100 dollars at the end of each month into an account earning 0.5 percent monthly. The deposit made k months before the end has grown by 1.005ᵏ, so the balance after 12 months is 100(1 + 1.005 + … + 1.005¹¹) = 100 · (1.005¹² − 1)/0.005 ≈ 1,233.56 dollars, slightly more than the 1,200 deposited.

Four real-world series
SituationTypeResult
raises of $2,000 a year for 10 years from $40,000arithmetic$490,000 earned
$100 a month at 0.5% a month for 12 monthsgeometric$1,233.56
rice doubling on 64 chessboard squaresgeometric18,446,744,073,709,551,615 grains
pyramid of 10 rows of cans (1 + 2 + … + 10)arithmetic55 cans

11. AI and machine learning

Machine learning is full of sequences and series. Training itself is a sequence: the weights w₀, w₁, w₂, … are produced by repeated updates. For the loss (w − 3)² + 2 from the quadratics article, with learning rate 0.25, each step halves the distance to the minimum at 3. The weights run 0, 1.5, 2.25, 2.625, …, and the error 3 · (1/2)ᵗ is a geometric sequence with ratio ½.

Left: weights approaching 3. Right: the error shrinking along a straight line on a log axis
Gradient descent produces a sequence whose error is geometric.
Gradient descent as a sequence
Step tWeight wₜError |wₜ − 3|Step size taken
0031.5
11.51.50.75
22.250.750.375
32.6250.3750.1875
42.81250.18750.0938
52.90620.09380.0469

The step sizes 1.5, 0.75, 0.375, … form a geometric series whose sum is 1.5/(1 − 0.5) = 3, exactly the total distance from the starting weight 0 to the minimum at 3. The infinite series explains why the process ends at a finite place.

Reinforcement learning uses discounted sums. An agent that receives reward r at each future step values them with a discount factor γ between 0 and 1: G = r + γr + γ²r + …. This is geometric with ratio γ, so a steady reward of 1 is worth 1/(1 − γ). With γ = 0.9 that is 10, and with γ = 0.99 it is 100. A discount close to 1 makes the agent look much further ahead.

Cumulative discounted reward for gamma 0.9 and 0.99 approaching limits 10 and 100
Higher γ means a larger limit and slower convergence.
Discounted return of a steady reward of 1
Discount γLimit 1/(1 − γ)Sum after 50 stepsShare of limit reached
0.522.00100.0%
0.9109.9599.5%
0.9910039.5039.5%

The exponential moving average used by many optimisers weights the past by (1 − β)βᵏ. Those weights are geometric and sum to exactly 1, so the average stays on the right scale. Series also compute functions: a calculator or library can approximate eˣ by the series 1 + x + x²/2! + x³/3! + …. For x = 1 the partial sums close in on e ≈ 2.71828 quickly.

Partial sums of 1 + 1 + 1/2! + 1/3! + … approaching e
Terms (up to 1/n!)nPartial sum
2 terms12.00000
3 terms22.50000
4 terms32.66667
5 terms42.70833
7 terms62.71806
9 terms82.71828

Finally, nearly every loss is a finite series. The total squared error over a dataset is a sum of N terms, and its average divides by N. Text, audio and sensor streams are sequences, and models for them, from recurrent networks to transformers, are built to process one term in relation to the others.

The same ideas, two vocabularies
AlgebraMachine learning
sequencetraining steps, token streams, time series
recursive rule aₙ = f(aₙ₋₁)update rule wₜ₊₁ = wₜ − η∇L; recurrent state
geometric sequence, ratio rdecaying error, learning-rate decay, discount γ
infinite geometric seriesdiscounted return, exponential moving average
finite series Σtotal loss over a dataset
convergencetraining converging to a minimum

12. Common mistakes

Frequent mistakes and corrections
MistakeWrongRight
Off-by-one in the nth termaₙ = 5 + 3n gives a₁₀ = 35aₙ = 5 + 3(n − 1) gives a₁₀ = 32
Miscounting the terms7, 10, …, 100: n = 31n = (100 − 7)/3 + 1 = 32
Using the infinite formula when |r| ≥ 11 + 2 + 4 + … = 1/(1 − 2) = −1diverges; formula needs |r| < 1
Confusing sequence and series"the sum of 2, 4, 6" as a listsequence = list; series = sum
Assuming shrinking terms converge1 + 1/2 + 1/3 + … convergesit diverges (the harmonic series)
Mixing formulasarithmetic formula on 3, 6, 12equal ratios, so use the geometric formula

13. Practice problems

Try these before looking at the answers.

  1. Find the 20th term of 4, 7, 10, ….
  2. Find the 6th term of 5, 10, 20, ….
  3. Find the sum of the first 50 positive integers.
  4. Find the sum of the first 6 terms of 2 + 6 + 18 + ….
  5. Find the sum of 8 + 4 + 2 + 1 + … (infinitely many terms).
  6. Evaluate Σ (k=1 to 4) (3k − 1).
  7. Does 5 + 7.5 + 11.25 + … converge? Explain.
  8. An agent earns a reward of 1 every step with discount γ = 0.8. What is the total discounted return?

Answers.

  1. 4 + 3(19) = 61.
  2. 5 · 2⁵ = 160.
  3. 50 · 51 / 2 = 1275.
  4. 2(3⁶ − 1)/(3 − 1) = 728.
  5. 8/(1 − 1/2) = 16.
  6. 2 + 5 + 8 + 11 = 26.
  7. No. The ratio is r = 1.5, and |r| ≥ 1, so the series diverges.
  8. 1/(1 − 0.8) = 5.

14. Conclusion

A sequence is an ordered list, and a series is its sum. Arithmetic sequences add a constant difference and have the nth term a₁ + (n − 1)d; geometric sequences multiply by a constant ratio and have the nth term a₁rⁿ⁻¹. Their sums have clean formulas, and an infinite geometric series converges to a₁/(1 − r) exactly when the ratio is smaller than 1 in size.

In machine learning these ideas describe training sequences that converge, discounted rewards, moving averages and total losses. The next article moves from patterns of numbers to comparisons between them: inequalities.