Back
In print settings: Save as PDF, turn headers and footers off, turn background graphics on.

Geometry & Topology

Differential geometry, topology, and the shape of mathematical spaces.

Official Documentation

July 2026

Contents

Overview

  • Algebraic Topology
  • Differential Geometry
  • Measure Theory & Lebesgue Integration
  • Riemannian Geometry
  • General Topology

Overview

Section Detail

Algebraic Topology

Algebraic Topology

Algebraic topology uses tools from abstract algebra to study topological spaces. The goal is to find algebraic invariants that classify topological spaces up to homeomorphism or homotopy equivalence.

Euler Characteristic and Simplicial Complexes

A simplicial complex is a space built from “building blocks” called simplices (points, line segments, triangles, tetrahedra). The Euler Characteristic χ\chi is a topological invariant defined for a finite simplicial complex as: χ=VE+F\chi = V - E + F where V,E,FV, E, F are the numbers of vertices, edges, and faces respectively. More generally: χ=n=0(1)ncn\chi = \sum_{n=0}^{\infty} (-1)^n c_n where cnc_n is the number of nn-simplices.

python
1def calculate_euler(v, e, f):
2 return v - e + f
3 
4# Tetrahedron: 4 vertices, 6 edges, 4 faces
5print(f"Tetrahedron chi: {calculate_euler(4, 6, 4)}")
6 
7# Cube: 8 vertices, 12 edges, 6 faces
8print(f"Cube chi: {calculate_euler(8, 12, 6)}")
9 
10# Torus (triangulated): chi should be 0
11v, e, f = 9, 27, 18
12print(f"Torus chi: {calculate_euler(v, e, f)}")

Homology Groups

Homology is a way of associating a sequence of abelian groups Hn(X)H_n(X) to a topological space. Informally, Hn(X)H_n(X) represents the ” nn-dimensional holes” in XX.

  • H0(X)H_0(X) counts path-connected components.
  • H1(X)H_1(X) counts “loops” or 1D holes.
  • H2(X)H_2(X) counts “voids” or 2D holes.

What is the first Betti number (rank of H1) of a circle S1?

The Fundamental Group

The fundamental group π1(X,x0)\pi_1(X, x_0) consists of equivalence classes of loops based at x0x_0 under homotopy. For a circle S1S^1, π1(S1)Z\pi_1(S^1) \cong \mathbb{Z}, representing the number of times a loop winds around the circle.

python
1def winding_number(points):
2 """Simple discrete winding number calculation around origin."""
3 import numpy as np
4 angles = np.arctan2([p[1] for p in points], [p[0] for p in points])
5 diffs = np.diff(angles)
6 # Adjust for wrap-around
7 diffs[diffs > np.pi] -= 2*np.pi
8 diffs[diffs < -np.pi] += 2*np.pi
9 return round(np.sum(diffs) / (2*np.pi))
10 
11# A circle loop
12theta = np.linspace(0, 2*np.pi, 100)
13circle_loop = [(np.cos(t), np.sin(t)) for t in theta]
14print(f"Winding number (1 loop): {winding_number(circle_loop)}")
15 
16# A double loop
17double_loop = [(np.cos(2*t), np.sin(2*t)) for t in theta]
18print(f"Winding number (2 loops): {winding_number(double_loop)}")

If two spaces have different Euler characteristics, can they be homeomorphic?

Section Detail

Differential Geometry

Differential Geometry

Differential geometry uses the techniques of differential and integral calculus to study the geometry of curves and surfaces.

Geometry of Curves

A space curve is defined by a vector function r(t)\mathbf{r}(t). The key invariants are curvature (κ\kappa) and torsion (τ\tau).

python
1import numpy as np
2 
3def calculate_curvature(t_val, dr_dt, d2r_dt2):
4 v1 = dr_dt(t_val)
5 v2 = d2r_dt2(t_val)
6 cross_product = np.cross(v1, v2)
7 norm_v1 = np.linalg.norm(v1)
8 kappa = np.linalg.norm(cross_product) / (norm_v1**3)
9 return kappa
10 
11# Helix: r(t) = (cos t, sin t, t)
12dr_dt = lambda t: np.array([-np.sin(t), np.cos(t), 1])
13d2r_dt2 = lambda t: np.array([-np.cos(t), -np.sin(t), 0])
14 
15print(f"Curvature of Helix at t=0: {calculate_curvature(0, dr_dt, d2r_dt2):.3f}")
16print("Curvature is constant for a helix.")

Gaussian Curvature

For surfaces, Gaussian Curvature (KK) is the product of the two principal curvatures. It is an intrinsic property, meaning it can be determined by measuring distances along the surface without reference to the surrounding space.

If we bend a flat sheet of paper into a cylinder, does its Gaussian curvature change?

Gauss-Bonnet Theorem

The Gauss-Bonnet Theorem links the total curvature of a surface to its topology (Euler characteristic χ\chi): MKdA+Mkgds=2πχ(M)\int_M K dA + \int_{\partial M} k_g ds = 2\pi \chi(M)

What is the Euler characteristic of a sphere?

python
1def euler_characteristic(v, e, f):
2 return v - e + f
3 
4# Cube: 8 vertices, 12 edges, 6 faces
5print(f"Cube χ: {euler_characteristic(8, 12, 6)}")
6# Tetrahedron: 4 vertices, 6 edges, 4 faces
7print(f"Tetrahedron χ: {euler_characteristic(4, 6, 4)}")
Section Detail

Measure Theory & Lebesgue Integration

Measure Theory & Lebesgue Integration

The Riemann integral, while foundational for introductory calculus, fails for functions that are “too discontinuous.” Measure theory provides a more robust framework by partitioning the range of a function rather than its domain.

1. The Failure of Riemann Integration

Consider the Dirichlet function, which is 11 for rationals and 00 for irrationals: 1Q(x)={1xQ0xQ\mathbf{1}_{\mathbb{Q}}(x) = \begin{cases} 1 & x \in \mathbb{Q} \\ 0 & x \notin \mathbb{Q} \end{cases}

In Riemann integration, any sub-interval contains both a rational and an irrational number. Thus, the lower rectangles always have height 00 and the upper rectangles height 11. They never meet.

The Lebesgue approach asks: “How ‘big’ is the set of rationals vs the set of irrationals?“. Since the rationals are countable, they have measure zero. The integral is effectively 0(size of irrationals)+1(size of rationals)=00 \cdot (\text{size of irrationals}) + 1 \cdot (\text{size of rationals}) = 0.

2. Measurable Spaces and σ\sigma-Algebras

To measure a set, we must first decide which sets are “legal” to measure.

Definition: σ\sigma-Algebra

A collection F\mathcal{F} of subsets of XX is a σ\sigma-algebra if:

  1. XFX \in \mathcal{F}
  2. AF    AcFA \in \mathcal{F} \implies A^c \in \mathcal{F} (Closed under complements)
  3. AnF    n=1AnFA_n \in \mathcal{F} \implies \bigcup_{n=1}^\infty A_n \in \mathcal{F} (Closed under countable unions)

Definition: Measure

A measure μ\mu is a function μ:F[0,]\mu: \mathcal{F} \to [0, \infty] such that:

  1. μ()=0\mu(\emptyset) = 0
  2. Countable Additivity: For disjoint sets AiA_i, μ(i=1Ai)=i=1μ(Ai)\mu(\bigcup_{i=1}^\infty A_i) = \sum_{i=1}^\infty \mu(A_i).

3. Measurable Functions

A function f:XRf: X \to \mathbb{R} is measurable if for every Borel set BB(R)B \in \mathcal{B}(\mathbb{R}), the preimage f1(B)f^{-1}(B) is in F\mathcal{F}. Equivalently: {xX:f(x)>a}FaR\{x \in X : f(x) > a \} \in \mathcal{F} \quad \forall a \in \mathbb{R}

python
1import numpy as np
2import matplotlib.pyplot as plt
3 
4# A "discontinuous" function: 1 if sin(x) > 0, else 0
5x = np.linspace(0, 10, 1000)
6y = (np.sin(x) > 0).astype(float)
7 
8# In Lebesgue terms, we are measuring the set {x : f(x) = 1}
9# This set is a collection of intervals [0, pi], [2pi, 3pi], etc.
10# These intervals are easy to measure!
11 
12plt.figure(figsize=(10, 4))
13plt.plot(x, y, label="f(x)")
14plt.fill_between(x, y, alpha=0.3)
15plt.title("Step Function (Easily Lebesgue Integrable)")
16plt.legend()
17plt.show()
18 

4. The Lebesgue Integral Construction

The Lebesgue integral is built in three stages:

  1. Simple Function: s(x)=i=1nai1Ei(x)s(x) = \sum_{i=1}^n a_i \mathbf{1}_{E_i}(x), where EiE_i are measurable disjoint sets.
  2. Integral of Simple Function: Xsdμ=i=1naiμ(Ei)\int_X s \, d\mu = \sum_{i=1}^n a_i \mu(E_i).
  3. General Integrable Function: For a non-negative measurable function ff: Xfdμ=sup{Xsdμ:0sf,s is simple}\int_X f \, d\mu = \sup \left\{ \int_X s \, d\mu : 0 \le s \le f, s \text{ is simple} \right\}

For general ff, we split it into f+=max(f,0)f^+ = \max(f, 0) and f=max(f,0)f^- = \max(-f, 0) and compute f+dμfdμ\int f^+ d\mu - \int f^- d\mu.

If we integrate a function that is 5 on a set with measure 2, and 0 everywhere else, what is the Lebesgue integral?

5. Almost Everywhere (a.e.)

In measure theory, we don’t care about what happens on “tiny” sets of measure zero. We say a property holds almost everywhere if the set of points where it fails has measure zero.

Example: If f(x)=g(x)f(x) = g(x) for all xx except at x=0x=0, their Lebesgue integrals are identical. This is why we can integrate functions with “holes” or infinite spikes (as long as the spikes aren’t too “fat”).

6. Convergence Theorems

The true power of Lebesgue theory is how well it handles limits.

  • Monotone Convergence: If fnf_n grows towards ff, the integrals grow towards the integral of ff.
  • Dominated Convergence: If fnff_n \to f and all fnf_n stay under some “umbrella” function gg that is integrable, then the limit of the integrals is the integral of the limit.

Can we Lebesgue-integrate a function that is 1 at every rational number in [0,1] and 0 at every irrational number?

Section Detail

Riemannian Geometry

Riemannian Geometry

Riemannian geometry is the branch of differential geometry that studies Riemannian manifolds—manifolds equipped with a metric tensor.

The Metric Tensor

A Riemannian metric gg is a collection of inner products on the tangent spaces of a manifold. In coordinates, it is represented by a symmetric matrix gijg_{ij}.

python
1import numpy as np
2 
3def calculate_length_on_manifold(g, path, dt):
4 # Length L = integral sqrt(g_ij * dx^i/dt * dx^j/dt) dt
5 length = 0
6 for i in range(len(path) - 1):
7 v = (path[i+1] - path[i]) / dt
8 # Simplified: assumes g is constant locally
9 speed = np.sqrt(v.T @ g @ v)
10 length += speed * dt
11 return length
12 
13# Polar metric: g = diag(1, r^2)
14def polar_metric(r):
15 return np.array([[1, 0], [0, r**2]])
16 
17# Circle path at r=1: (1, t) for t in [0, 2*pi]
18dt = 0.01
19t = np.arange(0, 2 * np.pi, dt)
20path = np.column_stack((np.ones_like(t), t))
21 
22g = polar_metric(1.0)
23print(f"Circumference (r=1): {calculate_length_on_manifold(g, path, dt):.3f}")

Geodesics

Geodesics are the “straightest possible” paths on a manifold. They generalize the notion of a line to curved spaces. In GR, particles move along geodesics in spacetime.

What is the shortest path between two points on a sphere?

Curvature Tensors

Curvature in Riemannian geometry is captured by the Riemann Curvature Tensor RijklR^l_{ijk}. It measures the extent to which parallel transport depends on the path taken.

In General Relativity, what physical quantity determines the metric tensor of spacetime?

python
1def christoffel_symbol_approx(g_inv, dg_dx):
2 # Very simplified version of Gamma calculations
3 pass
4 
5print("Riemannian manifolds are the foundation of modern gravitation theory.")
Section Detail

General Topology

General Topology

Topology is the study of properties that are preserved under continuous deformations, such as stretching and bending, but not tearing or gluing.

Metric Spaces

A metric space (X,d)(X, d) is a set XX with a distance function d:X×XRd: X \times X \to \mathbb{R} satisfying:

  1. Positivity: d(x,y)0d(x, y) \ge 0, and d(x,y)=0    x=yd(x, y) = 0 \iff x = y.
  2. Symmetry: d(x,y)=d(y,x)d(x, y) = d(y, x).
  3. Triangle Inequality: d(x,z)d(x,y)+d(y,z)d(x, z) \le d(x, y) + d(y, z).
python
1def check_metric_axioms(X, d):
2 for x in X:
3 for y in X:
4 # Positivity
5 if d(x, y) < 0: return False, "Negative distance"
6 if x != y and d(x, y) == 0: return False, "Zero distance for distinct points"
7 # Symmetry
8 if d(x, y) != d(y, x): return False, "Symmetry failed"
9 for z in X:
10 # Triangle Inequality
11 if d(x, z) > d(x, y) + d(y, z) + 1e-9:
12 return False, f"Triangle inequality failed for {x}, {y}, {z}"
13 return True, "Valid Metric"
14 
15# Manhattan Distance
16def taxicab(p1, p2):
17 return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])
18 
19points = [(0,0), (1,1), (2,3), (10, 0)]
20print(f"Taxicab metric: {check_metric_axioms(points, taxicab)}")
21 
22# Discrete Metric
23def discrete(p1, p2):
24 return 0 if p1 == p2 else 1
25 
26print(f"Discrete metric: {check_metric_axioms(points, discrete)}")

Topological Spaces

A topological space (X,τ)(X, \tau) is a set XX with a collection of subsets τ\tau (the open sets) such that:

  1. τ\emptyset \in \tau and XτX \in \tau.
  2. Arbitrary unions of sets in τ\tau are in τ\tau.
  3. Finite intersections of sets in τ\tau are in τ\tau.
python
1def is_topology(X, tau):
2 X_set = set(X)
3 tau_sets = [set(s) for s in tau]
4
5 # Empty set and X
6 if set() not in tau_sets or X_set not in tau_sets:
7 return False, "Missing empty set or X"
8
9 # Finite Intersections
10 import itertools
11 for s1, s2 in itertools.combinations(tau_sets, 2):
12 if s1.intersection(s2) not in tau_sets:
13 return False, f"Intersection of {s1} and {s2} not in tau"
14
15 # Binary Unions (covers arbitrary unions for finite sets)
16 for s1, s2 in itertools.combinations(tau_sets, 2):
17 if s1.union(s2) not in tau_sets:
18 return False, f"Union of {s1} and {s2} not in tau"
19
20 return True, "Valid Topology"
21 
22X = [1, 2, 3]
23indiscrete = [[], [1, 2, 3]]
24print(f"Indiscrete Topology: {is_topology(X, indiscrete)}")
25 
26overlap = [[], [1], [2], [1, 2, 3]]
27print(f"Partial Overlap: {is_topology(X, overlap)}")

Continuity

A function f:XYf: X \to Y is continuous if the preimage of every open set in YY is open in XX.

  • Formally: ff is continuous if VτY,f1(V)τX\forall V \in \tau_Y, f^{-1}(V) \in \tau_X.

In a Metric Space, this is equivalent to the ϵδ\epsilon-\delta definition: ff is continuous at x0x_0 if: ϵ>0,δ>0 such that dX(x,x0)<δ    dY(f(x),f(x0))<ϵ\forall \epsilon > 0, \exists \delta > 0 \text{ such that } d_X(x, x_0) < \delta \implies d_Y(f(x), f(x_0)) < \epsilon

In a discrete metric space, which sets are open?

Compactness and Connectedness

A space is compact if every open cover has a finite subcover. A space is connected if it cannot be partitioned into two disjoint non-empty open sets.

The Heine-Borel theorem states that subsets of R^n are compact if and only if they are: