6. Sequences, Series & Growth Rates
Level: Beginner You'll use this for: capacity planning, understanding "doubling," and recognizing exponential trouble early.
Arithmetic vs. geometric
- Arithmetic sequence: constant difference.
2, 5, 8, 11, ...(+3 each step). Sum of firstnterms:n/2 · (first + last). - Geometric sequence: constant ratio.
2, 4, 8, 16, ...(×2 each step).nth term:a·r^(n-1). Sum of firstnterms (r≠1):a·(r^n - 1)/(r-1).
Where these sum formulas actually come from
Arithmetic sum — Gauss's pairing trick. To sum 1, 2, 3, ..., 10,
write the sum forwards and backwards underneath itself, and add
column-by-column:
1 + 2 + 3 + ... + 9 + 10
+10 + 9 + 8 + ... + 2 + 1
------------------------------------
11 + 11 + 11 + ... + 11 + 11 <- every column sums to 11 (first+last)
10 columns × 11 = 110, but that's DOUBLE the sum (we added it to itself),
so the actual sum = 110 / 2 = 55.
Generalizing: n columns each summing to (first + last), then halved —
exactly the formula n/2 · (first + last) given above.
Geometric sum — the telescoping trick. To sum S = a + ar + ar² + ... + ar^(n-1), multiply the whole sum by r and subtract:
S = a + ar + ar² + ... + ar^(n-1)
rS = ar + ar² + ... + ar^(n-1) + ar^n
--------------------------------------------------
S - rS = a - ar^n <- everything in the
middle cancels
S(1 - r) = a(1 - r^n)
S = a(1 - r^n) / (1 - r) <- same as a(r^n - 1)/(r - 1), signs flipped
Both derivations use the same move: rewrite the sum a second way so that almost everything cancels, leaving a formula with no loop required.
The Rule of 72 (mental-math doubling time)
For any exponential growth at rate r% per period, time to double ≈
72 / r. Growing disk usage at 8%/month? Doubles in ~9 months. This is the
single fastest sanity check for "is this growth curve about to become a
problem."
def doubling_time(rate_percent):
return 72 / rate_percent
print(doubling_time(8)) # 9.0 months
Worked example: viral growth / incident blast radius
A worm that infects 1 host, and each infected host infects 2 more per hour,
follows hosts(t) = 3^t (1 becomes 3 total: itself + 2 new, compounding).
After 10 hours: 3^10 = 59,049 hosts. This is why "time to detect and
contain" matters exponentially more than "time to detect" alone — an extra
hour of dwell time in an exponential spread isn't linear damage, it's
multiplicative.
for t in range(0, 11):
print(t, 3**t)
# by hour 10: 59,049 — by hour 15: 14,348,907
Real-life engineering ties
- SWE: Fibonacci-style retry backoff, amortized array-doubling
(
ArrayList/Veccapacity growth), pagination cost. - AI: dataset/model size scaling laws are often near-geometric; training cost vs. model size follows power-law curves.
- Network: exponential backoff for TCP retransmission and Wi-Fi CSMA/CA
collision avoidance (Ch. 25) is literally a geometric sequence
(
wait = base · 2^attempt). - Security: malware/worm propagation modeling, credential-stuffing attack scaling, and understanding why "small" unpatched vulnerabilities compound (an attacker chaining 3 low-severity bugs can have multiplicatively higher impact than any one alone).
More real-life examples:
- The 2016 Mirai botnet and the 2017 WannaCry ransomware both spread by having each infected device scan for and infect several more — textbook exponential growth, which is why "time to detect" mattered exponentially more than any single infection.
- Compound interest (
A = P(1+r)^t) is the same geometric-sequence formula as this chapter's worm-spread example, just with a friendlier sign — "financial literacy" and "understanding exponential attack growth" are the same math with different subject matter. - Cloud cost forecasting (e.g., "our S3 storage bill is growing 6%/month") uses the Rule of 72 to sanity-check budget requests: 6%/month doubles storage spend in about 12 months, a number FinOps teams use directly.
- AWS SDKs and gRPC clients implement retry backoff as a geometric
sequence (
delay = base * 2^attempt, often with jitter) specifically so retry storms don't recreate the exponential-growth problem they're trying to avoid.
Common mistake
Assuming a curve that "looks linear" for the first few data points will stay linear. Exponential curves look almost flat right up until they don't — always check the ratio between consecutive periods, not just the absolute delta.