Arithmetic and Geometric Progressions

Published on 2026-11-04·v1.0

Learning Objectives

  • Recognize an arithmetic or geometric progression from a constant difference or a constant ratio, and write its nn-th term.
  • Derive and use the closed forms for the sum of the first nn terms of each, including the special case r=1r = 1 and the correct count of terms.
  • Decide the long-run behavior of rnr^n for every real ratio rr, and tie it to convergence of a sequence.
  • Translate loops into sums: nested loops give arithmetic sums, halving and doubling give geometric ones.
  • Use a geometric sum to explain the cost of a doubling array and of compound growth, and contrast them with their arithmetic counterparts.

Context & Motivation

Among all sequences, two families have closed forms simple enough to handle exactly and common enough to appear in almost every cost analysis. In an arithmetic progression each term differs from the previous one by a fixed amount dd. In a geometric progression each term is a fixed multiple rr of the previous one. The first describes linear growth, the second exponential growth, and the contrast between them is the contrast between a loop that does a little more work each pass and a process that multiplies its size.

In the previous lesson, sequences-and-convergence, you learned what it means for a sequence to settle down. A progression is the easiest place to practice that definition, since the answer is known in closed form. The sums of progressions are also where the sequence (an)(a_n) turns into a new sequence of partial sums, the idea that the next lesson, infinite-series-and-partial-sums, builds on. The data-structures lesson dynamic-arrays-and-amortized-resizing argues that doubling a full array keeps appends cheap on average and that adding a fixed amount does not. This lesson supplies the arithmetic behind both claims and checks them with an actual count.

Core Theory

Arithmetic progressions

A sequence with an+1−an=da_{n+1} - a_n = d for every nn is an arithmetic progression with first term a1a_1 and common difference dd. Its terms are

an=a1+(n−1) da_n = a_1 + (n-1)\,d

Its sum Sn=a1+a2+⋯+anS_n = a_1 + a_2 + \dots + a_n can be found by writing the sum twice, once forward and once backward, and adding the columns: every column adds to a1+ana_1 + a_n, and there are nn columns, so 2Sn=n(a1+an)2S_n = n(a_1 + a_n). Hence

Sn=n (a1+an)2=n (2a1+(n−1)d)2S_n = \frac{n\,(a_1 + a_n)}{2} = \frac{n\,\bigl(2a_1 + (n-1)d\bigr)}{2}

The same formula can be proved by induction, as in mathematical-induction. The special case a1=1a_1 = 1, d=1d = 1 gives 1+2+⋯+n=n(n+1)/21 + 2 + \dots + n = n(n+1)/2. For d≠0d \neq 0 the terms grow linearly in nn and the sums quadratically. If d≠0d \neq 0 the sequence (an)(a_n) diverges (it grows without bound, upward or downward), and if d=0d = 0 it is constant.

Geometric progressions

A sequence with an+1=r ana_{n+1} = r\,a_n is a geometric progression with ratio rr:

an=a1 r n−1a_n = a_1\, r^{\,n-1}

For the sum, subtract rSnr S_n from SnS_n. Every term cancels except the first and the last, leaving Sn(1−r)=a1(1−rn)S_n(1 - r) = a_1(1 - r^n), so

Sn=a1 1−rn1−r(r≠1)S_n = a_1\,\frac{1 - r^n}{1 - r} \qquad (r \neq 1)

This formula divides by 1−r1 - r, so it does not apply when r=1r = 1. In that case every term equals a1a_1 and Sn=n a1S_n = n\,a_1. When the sum starts at the exponent 00, as in 1+r+⋯+rn1 + r + \dots + r^n, there are n+1n + 1 terms and the formula reads (1−rn+1)/(1−r)(1 - r^{n+1})/(1 - r). Counting terms wrongly is the most common error in applying it.

What rnr^n does

The behavior of the sequence (rn)(r^n) is the whole story for convergence of geometric progressions:

  • If ∣r∣<1\lvert r \rvert < 1, then rn→0r^n \to 0.
  • If r=1r = 1, the sequence is constant 11.
  • If r=−1r = -1, it alternates between −1-1 and 11 and diverges.
  • If r>1r > 1, then rn→∞r^n \to \infty. If r<−1r < -1, the terms alternate in sign and their size grows without bound, so it diverges.

To see the first case, note that r=0r = 0 is immediate; for r≠0r \neq 0, write ∣r∣=1/(1+h)\lvert r \rvert = 1/(1+h) with h>0h > 0. Bernoulli's inequality gives (1+h)n≥1+nh(1+h)^n \ge 1 + nh, so 0≤∣r∣n≤1/(1+nh)→00 \le \lvert r \rvert^n \le 1/(1 + nh) \to 0, and the squeeze theorem finishes the proof. Consequently a geometric progression a1rn−1a_1 r^{n-1} converges exactly when ∣r∣<1\lvert r \rvert < 1 (to 00) or r=1r = 1 (to a1a_1), provided a1≠0a_1 \neq 0. And when ∣r∣<1\lvert r \rvert < 1, the closed form shows the partial sums settling at a1/(1−r)a_1/(1-r), since rn→0r^n \to 0 (the next lesson turns this into a theorem about infinite series).

Loops, halving, and doubling

Counting the iterations of a program often means summing a progression. An inner loop whose bound grows by one each outer pass gives an arithmetic sum, hence Θ(n2)\Theta(n^2) in total. A quantity that is halved at each step, as in a loop while n > 1: n //= 2, runs ⌊log⁡2n⌋\lfloor \log_2 n \rfloor times, and in a recursion that does work proportional to its input size and then recurses on half of it, the successive amounts n,n/2,n/4,…n, n/2, n/4, \dots form a geometric progression. In a geometric sum with r>1r > 1 the last term dominates: 1+2+⋯+2k−1=2k−11 + 2 + \dots + 2^{k-1} = 2^k - 1 is less than twice the last term 2k−12^{k-1}. That fact is what makes doubling cheap.

Worked Examples

Example 1: arithmetic sums from loops

The loop for i in range(n): for j in range(i): count += 1 runs the inner body 0+1+⋯+(n−1)=n(n−1)/20 + 1 + \dots + (n-1) = n(n-1)/2 times. Running it gives 4545 for n=10n = 10, 49504950 for n=100n = 100, and 499500499500 for n=1000n = 1000, matching the formula each time. It is about half of n2n^2, yet still quadratic.

Now invert the question. For the progression 5,8,11,14,…5, 8, 11, 14, \dots (so a1=5a_1 = 5, d=3d = 3), find the smallest nn with Sn>1000S_n > 1000. Here Sn=n(3n+7)/2S_n = n(3n + 7)/2, so we need 3n2+7n−2000>03n^2 + 7n - 2000 > 0. The positive root is (−7+24049)/6≈24.68(-7 + \sqrt{24049})/6 \approx 24.68. Check the neighbors: S24=948S_{24} = 948 and S25=1025S_{25} = 1025. The answer is n=25n = 25, whose last term is a25=77a_{25} = 77.

Example 2: geometric sums and the count of terms

For 3+6+12+…3 + 6 + 12 + \dots with 1010 terms, a1=3a_1 = 3, r=2r = 2:

S10=3 1−2101−2=3⋅1023=3069S_{10} = 3\,\frac{1 - 2^{10}}{1 - 2} = 3 \cdot 1023 = 3069

For 1+12+14+…1 + \tfrac12 + \tfrac14 + \dots with 1010 terms, S10=1−2−101−1/2=2−2−9=1.998046875S_{10} = \dfrac{1 - 2^{-10}}{1 - 1/2} = 2 - 2^{-9} = 1.998046875. Adding the ten terms directly gives the same number. The sum 1+2+4+⋯+291 + 2 + 4 + \dots + 2^9 is 1023=210−11023 = 2^{10} - 1, the largest number that fits in ten bits, since every bit set to 11 contributes one power of two. The exponents 00 through 99 make 1010 terms, not 99.

Example 3: counting the copies of a doubling array

Each append to a full array copies every stored element into a larger array. The script below counts only those copies, starting from capacity 11, for two growth rules: doubling the capacity, and adding 1616 slots.

plaintext
def count_copies(n, grow): capacity, length, copies = 1, 0, 0 for _ in range(n): if length == capacity: # full: allocate a bigger array and copy copies += length capacity = grow(capacity) length += 1 # the append itself (one write) return copies for n in (10, 1_000, 10_000, 100_000, 1_000_000): dbl = count_copies(n, lambda c: 2 * c) inc = count_copies(n, lambda c: c + 16) print(f"{n:>9} doubling: {dbl:>9} ({dbl / n:.2f} per append) +16: {inc:>12} ({inc / n:.1f} per append)")

Its output:

text
10 doubling: 15 (1.50 per append) +16: 1 (0.1 per append) 1000 doubling: 1023 (1.02 per append) +16: 31311 (31.3 per append) 10000 doubling: 16383 (1.64 per append) +16: 3120625 (312.1 per append) 100000 doubling: 131071 (1.31 per append) +16: 312456250 (3124.6 per append) 1000000 doubling: 1048575 (1.05 per append) +16: 31249562500 (31249.6 per append)

Doubling. The resizes happen when the length is 1,2,4,…1, 2, 4, \dots, so the copies form the geometric sum 1+2+⋯+2k−1=2k−11 + 2 + \dots + 2^{k-1} = 2^k - 1, where 2k2^k is the final capacity, the smallest power of two that is at least nn. For n=106n = 10^6 that is 220−1=10485752^{20} - 1 = 1048575, exactly the count. Since 2k<2n2^k < 2n, the copies are always below 2n2n, which is the bound used in dynamic-arrays-and-amortized-resizing. The ratio per append is not constant: it is 1.021.02 at n=1000n = 1000 and 1.641.64 at n=104n = 10^4, because the array doubled to capacity 1638416384 at append 81938193, and the 1638316383 copies so far are spread over only 10410^4 appends. It stays under 22 throughout.

Adding 16. The resizes happen at lengths 1,17,33,…1, 17, 33, \dots, an arithmetic progression with d=16d = 16. With m=⌊(n−2)/16⌋m = \lfloor (n-2)/16 \rfloor, the copies total (m+1)+16 m(m+1)/2(m+1) + 16\,m(m+1)/2. For n=1000n = 1000, m=62m = 62 and the total is 63+31248=3131163 + 31248 = 31311, as counted. The cost per append grows like n/32n/32, so it keeps getting worse with nn.

This compares copies only. Doubling pays in memory: right after a resize up to half the array is unused, whereas adding 1616 wastes at most 1515 slots. And the factor 22 is not special. Growing the capacity by any fixed factor r>1r > 1 keeps copies per append bounded by about r/(r−1)r/(r-1), so factor 1.51.5 (rounded up) measures 2.102.10 per append at n=106n = 10^6 and factor 1.1251.125 measures 8.688.68. A smaller factor trades fewer unused slots for more copying.

Example 4: compound growth versus simple growth

Take an account holding 10001000 with a fixed 5%5\% annual rate and annual compounding. Simple interest adds 5050 each year, an arithmetic progression: 1000+50k1000 + 50k, which is 25002500 after 3030 years. Compound interest multiplies by 1.051.05, a geometric one: 1000⋅1.05k1000 \cdot 1.05^k equals 10501050 after 11 year, 1628.891628.89 after 1010, and 4321.944321.94 after 3030. The balance doubles when 1.05k=21.05^k = 2, at k=ln⁡2/ln⁡1.05≈14.21k = \ln 2 / \ln 1.05 \approx 14.21 years (the rule of thumb 72/5=14.472/5 = 14.4 is close).

Regular deposits form a geometric sum. Depositing 100100 at the end of each month for 120120 months at monthly rate i=0.05/12i = 0.05/12 gives 100 (1+i)120−1i≈15528.23100\,\dfrac{(1+i)^{120} - 1}{i} \approx 15528.23, while the deposits themselves total 1200012000. Applying the deposits one month at a time in a loop reproduces 15528.2315528.23.

Common Misconceptions & Pitfalls

  • Off-by-one in the number of terms. The sum r0+r1+⋯+rnr^0 + r^1 + \dots + r^n has n+1n + 1 terms, and using nn in the exponent of the formula gives the wrong answer. Write the first and last exponent, count, and then substitute.
  • Applying the geometric formula at r=1r = 1. It divides by zero. The sum is n a1n\,a_1, and this case matters because a loop with ratio exactly 11 is just a loop.
  • "The sum of an arithmetic progression is linear." For d≠0d \neq 0 the terms are linear in nn and the sum is quadratic. A nested loop with a bound that grows with the outer counter is Θ(n2)\Theta(n^2), even though the inner count is "only" ii.
  • "A geometric progression with r>1r>1 is dominated by its first terms." For r>1r > 1 the last term dominates, and the sum is a bounded multiple of it. For ∣r∣<1\lvert r \rvert < 1 the first term dominates. That is why the copy costs of a doubling array add up to a small multiple of nn.
  • "Amortized O(1) means each append is cheap." In Example 3 the append at length 219=5242882^{19} = 524288 copies that many elements at once. The claim concerns the average over many appends, not any single one.
  • "A ratio r<−1r < -1 makes the terms tend to −∞-\infty." The terms alternate in sign with growing size, so the sequence has no limit at all, finite or infinite.

Summary

An arithmetic progression adds a fixed difference: an=a1+(n−1)da_n = a_1 + (n-1)d and Sn=n(a1+an)/2S_n = n(a_1 + a_n)/2, so for d≠0d \neq 0 terms grow linearly and sums quadratically. A geometric progression multiplies by a fixed ratio: an=a1rn−1a_n = a_1 r^{n-1} and Sn=a1(1−rn)/(1−r)S_n = a_1(1 - r^n)/(1 - r) for r≠1r \neq 1, with Sn=n a1S_n = n\,a_1 at r=1r = 1. The sequence (rn)(r^n) tends to 00 exactly when ∣r∣<1\lvert r \rvert < 1, which settles when a geometric progression converges. Counting terms carefully matters, because the same pattern gives nn or n+1n+1 terms depending on where the exponent starts. In computing, nested loops produce arithmetic sums, halving produces log⁡2n\log_2 n steps, and doubling produces a geometric sum dominated by its last term, which is why a doubling array copies fewer than 2n2n elements over nn appends while a fixed increment of 1616 copies about n2/32n^2/32. Compound growth is the same geometric structure with money in place of memory. The next lesson, infinite-series-and-partial-sums, asks what happens to these sums when the number of terms is allowed to grow forever.

Documentation Links