Example

Take two limits in both orders and get two answers

xⁿ on [0, 1] and Abel's series: continuous terms, a convergent sum, and a limit that jumps.

The chapter’s smallest example is xⁿ on [0, 1]: taking the limit in n first and then x → 1 gives 0; the other order gives 1. This program shows the two orders, measures how slowly the convergence happens near x = 1, and sums Abel’s series near its jump.

Run it

Save this as limits.py and run it with Python 3.11 or later. It uses the standard library only.

"""Limits that do not commute: x^n on [0, 1], and Abel's series (standard library only)."""
import math

print("x^n: the two orders of limit")
print(f"  limit over n first, then x -> 1:  x^1000 at x = 0.999 is {0.999 ** 1000:.2e}, and -> 0 as n grows")
print(f"  limit over x first, then n:       x^n at x = 1 is {1.0 ** 1000} for every n")

print("\nPointwise, not uniform: the n needed for x^n < 1/2 at x = 1 - 1/k")
for k in (10, 100, 1000, 10000):
    x = 1 - 1 / k
    n = math.ceil(math.log(0.5) / math.log(x))
    print(f"  k = {k:>5}: n = {n:>5}   (k ln 2 = {k * math.log(2):8.1f})")
print("  sup over [0,1) of |x^n - 0| is 1 for every n: no single n serves every x.")


def abel(x, terms):
    """Partial sum of sum_{n>=1} (-1)^(n+1) sin(n x) / n, which converges to x/2 on (-pi, pi)."""
    return math.fsum((-1) ** (n + 1) * math.sin(n * x) / n for n in range(1, terms + 1))


print("\nAbel's series: each term continuous, the sum x/2 on (-pi, pi), but 0 at x = pi")
for x in (3.0, 3.1, 3.14, math.pi):
    print(f"  x = {x:.5f}: partial sum (100000 terms) {abel(x, 100000): .5f}   x/2 = {x / 2:.5f}")
print("  The limit jumps from pi/2 to 0 at x = pi: a convergent sum of continuous functions, discontinuous.")

Expected outcome

x^n: the two orders of limit
  limit over n first, then x -> 1:  x^1000 at x = 0.999 is 3.68e-01, and -> 0 as n grows
  limit over x first, then n:       x^n at x = 1 is 1.0 for every n

Pointwise, not uniform: the n needed for x^n < 1/2 at x = 1 - 1/k
  k =    10: n =     7   (k ln 2 =      6.9)
  k =   100: n =    69   (k ln 2 =     69.3)
  k =  1000: n =   693   (k ln 2 =    693.1)
  k = 10000: n =  6932   (k ln 2 =   6931.5)
  sup over [0,1) of |x^n - 0| is 1 for every n: no single n serves every x.

Abel's series: each term continuous, the sum x/2 on (-pi, pi), but 0 at x = pi
  x = 3.00000: partial sum (100000 terms)  1.50007   x/2 = 1.50000
  x = 3.10000: partial sum (100000 terms)  1.54976   x/2 = 1.55000
  x = 3.14000: partial sum (100000 terms)  1.57359   x/2 = 1.57000
  x = 3.14159: partial sum (100000 terms)  0.00000   x/2 = 1.57080
  The limit jumps from pi/2 to 0 at x = pi: a convergent sum of continuous functions, discontinuous.

Near x = 1 the n needed for xⁿ < 1/2 grows like k ln 2 at x = 1 − 1/k, without bound: the convergence is pointwise, not uniform, and that is exactly the hypothesis Cauchy’s theorem needs. Abel’s series sums to x/2 just below π and to 0 at π: every term is continuous and the series converges everywhere, yet the sum jumps.

Mechanism and limitations

Documented: Chapter 12 of the book sets out the mathematics; this program is a self-contained demonstration of it, not one of the laboratory’s recorded investigations.

Observed: the output above, produced by running the program exactly as shown.

Not shown:

  • Partial sums at finitely many points illustrate the limit; they do not prove convergence or its value. Part I, chapter 2 has Lean check the finite identity behind Abel’s series.
  • Floating-point sums of 100,000 terms carry rounding error; the jump is far larger than that error.

Related worked example: Chapter 3 , Chapter 9 .

Challenge this result

Copy this into the AI assistant of your choice, or work through it yourself. Check any finding against the recorded evidence.

Examine the claim that the pointwise limit of xⁿ on [0, 1] is discontinuous
while every xⁿ is continuous. Show that sup |xⁿ − f| = 1 for every n, explain
why that rules out uniform convergence, and say which hypothesis of Cauchy's
1821 theorem Abel's series violates. Then find another pair of limits whose
order matters.

Chapter: https://programmer.ie/books/math/12-chapter/
Example: https://programmer.ie/examples/math/12-chapter/
Program: https://github.com/ernanhughes/math/blob/main/notebooks/math/programs/12-limits.py
Distinguish what the record shows from what you infer. If you cannot open a link, ask me for the material; do not invent it.

Canonical source and the program .

Understand this example

Copy this prompt into your AI tool. No code runs here.

Apply this example

Copy this prompt into your AI tool. No code runs here.