Euclid's first four axioms are uncontroversial. The fifth (the parallel postulate) is a choice. Replace it and you get different geometries: hyperbolic (many parallels through a point), spherical (no parallels). All three are consistent. The universe picked one, and it's not the flat one.
The parallel postulate
Euclid's fifth postulate: given a line and a point not on it, exactly one parallel line passes through the point. For two thousand years, mathematicians tried to prove it from the other four. They failed, because it's independent. You can negate it in two ways:
Hyperbolic: infinitely many parallels through the point
Spherical (elliptic): zero parallels through the point
Hyperbolic geometry
On a surface of constant negative curvature (like a saddle), triangles have angle sums less than 180 degrees. The defect (180 - angle sum) is proportional to area. In the Poincare disk model, the entire hyperbolic plane fits inside a circle, with distances growing exponentially near the boundary.
Scheme
; Hyperbolic distance in the Poincare disk model; d(p,q) = 2 * arctanh(|p-q| / |1 - p*conj(q)|); For points on the real axis:
(define (atanh x)
(* 0.5 (log (/ (+ 1 x) (- 1 x)))))
(define (hyperbolic-distance x1 x2)
; For points on the real line in the unit disk
(let ((num (abs (- x1 x2)))
(den (abs (- 1 (* x1 x2)))))
(* 2 (atanh (/ num den)))))
; Points near the center: short hyperbolic distance
(display "d(0, 0.1): ")
(display (hyperbolic-distance 00.1))
(newline)
; Points near the boundary: huge hyperbolic distance
(display "d(0, 0.9): ")
(display (hyperbolic-distance 00.9))
(newline)
(display "d(0, 0.99): ")
(display (hyperbolic-distance 00.99))
(newline)
; Triangle angle sum in hyperbolic geometry; For a triangle with area A and curvature K = -1:; angle_sum = pi - A
(define pi 3.141592653589793)
(define (hyp-angle-sum area)
(- pi area))
(display "Angle sum for area 0.5: ")
(display (* (/ (hyp-angle-sum 0.5) pi) 180))
(display " degrees")
Spherical geometry
On a sphere, "lines" are great circles (equators). Any two great circles intersect twice, so there are no parallel lines. Triangle angle sums exceed 180 degrees. The excess is proportional to area. This is the geometry of the Earth's surface and of general relativity.
Scheme
; Spherical geometry on a unit sphere; Great-circle distance from latitude/longitude
(define pi 3.141592653589793)
(define (deg->rad d) (* d (/ pi 180)))
; Haversine formula for great-circle distance
(define (haversine lat1 lon1 lat2 lon2)
(let ((dlat (deg->rad (- lat2 lat1)))
(dlon (deg->rad (- lon2 lon1)))
(rlat1 (deg->rad lat1))
(rlat2 (deg->rad lat2)))
(let ((a (+ (* (sin (/ dlat 2)) (sin (/ dlat 2)))
(* (cos rlat1) (cos rlat2)
(sin (/ dlon 2)) (sin (/ dlon 2))))))
(* 2 (asin (sqrt a))))))
; Distance in radians on unit sphere
(display "NYC to London (radians): ")
(display (haversine 40.7-74.051.5-0.1))
(newline)
; On Earth (R = 6371 km)
(display "NYC to London (km): ")
(display (* 6371 (haversine 40.7-74.051.5-0.1)))
(newline)
; Spherical triangle angle sum; For a triangle with area A on a unit sphere:; angle_sum = pi + A (spherical excess)
(define (sph-angle-sum area)
(+ pi area))
(display "Angle sum for area 1: ")
(display (* (/ (sph-angle-sum 1) pi) 180))
(display " degrees")
All three geometries are unified by one formula: the angle sum of a triangle equals pi plus the integral of curvature over the triangle's area. Flat: curvature 0, angles sum to pi. Spherical: positive curvature, angles sum to more. Hyperbolic: negative curvature, angles sum to less. This is the Gauss-Bonnet theorem, which connects local curvature to global topology. Differential geometry (Chapter 6) makes this precise.