Objective
Learning objectives
- Distinguish arithmetic sequences (constant added step) from geometric sequences (constant multiplied step)
- Read sequence notation and write both an explicit and a recursive definition
- Generate both sequence types in Python and plot them
- Classify a sequence from its first few terms and predict its next term
Hook
A model's validation accuracy after each training epoch: 60%, 65%, 70%, 75% — what pattern continues that? And a model's error rate after each epoch: 40%, 20%, 10%, 5% — is that the same kind of pattern, or a genuinely different one? Both are sequences of numbers, one per step. The question worth pausing on is whether "improving steadily" always looks the same way numerically, or whether there's more than one real shape "steady improvement" can take.
See it
The accuracy numbers add a fixed 5 each epoch: 60, 65, 70, 75, 80, 85, 90, 95. The error-rate numbers multiply by a fixed 0.5 each epoch: 40, 20, 10, 5, 2.5, 1.25. Plotted side by side, the first is a straight line — Phase 01's linear functions, exactly. The second curves, flattening as it goes — Phase 01's nonlinear functions, exactly. A sequence is genuinely nothing more than a function, evaluated only at whole-number steps (1, 2, 3, ...) instead of every possible input.
Name it
An arithmetic sequence adds the same fixed amount (d, the common difference) to get each next term. A geometric sequence multiplies by the same fixed amount (r, the common ratio) to get each next term — the sequence version of Phase 02's exponential growth and decay.
Sequence notation writes the n-th term as a_n, with a_1 as the first term. There are two equally valid ways to define one:
- Explicit: a direct formula for any term from its position alone — arithmetic:
a_n = a_1 + (n - 1) × d; geometric: a_n = a_1 × r^(n - 1). - Recursive: each term defined from the previous term — arithmetic:
a_n = a_(n-1) + d; geometric: a_n = a_(n-1) × r. Computing a_100 recursively means computing all 99 terms before it; explicitly, it's one direct calculation.
Code it
def arithmetic(a1, d, n_terms):
return [a1 + i * d for i in range(n_terms)]
def geometric(a1, r, n_terms):
return [round(a1 * (r ** i), 4) for i in range(n_terms)]
accuracy = arithmetic(60, 5, 8)
error_rate = geometric(40, 0.5, 8)
print(accuracy)
print(error_rate)
[60, 65, 70, 75, 80, 85, 90, 95]
[40.0, 20.0, 10.0, 5.0, 2.5, 1.25, 0.625, 0.3125]
Both functions are the explicit definition — each computes a_n directly from n, with no dependency on having already built the terms before it. Here's the same two sequences, built recursively instead, to show they land on identical results either way:
def arithmetic_recursive(a1, d, n_terms):
seq = [a1]
for _ in range(n_terms - 1):
seq.append(seq[-1] + d)
return seq
print(arithmetic_recursive(60, 5, 8))
[60, 65, 70, 75, 80, 85, 90, 95]
import matplotlib.pyplot as plt
steps = list(range(1, 9))
plt.plot(steps, accuracy, marker="o", label="accuracy (arithmetic)")
plt.plot(steps, error_rate, marker="o", label="error rate (geometric)")
plt.xlabel("epoch")
plt.legend()
plt.savefig("sequence_comparison.png", dpi=150, bbox_inches="tight")
print(geometric(3, 2, 6))
Explicit geometric formula, a1 = 3, r = 2: each term is 3 × 2^(n-1) — 3, then 3×2=6, then 3×4=12, then 3×8=24, then 3×16=48, then 3×32=96. Doubling each step, starting from 3 instead of 1 — the exact same repeated-multiplication pattern as Phase 02's rumor example, just a different starting value.