A sequence converges when its terms settle on one value. Make that exact with a tolerance and a cut-off, prove that r to the n shrinks to 0 exactly when the size of r is below 1, and sum the geometric series behind gradient descent’s error and a discounted return.
State what it means for a sequence to converge, and find the step from which every term stays within a given tolerance.
Prove that r^n tends to 0 when |r| < 1, and that it has no limit when r = -1 or |r| > 1.
Define the sum of a series as the limit of its partial sums, and derive the sum a/(1 - r) of the geometric series for |r| < 1.
Write the error of gradient descent on the running loss as a geometric sequence, and its total travel and a discounted return as geometric series.
Compute terms, cut-offs and partial sums in Python, with a loop and with numpy.cumsum.
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 on the running loss, \({L(w) = 7.5w^2 - 23.5w + 18.5}\), with learning rate 0.1 from \({w = 0}\) jumps across the bottom at every step: \(w\) runs 0, 2.35, 1.175, 1.7625, 1.46875, and on. It never lands exactly on the lowest point, \({47/30 \approx 1.567}\), and it never stops moving. In what exact sense does the run get there? And how far does the weight travel in all?
Intuition
A sequence is a list of numbers in order (M01.7.1), here the weights \({w_0, w_1, w_2, \dots}\), one per step. Draw them against the step number, with a thin band around \({47/30}\).
M04.8.1-F1
Gradient descent with \({\eta = 0.1}\) on the running loss. Left: the weights jump from side to side of \({47/30}\), and from step 4 on every one of them lies inside the band \({47/30 \pm 0.1}\). Right: the running total of the jump lengths climbs and levels off at 4.7.
The left picture is what “the run gets there” means. Choose any band around \({47/30}\), as thin as you like. From some step on, every weight lies inside it and stays inside. A thinner band may mean a longer wait, but the wait is always finite. Landing on \({47/30}\) is never required.
The right picture answers the second question. Add the jumps one at a time and the running totals settle too, on 4.7. A sum of infinitely many terms means exactly this: the number that its running totals settle on.
Build it up
Step 1. Measure the distance to the bottom. Write \({e_t = w_t - 47/30}\) for the error at step \(t\). The running loss has slope \({L'(w) = 15w - 23.5}\), which is \({15\,(w - 47/30)}\), so one update is
The second line subtracts \({47/30}\) from both sides of the first. With \({\eta = 0.1}\) the multiplier is \({1 - 1.5 = -0.5}\): each step halves the distance and flips its side.
Step 2. Unroll it. Multiplying by the same number at every step gives a geometric sequence (M01.7.1): \({e_t = (-0.5)^t\, e_0}\) with \({e_0 = -47/30}\). Its size is \({(47/30) \times 0.5^t}\).
Step 3. Meet a tolerance. Ask for \({|e_t| < 0.1}\). The sizes are 0.196 at step 3 and 0.098 at step 4, and they only shrink after that, so the tolerance 0.1 is met from step 4 on. The tolerance 0.01 is met from step 8 on.
M04.8.1-F2
The distance to \({47/30}\) on a logarithmic scale. Halving at every step makes a straight line, so it crosses every tolerance line sooner or later and stays below it.
Step 4. Add the jumps. The jump at step \(t\) has length \({|e_{t+1} - e_t| = 1.5\,|e_t|}\), which is \({2.35 \times 0.5^t}\): 2.35, 1.175, 0.5875, and so on. The lengths form a geometric sequence too. The number their running totals settle on is the subject of the formal statement.
The formal statement
NoteDefinitions: the limit of a sequence, the sum of a series
A sequence \({a_1, a_2, a_3, \dots}\)converges to the number \(\ell\) if for every tolerance \({\varepsilon > 0}\) there is a whole number \(N\) with
\[
|a_n - \ell| < \varepsilon \;\text{ for every } n \ge N .
\]
Then \(\ell\) is its limit, written \({\lim_{n \to \infty} a_n = \ell}\) or \({a_n \to \ell}\). A sequence that converges to no number diverges.
The series\({\sum_{k=0}^{\infty} a_k}\) has the partial sums\({S_n = a_0 + \dots + a_{n-1}}\), the totals of its first \(n\) terms. It converges to \(S\), its sum, if \({S_n \to S}\). Otherwise it diverges.
This is the limit at infinity of M04.1.3, with whole numbers \(n\) in place of a real \(x\), so the limit laws hold unchanged. And if \({f(x) \to \ell}\) as \({x \to \infty}\), then \({f(n) \to \ell}\); for example \({1/n \to 0}\).
A convergent sequence is bounded. Take \({\varepsilon = 1}\). From some \(N\) on, every term lies within 1 of \(\ell\), so its size is below \({|\ell| + 1}\). Only finitely many terms come before \(N\), and the largest of their sizes is a number too. The larger of the two bounds every term.
NoteResult: powers and the geometric series
\({r^n \to 0}\) if \({|r| < 1}\), and \({r^n = 1}\) for every \(n\) if \({r = 1}\). If \({r = -1}\) or \({|r| > 1}\), the sequence \(r^n\) diverges.
For \({a \neq 0}\), the geometric series converges exactly when \({|r| < 1}\), and then
Proof that \({r^n \to 0}\) when \({|r| < 1}\). If \({r = 0}\), every term from \({n = 1}\) on is 0. Otherwise \({0 < |r| < 1}\), so \({\ln |r| < 0}\). A tolerance \({\varepsilon \ge 1}\) is met from \({n = 1}\) on, because \({|r|^n < 1}\). For \({0 < \varepsilon < 1}\), take logarithms, which keep the order of positive numbers (M01.4.3):
The last step divides by the negative number \({\ln |r|}\), which flips the inequality. So \(N\) can be any whole number above \({\ln \varepsilon / \ln |r|}\).
Proof that the other cases diverge. If \({|r| > 1}\), then \({\ln |r| > 0}\), and the same steps show that \({|r|^n > M}\) for every \({n > \ln M / \ln |r|}\). The terms pass every bound, so the sequence is unbounded and cannot converge. If \({r = -1}\), the terms alternate between \({-1}\) and 1. Two neighbours are 2 apart, so they cannot both lie within \({\tfrac12}\) of one number: the tolerance \({\tfrac12}\) is never met.
Proof of the sum. For \({r \neq 1}\), the finite sum of M01.7.3 gives the partial sums, which split into a fixed part and a part that changes with \(n\):
If \({|r| < 1}\), then \({r^n \to 0}\) and the limit laws give \({S_n \to a/(1 - r)}\). If \({r = 1}\), then \({S_n = na}\), which is unbounded. In the remaining cases, solving the display for \(r^n\) gives \({r^n = 1 - (1 - r)\,S_n/a}\); if \(S_n\) converged, so would \(r^n\), and it does not. The last term of the display is the gap left after \(n\) terms: the next term, \({a\,r^n}\), divided by \({1 - r}\).
Use 1: gradient descent. Step 1 found \({e_t = (1 - 15\eta)^t\, e_0}\). By the result, the error tends to 0 from every start exactly when \({|1 - 15\eta| < 1}\), that is when \({0 < \eta < 2/15 \approx 0.133}\). That is the learning-rate limit of ML01.5.3, now a fact about powers.
Use 2: a discounted return. In reinforcement learning (RL01.5), a reward of 1 at every step, each counted \(\gamma\) times the one before, has the return \({1 + \gamma + \gamma^2 + \cdots}\). With \({\gamma = 0.9}\) this is a geometric series with \({a = 1}\) and \({r = 0.9}\), so the return is \({1/(1 - 0.9) = 10}\). M01.7.3 saw the totals level off in a table; the result proves that they do.
Go deeper: a sequence has only one limit
Suppose \({a_n \to \ell}\) and \({a_n \to \ell'}\) with \({\ell \neq \ell'}\), and take \({\varepsilon = |\ell - \ell'|/2}\). From some step on, every term is within \(\varepsilon\) of \(\ell\), and from some step on, within \(\varepsilon\) of \(\ell'\). Beyond both steps a term \(a_n\) would give
which is impossible. So “the limit” is a fair name.
Worked example
Gradient descent on the running loss with \({\eta = 0.1}\) from \({w_0 = 0}\). From which step is \(w_t\) within 0.001 of the bottom, and how far does the weight travel in all?
The cut-off. The distance is \({|e_t| = (47/30) \times 0.5^t}\), and we need it below 0.001:
So from step 11 on. Check: at step 10 the distance is \({(47/30)/2^{10} \approx 0.00153}\), still too far, and at step 11 it is about 0.00076.
The total distance. The jumps have lengths \({2.35 \times 0.5^t}\) for \({t = 0, 1, 2, \dots}\): a geometric series with \({a = 2.35}\) and \({r = 0.5}\).
M04.8.1-F3
The jumps, one row each. Every jump is half the one before and crosses \({47/30}\), and the running totals on the right climb towards 4.7.
The net move is only \({47/30 \approx 1.567}\): by overshooting, the weight travels three times as far. After five jumps the total is 4.5531, and the gap is 0.1469, which is the next jump, 0.0734, divided by \({1 - 0.5}\).
Code
From scratch: the weights, the cut-off by a loop, and the running total.
w_star =47/30def descent(eta, w0, steps):"""Weights of gradient descent on the running loss, whose slope is 15 w - 23.5.""" w = [w0]for _ inrange(steps): w.append(w[-1] - eta * (15* w[-1] -23.5))return ww = descent(0.1, 0.0, 40)print("first weights:", [round(x, 5) for x in w[:5]])print("error ratios: ", [round((w[t +1] - w_star) / (w[t] - w_star), 9) for t inrange(5)])def first_step_within(eps, start=47/30, ratio=0.5):"""The first t with start * ratio**t < eps; the distances only shrink after it.""" t =0while start * ratio ** t >= eps: t +=1return tprint("cut-offs for 0.1, 0.01, 0.001:", [first_step_within(eps) for eps in (0.1, 0.01, 0.001)])total =0.0for t inrange(40): total +=abs(w[t +1] - w[t])print("distance travelled in 40 jumps:", round(total, 9))
first weights: [0.0, 2.35, 1.175, 1.7625, 1.46875]
error ratios: [-0.5, -0.5, -0.5, -0.5, -0.5]
cut-offs for 0.1, 0.01, 0.001: [4, 8, 11]
distance travelled in 40 jumps: 4.7
The library version: numpy.cumsum returns every partial sum at once, so a whole column of running totals can be checked against the formula \({a\,(1 - r^n)/(1 - r)}\) in one line. The same call adds up discounted rewards.
import numpy as npjumps = np.abs(np.diff(w)) # the 40 jump lengthstotals = np.cumsum(jumps) # S_1, S_2, ..., S_40n = np.arange(1, 41)formula =2.35* (1-0.5** n) / (1-0.5)print("S_1 to S_5:", totals[:5].round(4))print("largest gap to the formula:", np.abs(totals - formula).max())rewards =0.9** np.arange(200) # 1, 0.9, 0.81, ...: a reward of 1, discountedreturns = np.cumsum(rewards)print("return after 10, 50 and 200 steps:", returns[[9, 49, 199]].round(4))
S_1 to S_5: [2.35 3.525 4.1125 4.4063 4.5531]
largest gap to the formula: 8.881784197001252e-16
return after 10, 50 and 200 steps: [ 6.5132 9.9485 10. ]
Explore
This module’s interactive, the Taylor builder, lives in lesson 3. Two of its functions, \({1/(1 - x)}\) and \({\ln(1 + x)}\), are built from the geometric series of this lesson, and they show what happens to its partial sums outside \({|x| < 1}\).
Pitfalls
M04.8.1-F4
Wrong beside right. With learning rate 0.14 the error is multiplied by \({-1.1}\) at every step: a ratio below 1, yet the terms swing wider. With 0.12 the ratio is \({-0.8}\), whose size is below 1, and the terms settle on 0.
“r is less than 1, so r to the n shrinks to 0.”
The condition is on the size of \(r\): \({|r| < 1}\). With \({r = -1.1}\) the terms alternate in sign and grow, and with \({r = -1}\) they flip for ever. In gradient descent this is a learning rate that is too big: \({\eta = 0.14}\) gives \({1 - 15\eta = -1.1}\), and the run blows up.
“The run never reaches 47/30, so it does not converge.”
Convergence never asks a sequence to reach its limit, only to come within every tolerance and stay there. Reaching is not enough either: 0, 1, 0, 1, … reaches 0 again and again, yet stays near no single number, so it diverges.
“Each term is closer to the target than the last, so the target is the limit.”
The terms \({1 + 1/n}\) get closer to 0 at every step, yet they never come within 1 of it: their limit is 1. Getting closer is not the same as getting within every tolerance.
“The terms tend to 0, so the series adds up to 0.”
A sequence and its series are different objects. The discounted rewards \({0.9^k}\) tend to 0, but their sum is 10.
Check yourself
Recall
1. What does \({a_n \to \ell}\) mean?
Show answer
For every tolerance \({\varepsilon > 0}\) there is a whole number \(N\) with \({|a_n - \ell| < \varepsilon}\) for every \({n \ge N}\).
2. For which \(r\) does \(r^n\) converge, and to what?
Show answer
To 0 when \({|r| < 1}\), and to 1 when \({r = 1}\). For \({r = -1}\) and for \({|r| > 1}\) it diverges.
3. What is the sum of a series?
Show answer
The limit of its partial sums, the totals of its first \(n\) terms, when that limit exists.
4. What is the sum of the geometric series \({a + ar + ar^2 + \cdots}\), and when does it exist?
5. What is the error of gradient descent on the running loss after \(t\) steps, and which learning rates make it vanish?
Show answer
\({e_t = (1 - 15\eta)^t\, e_0}\), which tends to 0 exactly when \({0 < \eta < 2/15}\).
Exercises
1.★ Find the limit of \({a_n = 3 - 2/n}\), and a whole number \(N\) with \({|a_n - 3| < 0.01}\) for every \({n \ge N}\).
Show solution
\({|a_n - 3| = 2/n}\), and \({2/n < 0.01}\) exactly when \({n > 200}\). So \({N = 201}\) works, and since such an \(N\) exists for every tolerance (any whole number above \({2/\varepsilon}\)), the limit is 3.
2.★★ Find each sum, or show that the series diverges. (a) \({4 + 2 + 1 + 0.5 + \cdots}\) (b) \({\sum_{k=1}^{\infty} (2/3)^k}\) (c) \({1 - 1.1 + 1.21 - 1.331 + \cdots}\)
Show solution
(a) \({a = 4}\) and \({r = 0.5}\), so the sum is \({4/(1 - 0.5) = 8}\).
(b) The first term is \({2/3}\), since \(k\) starts at 1, and \({r = 2/3}\). The sum is \({(2/3)/(1 - 2/3) = 2}\).
(c) \({r = -1.1}\), so \({|r| > 1}\) and the series diverges: its terms do not even tend to 0.
3.★★★ For \({0 < \eta < 2/15}\), show that gradient descent on the running loss from \({w_0 = 0}\) travels a total distance of \({47/30}\) when \({\eta \le 1/15}\), and of \({\tfrac{47}{30} \cdot \tfrac{15\eta}{2 - 15\eta}}\) when \({1/15 < \eta < 2/15}\). What happens as \(\eta\) nears \({2/15}\)?
Show solution
Write \({m = 1 - 15\eta}\), so \({e_t = m^t e_0}\) with \({|e_0| = 47/30}\). Jump \(t\) has length
a geometric series in \(t\) with ratio \({|m| < 1}\). Its sum is \({15\eta\,(47/30)/(1 - |m|)}\). If \({\eta \le 1/15}\), then \({m \ge 0}\) and \({1 - |m| = 15\eta}\), so the total is \({47/30}\): the run never overshoots. If \({1/15 < \eta < 2/15}\), then \({m < 0}\) and \({1 - |m| = 2 - 15\eta}\), which gives the second formula; with \({\eta = 0.1}\) it is \({(47/30) \times 1.5/0.5 = 4.7}\). As \(\eta\) nears \({2/15}\), the bottom \({2 - 15\eta}\) shrinks to 0 and the total grows without bound.
Summary card
A sequence converges when its terms come within every tolerance and stay; a series converges when its partial sums do.
M04.8.1-F1
Settling, and adding up.
Limit. For every \({\varepsilon > 0}\) some \(N\) gives \({|a_n - \ell| < \varepsilon}\) for all \({n \ge N}\).
Powers.\({r^n \to 0}\) exactly when \({|r| < 1}\).
Geometric series.\({\sum_{k \ge 0} a\,r^k = a/(1 - r)}\) for \({|r| < 1}\); the gap after \(n\) terms is \({a\,r^n/(1 - r)}\).
In ML. Gradient descent’s error is \({(1 - 15\eta)^t\, e_0}\); a reward of 1 discounted by 0.9 returns 10.
Sources and next steps
Sources. Each was opened and checked against this lesson on 12 November 2026.
Gilbert Strang and Edwin Herman, Calculus Volume 2 (OpenStax), Section 5.1: the definition of a convergent sequence (for every \({\varepsilon > 0}\) an \(N\) with \({|a_n - L| < \varepsilon}\) for \({n \ge N}\)) and the behaviour of \(r^n\) in equations 5.1 to 5.4. Section 5.2: a series converges when its sequence of partial sums does, and the geometric series sums to \({a/(1 - r)}\) for \({|r| < 1}\) (equations 5.6 and 5.7).
Richard Sutton and Andrew Barto, Reinforcement Learning: An Introduction, 2nd edition, Section 3.3: the discounted return (3.8), finite for \({\gamma < 1}\) when the rewards are bounded, and equal to \({1/(1 - \gamma)}\) for a constant reward of +1 (3.10).