Sub topic 2
Geometric progressions and the common ratio
This chapter assumes you can work with fractions, exponents and the laws of indices, and that you can solve a linear equation.
Geometric progressions and the common ratio
A geometric progression (GP) is a sequence in which each term is the previous term multiplied by a fixed number. That fixed number is the common ratio, written r. The sequence 2, 6, 18, 54 has r = 3.
To test a sequence, divide each term by the term before it. If every result is the same, the sequence is a GP and that result is r. Otherwise it is not a GP. The ratio can be negative or a fraction. The sequence 8, 4, 2, 1 has r = 1/2.
Finding the nth term of a GP
With first term a and common ratio r, the nth term is:
T(n) = a × r^(n−1)
The exponent is n − 1 because the first term needs no multiplication by r.
def gp_nth(a, r, n):
return a * r ** (n - 1)
print(gp_nth(2, 3, 5)) # 162Summing a finite GP
The sum of the first n terms is:
| Case | Formula for the sum S(n) |
|---|---|
| r > 1 | a(r^n − 1)/(r − 1) |
| r < 1 | a(1 − r^n)/(1 − r) |
| r = 1 | n × a |
Choosing the form that keeps the top and bottom positive avoids sign errors.
from fractions import Fraction
def gp_sum(a, r, n):
a, r = Fraction(a), Fraction(r)
if r == 1:
return a * n
return a * (1 - r ** n) / (1 - r)
print(gp_sum(2, 3, 5)) # 242Infinite GP: when the sum exists and what it equals
The infinite sum exists only when |r| < 1, because then r^n shrinks toward 0 as n grows. In that case:
S = a / (1 − r)
from fractions import Fraction
def gp_infinite_sum(a, r):
a, r = Fraction(a), Fraction(r)
if abs(r) >= 1:
raise ValueError("the sum exists only when |r| < 1")
return a / (1 - r)
print(gp_infinite_sum(8, Fraction(1, 2))) # 16Exercise
Find the sum of the infinite series 3 + 1 + 1/3 + 1/9 + ...
Show answer
Here a = 3 and r = 1/3. Since |r| < 1, S = 3 / (1 − 1/3) = 3 / (2/3) = 9/2 = 4.5.