A sequence is a list of numbers in order, made by a formula or by a rule that builds each term from the one before. Unroll the two simplest rules, add d and multiply by r, to reach any term in one line, and find a line and an exponential behind them.
Tell a formula for the n-th term of a sequence from a rule that builds each term from the one before.
Recognise arithmetic and geometric sequences by their differences and ratios, and name the common difference and the common ratio.
Derive the n-th term of an arithmetic and of a geometric sequence by unrolling its rule, and use the result to find any term.
Explain why the terms of an arithmetic sequence lie on a line and those of a geometric sequence on an exponential curve.
Produce the terms of a sequence in Python with a loop from the rule, with a function from the formula, and with numpy.arange.
In review. The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
The question
Gradient descent does not find a model’s weights in one jump. It starts from a guess and applies one fixed rule again and again, so the weights form a list: the guess, the weight after one step, after two steps, and so on. To know the thousandth entry of such a list, must you work out the 999 before it? For the two simplest rules, no. One line of algebra jumps straight there.
Intuition
A sequence is a list of numbers in a fixed order. Each number in it is a term, and its place in the list is its position: first, second, third, and so on. Order matters: 1, 2, 3 and 3, 2, 1 hold the same numbers but are different sequences.
There are two ways to say which numbers are in the list. A formula gives the term at any position directly, such as “the term at position \(n\) is three times \(n\), minus one”. A rule gives the first term and says how to make each term from the one before, such as “start at 2 and add 3 each time”. Both describe the same list, 2, 5, 8, 11, and so on.
The two simplest rules are “add the same amount each time” and “multiply by the same amount each time”. Plot each term above its position and they draw two shapes you already know.
M01.7.1-F1
The same idea twice. Left: each step adds 3, so every riser has the same height and the dots lie on a straight line. Right: each step doubles, so every riser is twice the last and the dots lie on an exponential curve. The sequence is the dots alone; the dashed lines only show the shape.
Three things in the picture are the whole lesson:
Adding the same amount gives a straight line. Each step goes one position across and 3 up, a constant slope.
Multiplying by the same amount gives an exponential curve. Each step doubles the height, so the climbs keep getting bigger.
Only whole-number positions count. There is a first term and a second, but no term at position 2.5. The dashed line and curve join the dots to show their shape.
Build it up
Step 1. Names for the terms. Write \(a_1\) for the first term, \(a_2\) for the second and \(a_n\) for the term at position \(n\). Read \(a_n\) as “a sub n”. The small \(n\) is a label on a list (M01.1.4), not a power. For 2, 5, 8, 11, we have \({a_1 = 2}\), \({a_2 = 5}\) and \({a_4 = 11}\). Positions count from 1.
Step 2. A formula. The formula \({a_n = 3n - 1}\) computes the term at any position straight away: put \({n = 4}\) and get \({3 \times 4 - 1 = 11}\). Nothing before it needs working out. A sequence given like this is a function (M01.3.1) whose inputs are the positions 1, 2, 3, and so on.
Step 3. A rule. The same list can be given by a first term and a rule:
\[
a_1 = 2, \qquad a_{n+1} = a_n + 3 .
\]
Read the rule as “the next term is this term plus 3”. To reach \(a_4\) you must walk: \({a_2 = 5}\), then \({a_3 = 8}\), then \({a_4 = 11}\). A rule that makes each term from the one before is called recursive. Without a first term it describes nothing.
Step 4. The two simplest rules. If the rule adds the same number \(d\) every time, the sequence is arithmetic and \(d\) is its common difference. If the rule multiplies by the same number \(r\) every time, the sequence is geometric and \(r\) is its common ratio. So 2, 5, 8, 11 is arithmetic with \({d = 3}\), and 1, 2, 4, 8 is geometric with \({r = 2}\). Both can go down: 20, 17, 14 has \({d = -3}\), and 8, 4, 2, 1 has \({r = 0.5}\).
Step 5. Unrolling a rule. To jump to position \(n\) without walking, write the first few terms using only \(a_1\) and the step, and look for the pattern.
M01.7.1-F2
Unrolling the two rules. Each arrow adds one more \(d\), or multiplies in one more \(r\). The term at position \(n\) has had \({n - 1}\) steps, so it holds \({n - 1}\) copies of \(d\), or \({n - 1}\) factors of \(r\).
Position 1 has had no steps, position 2 one step, position 3 two. The first term is where you start, not a step, so position \(n\) has had one step fewer than its number: \({n - 1}\).
The formal statement
NoteDefinition: sequence, arithmetic and geometric
A sequence is a list of numbers \({a_1, a_2, a_3, \dots}\) in order, one for each position \({n = 1, 2, 3, \dots}\). It may stop after some number of terms or go on for ever.
It is arithmetic, with common difference \(\cparam{d}\), if \({a_{n+1} = a_n + \cparam{d}}\) for every \(n\).
It is geometric, with common ratio \(\cparam{r}\), if \({a_{n+1} = \cparam{r}\, a_n}\) for every \(n\).
The position goes in, the term comes out, and the step shapes the rule.
Derivation, arithmetic. Unroll the rule one step at a time. Each line uses the line before.
\[
\begin{aligned}
a_2 &= a_1 + d \\
a_3 &= a_2 + d \\
&= (a_1 + d) + d = a_1 + 2d \\
a_4 &= a_3 + d \\
&= (a_1 + 2d) + d = a_1 + 3d
\end{aligned}
\]
Every step adds one more \(d\). Position \(n\) is reached from \(a_1\) in \({n - 1}\) steps, so it carries \({n - 1}\) copies of \(d\), and \({a_n = a_1 + (n - 1)d}\). Check at \({n = 1}\): the formula gives \({a_1 + 0 \times d}\), which is \(a_1\), as it must.
Derivation, geometric. The same unrolling, with “multiply by \(r\)” in place of “add \(d\)”:
After \({n - 1}\) steps there are \({n - 1}\) factors of \(r\), and \({n - 1}\) factors of \(r\) multiplied together is \({r^{\,n-1}}\) (M01.1.2). So \({a_n = a_1 r^{\,n-1}}\). Check at \({n = 1}\): \({r^0 = 1}\) (M01.4.1), so the formula gives \(a_1\).
Go deeper: why seeing the pattern is a proof: induction
Three unrolled steps show a pattern. They do not show that it still holds at step 1,000. Induction (M01.6.4) closes the gap. The claim is that \({a_n = a_1 + (n - 1)d}\) for every \(n\).
First case. At \({n = 1}\) the claim says \({a_1 = a_1 + 0 \times d}\), which is true.
Step. Suppose the claim holds at some position \(k\), so that \({a_k = a_1 + (k - 1)d}\). The rule gives the next term:
That is the claim at position \({k + 1}\). So it holds at 1, hence at 2, hence at 3, and on along every position. The geometric case is the same argument with \({a_{k+1} = r\,a_k}\).
A line sampled at whole numbers. Multiply out the arithmetic formula and collect the terms:
This is the line \({y = mx + b}\) of M01.3.2 with slope \(d\) and intercept \({a_1 - d}\), looked at only at \({x = 1, 2, 3, \dots}\). For 2, 5, 8, the slope is 3 and the intercept is \({2 - 3 = -1}\), so \({a_n = 3n - 1}\): the dashed line of the first figure. The intercept is the term one step before the first.
An exponential sampled at whole numbers. In the same way, for a positive ratio \(r\) other than 1,
which is the exponential of M01.4.2, a starting value times a base raised to the power \(x\), with base \(r\) and starting value \({a_1 / r}\). For the doubling sequence that is \({\tfrac12 \times 2^{\,n}}\), a curve through \((0, \tfrac12)\): once more, the term one step before the first.
Telling the two apart. Subtract each term from the next. If the differences are all equal, the sequence is arithmetic and the difference is \(d\). Divide each term by the one before. If the ratios are all equal, it is geometric and the ratio is \(r\). The squares 1, 4, 9, 16 have differences 3, 5, 7 and ratios 4, 2.25 and \({16/9 \approx 1.7778}\), so they are neither.
Worked example
The doubling sequence 1, 2, 4, 8, and so on. The first term is \({a_1 = 1}\) and each term is twice the one before, so the sequence is geometric with \({r = 2}\).
Its formula. Put \({a_1 = 1}\) and \({r = 2}\) into the result:
\[
a_n = 1 \times 2^{\,n-1} = 2^{\,n-1} .
\]
Which term is 1024? We need \({2^{\,n-1} = 1024}\). Ten 2s multiplied together make 1024 (M01.4.1), so \({1024 = 2^{10}}\), the exponent \({n - 1}\) is 10, and \({n = 11}\). The number 1024 is the eleventh term.
M01.7.1-F3
Two routes to the eleventh term. The rule walks down the green arrows, ten doublings. The formula jumps there in one step. In every row the exponent is one less than the position.
Check by the rule. Walking from \({a_1 = 1}\) takes ten doublings: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024. Ten steps, eleven terms.
Further out. The twentieth term is \({2^{19} = 524{,}288}\). The rule needs 19 doublings to get there; the formula needs one power.
An arithmetic one. The sequence 2, 5, 8, 11 has \({a_1 = 2}\) and \({d = 3}\). Its twentieth term is
First the rule, as a loop. Each pass takes the last term in the list and appends twice it.
# the first term, a_1 = 1terms = [1]# range(10) gives 0, 1, ..., 9for step inrange(10):# terms[-1]: the last term terms.append(terms[-1] *2)print(terms)print("number of terms:", len(terms))
[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]
number of terms: 11
Ten passes after the first term make eleven terms, as in the worked example. Next the formulas, as functions. Each one computes a term from its position, with no walking.
def geometric_term(a1, r, n):"""The n-th term: a1 times r to the power n - 1."""return a1 * r ** (n -1)def arithmetic_term(a1, d, n):"""The n-th term: a1 plus n - 1 steps of size d."""return a1 + (n -1) * dprint("a_11 of 1, 2, 4:", geometric_term(1, 2, 11))print("a_20 of 1, 2, 4:", geometric_term(1, 2, 20))print("a_20 of 2, 5, 8:", arithmetic_term(2, 3, 20))print("a_34 of 2, 5, 8:", arithmetic_term(2, 3, 34))
a_11 of 1, 2, 4: 1024
a_20 of 1, 2, 4: 524288
a_20 of 2, 5, 8: 59
a_34 of 2, 5, 8: 101
The rule and the formula must agree at every position. A loop can check all eleven.
agree =True# position n is index n - 1for n inrange(1, 12):if terms[n -1] != geometric_term(1, 2, n): agree =Falseprint("rule and formula agree:", agree)
rule and formula agree: True
Look at terms[n - 1]. Python counts the places in a list from 0, so the term at position \(n\) sits at index \({n - 1}\). Now the same terms with NumPy, as a preview of P02.
import numpy as np# 1 to 11: stops before 12positions = np.arange(1, 12)print(positions)# 2 to the powers 0 to 10print(2** np.arange(11))# 2 + (n - 1) * 3 at every nprint(2+ (positions -1) *3)
np.arange(1, 12) stops before 12, just as range does. Raising 2 to a whole array of exponents applies the formula to every position in one line.
A sequence from training. Gradient descent (ML01.5) makes weights by a rule. Here is one simple rule of that kind: each update moves the weight a fifth of the way towards the value 3. Training counts from 0, so \(w_0\) is the starting guess and \(w_t\) is the weight after \(t\) updates.
# w_0, the starting guessw =0.0print("update, weight, gap to 3")for t inrange(5):# a fifth of the way to 3 w = w -0.2* (w -3)print(t +1, round(w, 4), round(3- w, 4))
update, weight, gap to 3
1 0.6 2.4
2 1.08 1.92
3 1.464 1.536
4 1.7712 1.2288
5 2.017 0.983
The weights 0.6, 1.08, 1.464 are neither arithmetic nor geometric. But the gaps to 3, which are 2.4, 1.92 and 1.536, shrink by the same factor 0.8 each time: they form a geometric sequence. The third exercise shows why.
Explore
This module’s interactive, the sum builder, lives in lesson M01.7.3, where it adds the terms up. Its bars already show this lesson’s sequences: choose arithmetic and see equal steps, or choose geometric and see steps that grow, or shrink, by the same factor each time.
Pitfalls
M01.7.1-F4
Wrong beside right, for the fourth term of 2, 5, 8, 11. Four hops overshoot to the fifth term. Four terms have only three steps between them.
“The n-th term is the first term plus n steps.”
Counting positions instead of steps puts you one term too far. From the first term to the fourth there are three steps, not four, just as four fence posts have three gaps between them. So \({a_1 + 4d = 14}\) is the fifth term of 2, 5, 8, 11, and the fourth is \({a_1 + 3d = 11}\). Test any formula at \({n = 1}\): a correct one gives back \(a_1\).
“Counting from 0 or from 1 makes no difference.”
It changes the formula. Here the first term is \(a_1\), so the \(n\)-th term is \({n - 1}\) steps on. Training counts weights from \(w_0\), the value before any update, so a weight that changes by \(d\) at every update is \({w_0 + t\,d}\) after \(t\) updates, with no “minus one”. Python counts from 0 as well: terms[0] holds \(a_1\). Before using a formula, check where its counter starts.
“Every sequence is arithmetic or geometric.”
Most are neither. The squares 1, 4, 9, 16 have differences 3, 5, 7 and ratios 4, 2.25 and \({16/9 \approx 1.7778}\), and neither list is constant. Test the differences and the ratios before you use either formula.
“A geometric sequence always grows.”
Not always. With a positive first term it grows only when \(r\) is greater than 1. With \({r = 0.5}\) the terms halve: 8, 4, 2, 1, 0.5. With \({r = -2}\) they flip sign every time: 1, −2, 4, −8. A learning rate cut by the same factor every epoch (M01.4.2) is a geometric sequence that shrinks.
Check yourself
Recall
1. What is the difference between a formula for a sequence and a recursive rule for it?
Show answer
A formula gives the term at any position straight from \(n\), for example \({a_n = 3n - 1}\). A rule gives a first term and says how to make each term from the one before, for example \({a_1 = 2}\) and \({a_{n+1} = a_n + 3}\).
2. What is the 20th term of 2, 5, 8, 11, and so on?
Show answer
\({a_{20} = 2 + 19 \times 3 = 59}\).
3. Which term of the doubling sequence 1, 2, 4, 8 is 1024?
Show answer
The 11th. The terms are \({a_n = 2^{\,n-1}}\) and \({1024 = 2^{10}}\), so \({n - 1 = 10}\).
4. How do you tell an arithmetic sequence from a geometric one?
Show answer
In an arithmetic sequence the differences between neighbouring terms are all equal, and that difference is \(d\). In a geometric sequence the ratios are all equal, and that ratio is \(r\).
5. Why does the formula for the \(n\)-th term contain \({n - 1}\) and not \(n\)?
Show answer
The first term is where you start, not a step. The term at position \(n\) is reached after \({n - 1}\) steps.
Exercises
1.★ A geometric sequence has \({a_1 = 3}\) and \({r = 2}\). Write its first five terms and find its 10th term.
2.★★ An arithmetic sequence has \({a_3 = 11}\) and \({a_7 = 23}\). Find \(d\), \(a_1\) and \(a_{20}\).
Show solution
From position 3 to position 7 there are 4 steps, and the term rises by \({23 - 11 = 12}\), so \({d = 12 / 4 = 3}\). From \(a_3\) back to \(a_1\) is 2 steps, so \({a_1 = 11 - 2 \times 3 = 5}\). Then
\[
a_{20} = 5 + 19 \times 3 = 62 .
\]
3.★★★ A weight starts at \({w_0 = 0}\), and each update moves it a fifth of the way towards 3, by the rule \({w_{t+1} = w_t - 0.2\,(w_t - 3)}\). Show that the gap \({g_t = 3 - w_t}\) forms a geometric sequence, give its ratio, and find \(w_{10}\) to four decimal places.
Show solution
Write the next gap using the rule, then collect the copies of \({3 - w_t}\):
Each gap is 0.8 times the one before, so the gaps are geometric with ratio 0.8. The counter starts at 0 with \({g_0 = 3 - 0 = 3}\), so after \(t\) updates there have been \(t\) steps and \({g_t = 3 \times 0.8^{\,t}}\), with no “minus one”. Then
Geometric, multiply by \(r\).\({a_n = a_1\, r^{\,n-1}}\).
Steps, not positions. Position \(n\) is \({n - 1}\) steps after the first term.
Sources and next steps
Sources. Each was opened and checked against this lesson on 12 November 2026.
Jay Abramson and others, Algebra and Trigonometry, 2nd edition (OpenStax). Section 13.1 defines a sequence as a function whose domain is the positive integers and separates explicit formulas from recursive ones. Section 13.2 gives the explicit formula \({a_n = a_1 + d(n - 1)}\) and the recursive formula, and notes that the terms of an arithmetic sequence lie on a line whose slope is the common difference. Section 13.3 gives \({a_n = a_1 r^{\,n-1}}\) and calls a geometric sequence an exponential function whose domain is the positive integers, with the common ratio as its base.
NumPy reference, numpy.arange: the values it returns lie in the half-open interval from start up to, but not including, stop.
Next.M01.7.2 Sigma notation writes the total of a sequence as a single symbol and reads that symbol as a loop.