TExcelTAD
Home › Calculus Essentials › Sequences

Sequences

A sequence is an ordered list of numbers that goes on forever: a1,a2,a3,…a_1, a_2, a_3, \ldots . Every iterative algorithm, from Newton's method to training a neural network, produces one, and the main question is always the same: does it settle down to a limit?

Two ways to define a sequence

Style Example Terms
Explicit formula an=1/na_n = 1/n 1,1/2,1/3,1/4,…1, 1/2, 1/3, 1/4, \ldots
Explicit formula an=(−1)na_n = (-1)^n −1,1,−1,1,…-1, 1, -1, 1, \ldots
Recursive (from the previous term) a1=1a_1 = 1, an+1=2an+1a_{n+1} = 2a_n + 1 1,3,7,15,…1, 3, 7, 15, \ldots
Recursive (two previous terms) F1=F2=1F_1 = F_2 = 1, Fn+1=Fn+Fn−1F_{n+1} = F_n + F_{n-1} 1,1,2,3,5,8,…1, 1, 2, 3, 5, 8, \ldots

An explicit formula lets you jump straight to the 1000th term. A recursive one is what loops compute naturally: each iteration uses the previous result.

Convergence

A sequence converges to a limit LL if its terms get and stay as close to LL as you like:

lim⁡n→∞an=Lmeans: for every ε>0 there is an N with ∣an−L∣<ε for all n>N\lim_{n \to \infty} a_n = L \qquad \text{means: for every } \varepsilon > 0 \text{ there is an } N \text{ with } \lvert a_n - L \rvert < \varepsilon \text{ for all } n > N

If no such LL exists, the sequence diverges: it may blow up (2n2^n), or oscillate ((−1)n(-1)^n).

Useful limits:

Sequence Limit
1/n1/n, 1/n21/n^2, 1/n1/\sqrt{n} 0
rnr^n with ∣r∣<1\lvert r \rvert < 1 0
rnr^n with r>1r > 1 ∞\infty (diverges)
(1+1/n)n(1 + 1/n)^n e≈2.71828e \approx 2.71828
n1/nn^{1/n} 1
Fn+1/FnF_{n+1} / F_n (Fibonacci ratios) φ=(1+5)/2≈1.61803\varphi = (1 + \sqrt{5})/2 \approx 1.61803

The limit laws from Limit Laws and Limits at Infinity apply: for example (3n2+1)/(n2−5)→3(3n^2 + 1)/(n^2 - 5) \to 3 because the top and bottom are both dominated by their n2n^2 terms.

python · try it yourself
import math

print(" n     (1+1/n)^n    F(n+2)/F(n+1)")
a, b = 1, 1
for n in range(1, 41):
    a, b = b, a + b                      # now b = F(n+2), a = F(n+1)
    if n in (1, 2, 5, 10, 20, 40):
        print(f"{n:2d}  {(1 + 1 / n) ** n:12.8f}  {b / a:14.10f}")
print(f"limits: e = {math.e:.8f}, phi = {(1 + 5 ** 0.5) / 2:.10f}")
 n     (1+1/n)^n    F(n+2)/F(n+1)
 1    2.00000000    2.0000000000
 2    2.25000000    1.5000000000
 5    2.48832000    1.6250000000
10    2.59374246    1.6179775281
20    2.65329771    1.6180339850
40    2.68506384    1.6180339887
limits: e = 2.71828183, phi = 1.6180339887

The Fibonacci ratios settle very fast, (1+1/n)n(1 + 1/n)^n very slowly: two convergent sequences can approach their limits at very different rates.

Monotone and bounded

A sequence is increasing if an+1≥ana_{n+1} \ge a_n, decreasing if an+1≤ana_{n+1} \le a_n, and bounded if all terms stay between two fixed numbers. The monotone convergence theorem says: a sequence that is monotone and bounded always converges. This is often the easiest way to prove a limit exists without knowing its value.

In software: iterate until it stops changing

Algorithms that improve an answer step by step produce sequences, and code must decide when to stop. The Babylonian square-root method is a recursive sequence:

x0=guess,xn+1=xn+S/xn2  →  Sx_0 = \text{guess}, \qquad x_{n+1} = \frac{x_n + S/x_n}{2} \;\to\; \sqrt{S}

It is Newton's method applied to x2−S=0x^2 - S = 0.

python · try it yourself
def babylonian_sqrt(S, tol=1e-12):
    x = S if S > 1 else 1.0
    n = 0
    while True:
        nxt = (x + S / x) / 2
        n += 1
        print(f"x{n} = {nxt:.15f}")
        if abs(nxt - x) < tol:          # stop when the sequence stops changing
            return nxt
        x = nxt

root = babylonian_sqrt(2)
print("math.sqrt(2) =", 2 ** 0.5)
x1 = 1.500000000000000
x2 = 1.416666666666667
x3 = 1.414215686274510
x4 = 1.414213562374690
x5 = 1.414213562373095
x6 = 1.414213562373095
math.sqrt(2) = 1.4142135623730951

The number of correct digits roughly doubles each step (quadratic convergence). Other places you meet sequences:

  • Gradient descent: the loss after each training step is a sequence; "converged" means it stopped decreasing meaningfully.
  • Exponential moving averages mn=β⋅mn−1+(1−β)⋅xnm_n = \beta \cdot m_{n-1} + (1 - \beta) \cdot x_n (Adam optimizer, smoothed FPS counters) are recursive sequences.
  • Pseudo-random generators are recursive sequences designed not to show a pattern.
  • Animations: pos += (target − pos) · 0.1 each frame is a sequence that converges to target geometrically.

Note: Stopping when two terms are close does not prove convergence: 1+1/2+…+1/n1 + 1/2 + \ldots + 1/n changes by less and less but grows forever (see Series and Convergence). In practice combine a tolerance with a maximum number of iterations.

Exercises

Exercise 1: Write the terms

List a1a_1 to a5a_5 for an=(2n−1)/(n+1)a_n = (2n - 1)/(n + 1) and give the limit.

Answer

1/2,1,5/4,7/5,3/21/2, 1, 5/4, 7/5, 3/2; limit 22.

Solution
n=1 ⁣:1/2,n=2 ⁣:3/3=1,n=3 ⁣:5/4,n=4 ⁣:7/5,n=5 ⁣:9/6=3/2divide top and bottom by n ⁣: (2−1/n)/(1+1/n)→2/1=2\begin{aligned} &n=1\colon 1/2, \quad n=2\colon 3/3 = 1, \quad n=3\colon 5/4, \quad n=4\colon 7/5, \quad n=5\colon 9/6 = 3/2 \\ &\text{divide top and bottom by } n\colon \ (2 - 1/n)/(1 + 1/n) \to 2/1 = 2 \end{aligned}

Exercise 2: Converge or diverge?

Decide for each: a) (0.9)n(0.9)^n, b) (−1)n/n(-1)^n/n, c) cos⁡(nπ)\cos(n\pi), d) n2/2nn^2/2^n.

Answer

a) converges to 0, b) converges to 0, c) diverges, d) converges to 0.

Solution
(a) ∣r∣<1→0(b) ∣an∣=1/n→0, so an→0 even though the sign flips(c) cos⁡(nπ)=(−1)n, oscillates between −1 and 1(d) exponentials beat powers: 2n grows much faster than n2\begin{aligned} &\text{(a) } \lvert r \rvert < 1 \to 0 \\ &\text{(b) } \lvert a_n \rvert = 1/n \to 0, \text{ so } a_n \to 0 \text{ even though the sign flips} \\ &\text{(c) } \cos(n\pi) = (-1)^n, \text{ oscillates between } -1 \text{ and } 1 \\ &\text{(d) exponentials beat powers: } 2^n \text{ grows much faster than } n^2 \end{aligned}

Exercise 3: Find the fixed point

The recursive sequence an+1=2+ana_{n+1} = \sqrt{2 + a_n}, a1=0a_1 = 0, converges. Find its limit by hand, then confirm numerically.

Answer

2

Solution

If an→La_n \to L, then also an+1→La_{n+1} \to L, so L=2+LL = \sqrt{2 + L}:

L2=2+L  ⇒  L2−L−2=0  ⇒  (L−2)(L+1)=0  ⇒  L=2(L≥0)L^2 = 2 + L \;\Rightarrow\; L^2 - L - 2 = 0 \;\Rightarrow\; (L - 2)(L + 1) = 0 \;\Rightarrow\; L = 2 \quad (L \ge 0)
python · try it yourself
import math

a = 0.0
for n in range(1, 21):
    a = math.sqrt(2 + a)
print(f"{a:.12f}")
1.999999999998

Exercise 4: Smoothing an animation

Each frame, a UI element moves 20% of the remaining distance to its target: pn+1=pn+0.2⋅(100−pn)p_{n+1} = p_n + 0.2 \cdot (100 - p_n), p0=0p_0 = 0. Find a formula for pnp_n and the first frame where it is within 0.5 px of 100.

Answer

pn=100(1−0.8n)p_n = 100(1 - 0.8^n); frame 2424.

Solution

The gap gn=100−png_n = 100 - p_n obeys gn+1=0.8⋅gng_{n+1} = 0.8 \cdot g_n, so gn=100⋅0.8ng_n = 100 \cdot 0.8^n. We need 100⋅0.8n<0.5100 \cdot 0.8^n < 0.5, i.e. n>ln⁡(0.005)/ln⁡(0.8)≈23.7n > \ln(0.005)/\ln(0.8) \approx 23.7.

python · try it yourself
p, n = 0.0, 0
while 100 - p >= 0.5:
    p += 0.2 * (100 - p)
    n += 1
print(n, round(p, 4))
24 99.5278

Test yourself

What is the limit of an=(5n+2)/(2n−1)a_n = (5n + 2)/(2n - 1)?

  1. 5/25/2
  2. 2
  3. 0
  4. It diverges

Which sequence diverges?

  1. 1/n1/n
  2. (1/2)n(1/2)^n
  3. (−1)n(-1)^n
  4. (1+1/n)n(1 + 1/n)^n

A sequence is increasing and every term is below 10. What can you conclude?

  1. It converges to 10
  2. It diverges
  3. Nothing
  4. It converges to some limit ≤10\le 10