Geometric Series
In one sentence: A geometric series adds up a list where each term is the one before it times a fixed number, and this formula finds the whole sum in one step.
Read it out loud: “The sum, written with the Greek capital letter sigma, for k from 0 up to n minus 1, of r to the power k, equals one minus r to the power n, divided by one minus r. This works when r is not equal to 1. The letter k is a counter, r is the common ratio that each term is multiplied by, and n is the number of terms.”
Before you start
The ideas and signs this page uses, explained from zero. For powers of ten, Greek letters and other notation in general, see Math basics.
- The sum sign
The capital Greek letter sigma, written , means add up. Below it, says where the counter starts, and the letter on top, , says where it stops. So means . The sum has terms when runs from 0 to .
- Powers, like
A small raised number is an exponent. means multiplied by itself times, so . Any number to the power 0 equals 1, so . A negative exponent means divide: , which is one half.
- The common ratio
In a geometric series, each term is the one before it times the same number , which is called the common ratio. With the terms are 1, 2, 4, 8, 16. With the terms are 1, one half, one quarter, and so on. The list grows or shrinks by a fixed factor each time, not by a fixed amount.
- Limits and getting close to a value
A limit is the value that a quantity gets closer and closer to as a counter keeps growing. The terms , , get closer and closer to 0. The sum gets closer and closer to 2, and it never goes past 2.
- The not-equal sign and the dots
means that is not equal to 1. The three dots mean that the list continues in the same pattern, so keeps doubling until the last term, 512. The dots are a shorthand for ‘and so on’.
- Dynamic array (background)
A dynamic array is a list stored in computer memory in one block with a fixed amount of room. When the block is full and a new item arrives, the program builds a new block twice as big and copies every old item across. Copying takes time, so the total copying work matters for how fast adding items is.
- Reward discount factor (background)
In reinforcement learning, a method where a computer learns from rewards, a reward received later is worth less. The factor (gamma, a Greek letter) is a number between 0 and 1, and a reward received steps later is multiplied by . Adding these discounted rewards gives a geometric series.
What each symbol means
| Symbol | Meaning |
|---|---|
| Add up the terms for every from 0 up to . That is terms in all, because the counter starts at 0. The sum has no unit when the terms count things, such as copies or dollars. | |
| The step counter, a whole number that starts at 0 and goes up by 1. The first term is at , which is . It counts positions in the list, so it has no unit. | |
| The term at step : the number multiplied by itself times. For and , the term is . Its unit is the same unit as the terms of the list, such as copies. | |
| The common ratio, the number each term is multiplied by to get the next term. For doubling, . The formula needs , because the division by would be zero. The ratio has no unit. | |
| The number of terms in the series, a whole number such as 4 or 10. It counts the terms that are added, so it has no unit. It is not the same thing as the size of the list being built in the example. | |
| The closed form, a quick way to find the total. The top, , is what is left after cancellation, and the bottom, , is the factor that remains. The division by is why the formula excludes . |
The formula piece by piece
The term at step , which is multiplied by itself times. When the term is 1, when it is , and when it is . The whole series is these terms added together.
The total of all terms, from the first term at to the last term at . This is the total we want to find. The rest of the formula gives a faster way to find it than adding every term.
The term one step past the end of the list. It is the next term after , because . Multiplying the whole sum by shifts every term one place along, so appears when the shifted list is lined up against the original.
The leftover after the cancellation. When the shifted sum is subtracted from the original sum, almost every term cancels, and only the first term 1 and the last term remain. Dividing by turns that leftover into the total.
In one plain sentence: adding the first powers of , starting from , gives 1 minus , divided by 1 minus , as long as is not equal to 1.
What the formula is doing, and why
What goes in and what comes out. You give the formula a ratio and a number of terms . You get the sum of the terms . The ratio decides almost everything, because each term is the last one times . The formula gives the total directly, without adding each term one by one.
Why does the trick work? Call the sum . Multiply the whole list by , and every term moves one place along. Now subtract the shifted list from the original. Almost every term cancels, and is what remains. Dividing by gives . The division needs , because would then be zero. If , every term is 1, and the sum is .
Why does the answer depend on whether is bigger than 1? If , the terms grow, the last term is the biggest, and for large the sum is close to . If , the terms shrink, and the sum settles toward as grows. For , the sum gets close to 2.
Why is doubling cheap on average? The early steps are small, so the total is less than twice the final size. In the example below, the copies made while a list doubles add up to less than twice the number of items. The last copy alone is about half of all the copying, so the work is concentrated at the end.
An everyday picture
Think of a savings plan that doubles each week. You save 1 dollar in week 1, 2 dollars in week 2, 4 dollars in week 3, and so on. After 3 weeks your total is 1 + 2 + 4 = 7 dollars, which is one less than twice the 4 dollars you saved in week 3. In general, after weeks your total is one less than twice what you saved in the last week.
Worked example: Copies in a doubling array
A dynamic array starts with room for 1 item. When it is full and a new item arrives, it builds a new block with twice the room and copies every item across. We add 10 items and count the copies. The copies form a geometric series with ratio . Its number of terms is the number in the formula, which is 4 here, not 10.
- Find when the block is full. The block starts with room for 1 item. Adding item 2 finds the block full, so it copies 1 item into a new block with room for 2. Adding item 3 finds that block full, so it copies 2 items into a new block with room for 4.
- Continue the pattern. Adding item 5 finds the room of 4 full, so it copies 4 items into room for 8. Adding item 9 finds the room of 8 full, so it copies 8 items into room for 16. Items 10 and beyond fit in that block, so no more copies happen while we add 10 items.
- Write the copies as a series. The copies are 1, 2, 4 and 8. Each one is the one before times 2, so this is a geometric series with ratio . It has 4 terms, so the formula’s is 4 here.
- Add the terms. Adding the copies gives copies in total. This matches the pattern, because each term doubles the one before.
- Apply the formula. With and , the formula gives . The two minus signs cancel, so the answer is 15 copies. Both methods agree.
- Compare with the list size. The list holds 10 items, so twice the list size is . Since 15 is less than 20, the total copying is less than twice the number of items. On average that is copies per item.
Answer: Inserting 10 items causes 15 copies in total, which is less than . In general, doubling keeps the total copying below twice the number of items, so each item costs about 2 copies or fewer on average.
The numbers in this example are recomputed by script every time the site is built.
Common mistakes
- Using the formula with . The denominator becomes zero, and division by zero is not allowed. When , every term is 1, so the sum is .
- Miscounting the terms. The sum from to has terms. The sum from to also has terms, but it is different: it equals , because every term is one step along.
- Flipping the sign. The correct form is , not , which is the negative of the sum.
- Mixing up and . The ratio says how much each term multiplies, and says how many terms there are. Swapping them gives a different sum.
Where you will meet it
- Dynamic arrays that double in size, where the total copying stays below twice the final size.
- Compound growth, such as an amount of money that is multiplied by the same factor each year.
- Discounted rewards in reinforcement learning, where a reward received steps later is multiplied by , so the total reward is a geometric series. The number is between 0 and 1.
- Full binary trees, which are trees where each node has two children. Level holds nodes, so the total node count is a geometric series.
Questions people ask
What happens when $r$ is greater than 1?
The formula still works. For and 10 terms it gives . That equals , and the last term, 512, is about half of the total.
Why does the sum settle when $r$ is between 0 and 1?
Each power shrinks toward 0 as grows. For example, , which is almost 0. The top of the formula then goes to 1, and the sum goes to . For , that limit is 2.
Why is $r = 1$ a special case?
The formula divides by , which is zero when . In that case each term is 1, so the sum is . For example, four terms of 1 add up to .
Related formulas
- Sum of the First n Integers: This formula gives the total of the numbers 1, 2, 3 and so on up to in one quick calculation, with no adding one number at a time.
- Big O Notation: Big O notation is a way to say that one function never grows faster than another, once the input is big enough.
- Binary Number Value: Binary uses only the digits 0 and 1, and this formula turns a row of those digits into the ordinary number they stand for.