Skip to content
The Lumenary
Early undergraduateUndergraduate (first year) 115 min

Non-Euclidean geometry: spherical and hyperbolic

What if Euclid's fifth postulate fails? Triangles whose angles add up to more — or less — than 180°, and the discovery that these worlds are exactly as consistent as the flat one.

Formally verified · 13 LeanComputationally tested · 2 PythonAI-drafted · awaiting human reviewMathematically reviewed: Awaiting human review
MotivationH

The postulate that would not be proved

Euclid's Elements (c. 300 BCE) builds plane geometry from five postulates. The first four are short and obvious: a line can be drawn between any two points, extended indefinitely, a circle drawn with any centre and radius, and all right angles are equal. The fifth is long and different. In the equivalent form popularised by John Playfair (1795):

Parallel postulate. Through a point not on a given line there is exactly one line that does not meet it.

For two thousand years mathematicians tried to prove the fifth postulate from the other four — Ptolemy and Proclus in Alexandria, Ibn al-Haytham in Cairo, Omar Khayyam in Isfahan, Naṣīr al-Dīn al-Ṭūsī at Maragha, Giovanni Saccheri in Pavia, Johann Heinrich Lambert in Berlin. All of them failed, and many of their "proofs" quietly assumed something equivalent to what they were proving.

Meanwhile, navigators had been living in a non-Euclidean world all along. Fly from the North Pole straight down to the equator, turn left through 90∘90^\circ, fly a quarter of the way around the Earth, turn left through 90∘90^\circ again, and fly straight home: you have traced a triangle with three right angles. On a sphere the angles of a triangle add up to more than 180∘180^\circ — and the excess measures its area.

In the 1820s, Carl Friedrich Gauss, János Bolyai and Nikolai Lobachevsky independently took the bold step: suppose the postulate is false, with many parallels through a point, and see what follows. The result was not a contradiction but a new geometry, the hyperbolic plane, in which triangles have angle sums less than 180∘180^\circ. By the 1860s–1880s, Eugenio Beltrami, Felix Klein and Henri Poincaré had built concrete models of it — and with them proved that the parallel postulate can never be derived from the others. This lesson uses Euclidean geometry and its axioms, trigonometry, and vectors with the dot product; the cross product is recalled below.

IntuitionH

Three geometries, one picture

Drag the vertices of a triangle in each of the three geometries and watch its angle sum. In the plane it is always 180∘180^\circ. On the sphere it is larger, by an amount proportional to the area. In the hyperbolic plane (drawn in the Poincaré disc, where straight lines appear as circular arcs meeting the boundary at right angles) it is smaller, again by an amount proportional to the area.

Triangles on curved surfaces

Start with the triangle with three right angles: it covers exactly one eighth of the sphere.

90.0°90.0°90.0°ABC

Drag a corner to move it; drag anywhere else to turn the sphere. The sides are arcs of great circles — the shortest paths on a sphere.

  • ∠A90.0°
  • ∠B90.0°
  • ∠C90.0°

∠A + ∠B + ∠C = 270.0°

Angle excess (sum − 180°)
90.0° = 1.571 rad
Area, measured numerically
1.571 R²
Share of the whole sphere (area ÷ 4πR²)
12.50 %

∠A + ∠B + ∠C − π = Area / R²On a sphere of radius R, the excess in radians equals the area divided by R². The area is computed separately, by numerical integration, so the match is a check rather than an assumption.

∠A + ∠B + ∠C − π = K · Area

Flat planeK = 0∠A+∠B+∠C = 180°
SphereK = 1/R²∠A+∠B+∠C > 180°
Hyperbolic planeK = −1∠A+∠B+∠C < 180°

This is a first glimpse of the Gauss–Bonnet theorem: for a triangle whose sides are geodesics (shortest paths), the angle sum minus π equals the total curvature inside it. Here the curvature K is the same everywhere; on other surfaces you add up (integrate) K over the area.

The table under the widget records a single law for all three: angle sum − π=K⋅area-\, \pi = K \cdot \text{area}, where KK is the curvature: +1/R2+1/R^2 on a sphere of radius RR, 00 in the plane and −1-1 in the standard hyperbolic plane. Small triangles have small area, so in all three geometries tiny triangles look Euclidean — which is why the Earth looks flat to someone standing on it.

DefinitionsH

Definitions

Definition— great circle, spherical distance

On the sphere SR={x∈R3:∣x∣=R}S_R = \{x \in \R^3 : |x| = R\}, a great circle is the intersection of SRS_R with a plane through the centre OO. The distance between two points is the length of the shorter great-circle arc joining them: RR times the angle ∠AOB\angle AOB, so for unit vectors cos⁡d(A,B)=A⋅B\cos d(A, B) = A \cdot B. Great circles are the "straight lines" (geodesics) of the sphere: the shortest paths between points. Two points are antipodal if they are opposite ends of a diameter.

Definition— cross product

For u,v∈R3u, v \in \R^3, the cross product is u×v=(u2v3−u3v2, u3v1−u1v3, u1v2−u2v1)u \times v = (u_2 v_3 - u_3 v_2,\ u_3 v_1 - u_1 v_3,\ u_1 v_2 - u_2 v_1). It is perpendicular to both uu and vv, and its length is ∣u∣ ∣v∣sin⁡θ|u|\,|v| \sin\theta, where θ\theta is the angle between them. So for a great circle through AA and CC, the vector C×AC \times A is a normal to its plane.

Definition— spherical triangle, angle, lune

A spherical triangle ABCABC has as sides the great-circle arcs BCBC, CACA, ABAB (each shorter than a semicircle). Its angle at CC is the angle between the tangent lines of the two sides at CC — equivalently, the angle between the planes OCAOCA and OCBOCB, or between their normals C×AC \times A and C×BC \times B. A lune of angle α\alpha is the region between two half great circles from a point to its antipode, meeting at angle α\alpha.

Definition— upper half-plane model

The hyperbolic plane in the upper half-plane model is H={z=x+iy∈C:y>0}\mathbb H = \{z = x + iy \in \C : y > 0\} with lengths measured by ds=∣dz∣/yds = |dz|/y: a curve z(t)z(t), a≤t≤ba \le t \le b, has hyperbolic length ∫ab∣z′(t)∣/Im⁡z(t) dt\int_a^b |z'(t)| / \operatorname{Im} z(t)\, dt, and the distance d(z,w)d(z, w) is the infimum of the lengths of curves from zz to ww. Areas are measured by dx dy/y2dx\,dy/y^2. Angles are the usual Euclidean angles (the model is conformal).

Definition— hyperbolic lines, parallels

The lines (geodesics) of H\mathbb H are the vertical half-lines {Re⁡z=c}\{\operatorname{Re} z = c\} and the semicircles centred on the real axis. The real axis together with ∞\infty is the boundary at infinity: it is not part of H\mathbb H. Two lines that do not meet are parallel; they are limiting parallels if they meet at a point of the boundary and ultraparallel otherwise.

Definition— Poincaré disc model

The Poincaré disc is the open unit disc D={∣w∣<1}\mathbb D = \{|w| < 1\}, with lines the diameters and the circular arcs meeting the unit circle at right angles. It is the image of H\mathbb H under the Cayley transform w=(z−i)/(z+i)w = (z - i)/(z + i), which carries the half-plane model onto the disc model, lines to lines, preserving angles; the boundary circle is the boundary at infinity.

Definition— Möbius transformation, excess, defect

A Möbius transformation of H\mathbb H is a map z↦az+bcz+dz \mapsto \dfrac{az + b}{cz + d} with a,b,c,d∈Ra, b, c, d \in \R and ad−bc=1ad - bc = 1. The angle excess of a spherical triangle with angles α,β,γ\alpha, \beta, \gamma is α+β+γ−π\alpha + \beta + \gamma - \pi; the defect of a hyperbolic triangle is π−(α+β+γ)\pi - (\alpha + \beta + \gamma).

Worked examplesH

Examples

Example— Three right angles

The North Pole NN and the points (0∘,0∘)(0^\circ, 0^\circ) and (0∘,90∘E)(0^\circ, 90^\circ\mathrm{E}) on the equator form a spherical triangle with three right angles: angle sum 3π2\frac{3\pi}{2}, excess π2\frac{\pi}{2}. It is one of the eight congruent triangles into which the three coordinate planes cut the sphere, so its area is 18⋅4πR2=π2R2=R2⋅excess\frac18 \cdot 4\pi R^2 = \frac{\pi}{2} R^2 = R^2 \cdot \text{excess} — Girard's theorem in its simplest case.

Example— Great circles versus parallels of latitude

Madrid and New York both lie at about 40∘40^\circ N. The circle of latitude through them is not a great circle (its plane does not pass through the Earth's centre), so it is not the shortest route: the great-circle route bends north over the Atlantic, and long-distance flights follow such curving routes. The equator is the only circle of latitude that is a line of spherical geometry. Meridians are great circles, and any two of them meet at the poles: on the sphere there are no parallel lines at all.

Example— Distances in the half-plane

Along the imaginary axis, the curve z(t)=itz(t) = it from ii to iyiy (y>1y > 1) has length ∫1ydt/t=ln⁡y\int_1^y dt/t = \ln y. As y→∞y \to \infty or y→0y \to 0, the distance from ii grows without bound: the boundary is infinitely far away, even though it looks close in the picture. Horizontal distances shrink with height: the points ii and 1+i1 + i are at hyperbolic distance arcosh⁡32≈0.96\operatorname{arcosh}\frac32 \approx 0.96, but 100i100i and 1+100i1 + 100i are only about 0.010.01 apart.

PL
The Poincaré disc. Through the point P there are infinitely many hyperbolic lines (solid arcs) that never meet the horizontal line L. The two dashed arcs are the limiting parallels: they meet L only at the boundary circle, which is infinitely far away.
ProofH

Spherical geometry

Take R=1R = 1 (for radius RR, lengths scale by RR and areas by R2R^2). Let A,B,CA, B, C be unit vectors, with sides a=d(B,C)a = d(B, C), b=d(C,A)b = d(C, A), c=d(A,B)c = d(A, B) and angles α,β,γ\alpha, \beta, \gamma at A,B,CA, B, C.

Theorem— Theorem (spherical law of cosines)

cos⁡c=cos⁡acos⁡b+sin⁡asin⁡bcos⁡γ\cos c = \cos a \cos b + \sin a \sin b \cos \gamma.

Proof

The normals to the planes OCAOCA and OCBOCB are C×AC \times A and C×BC \times B, with lengths ∣C×A∣=sin⁡b|C \times A| = \sin b and ∣C×B∣=sin⁡a|C \times B| = \sin a, and γ\gamma is the angle between them, so (C×A)⋅(C×B)=sin⁡bsin⁡acos⁡γ(C \times A) \cdot (C \times B) = \sin b \sin a \cos\gamma. On the other hand, Lagrange's identity (u×v)⋅(w×x)=(u⋅w)(v⋅x)−(u⋅x)(v⋅w)(u \times v)\cdot(w \times x) = (u \cdot w)(v \cdot x) - (u \cdot x)(v \cdot w) with C⋅C=1C \cdot C = 1 gives

(C×A)⋅(C×B)=A⋅B−(A⋅C)(B⋅C)=cos⁡c−cos⁡bcos⁡a.(C \times A) \cdot (C \times B) = A \cdot B - (A \cdot C)(B \cdot C) = \cos c - \cos b \cos a .

Equating the two expressions gives the law.

∎

For small triangles, cos⁡x≈1−x2/2\cos x \approx 1 - x^2/2 and sin⁡x≈x\sin x \approx x; substituting and keeping terms of second order turns the spherical law into the Euclidean law of cosines c2=a2+b2−2abcos⁡γc^2 = a^2 + b^2 - 2ab\cos\gamma.

Theorem— Lemma (area of a lune)

A lune of angle α\alpha on the unit sphere has area 2α2\alpha.

Proof

Rotations about the axis through the lune's two vertices preserve area and carry lunes to lunes of the same angle, so the area of a lune depends only on its angle, say L(α)L(\alpha); it is additive (L(α+β)=L(α)+L(β)L(\alpha + \beta) = L(\alpha) + L(\beta), placing lunes side by side) and increasing. Since nn lunes of angle 2π/n2\pi/n tile the sphere, L(2π/n)=4π/nL(2\pi/n) = 4\pi/n, and by additivity L(2πm/n)=4πm/nL(2\pi m/n) = 4\pi m/n. An increasing function that agrees with α↦2α\alpha \mapsto 2\alpha on all rational multiples of 2π2\pi equals it everywhere.

∎

Theorem— Theorem (Girard, 1629)

A spherical triangle on a sphere of radius RR has area R2(α+β+γ−π)R^2(\alpha + \beta + \gamma - \pi).

Proof

Take R=1R = 1 and write A′,B′,C′A', B', C' for the antipodes of A,B,CA, B, C. The three great circles BCBC, CACA, ABAB cut the sphere into eight triangles: Δ=ABC\Delta = ABC, its antipodal image Δ′=A′B′C′\Delta' = A'B'C' (of the same area, since x↦−xx \mapsto -x is an isometry), and six others. The two great circles through AA bound a lune of angle α\alpha containing Δ\Delta; the great circle BCBC cuts it into Δ\Delta and the triangle A′BCA'BC. So

LA=Δ∪A′BC,LB=Δ∪AB′C,LC=Δ∪ABC′,L_A = \Delta \cup A'BC, \quad L_B = \Delta \cup AB'C, \quad L_C = \Delta \cup ABC',

and their antipodal lunes are LA′=Δ′∪AB′C′L_A' = \Delta' \cup AB'C', LB′=Δ′∪A′BC′L_B' = \Delta' \cup A'BC', LC′=Δ′∪A′B′CL_C' = \Delta' \cup A'B'C. Each of the six other triangles appears in exactly one of these six lunes, while Δ\Delta appears in three and Δ′\Delta' in three. Adding areas (boundaries have zero area), using the lemma:

2(2α+2β+2γ)=4π+2area⁡(Δ)+2area⁡(Δ′)=4π+4area⁡(Δ),2(2\alpha + 2\beta + 2\gamma) = 4\pi + 2\operatorname{area}(\Delta) + 2\operatorname{area}(\Delta') = 4\pi + 4 \operatorname{area}(\Delta),

so area⁡(Δ)=α+β+γ−π\operatorname{area}(\Delta) = \alpha + \beta + \gamma - \pi.

∎

Consequences. Every spherical triangle has angle sum greater than π\pi. Two triangles with the same angles have the same area — and in fact are congruent: on the sphere there are no similar triangles of different sizes, and so no scale models. There are no rectangles (a quadrilateral with four right angles would have angle sum 2π2\pi, so zero area). And any two great circles meet — their planes through OO share a line, which meets the sphere in two antipodal points — so there are no parallels.

Spherical geometry is not, however, Euclidean geometry with the fifth postulate replaced: two antipodal points lie on infinitely many great circles (every meridian joins the poles), so the first postulate's uniqueness fails too, and lines are closed curves of finite length. Identifying each point with its antipode gives elliptic geometry on the projective plane, in which two points determine exactly one line and any two lines meet in exactly one point.

ProofH

Hyperbolic geometry

Theorem— Proposition (vertical segments are shortest)

For 0<a<b0 < a < b, the hyperbolic distance from iaia to ibib is ln⁡(b/a)\ln(b/a), and the vertical segment is the only shortest curve.

Proof

For any curve z(t)=x(t)+iy(t)z(t) = x(t) + iy(t) from iaia to ibib,

∫x′2+y′2y dt  ≥  ∫∣y′∣y dt  ≥  ∫y′y dt=ln⁡b−ln⁡a,\int \frac{\sqrt{x'^2 + y'^2}}{y}\,dt \;\ge\; \int \frac{|y'|}{y}\,dt \;\ge\; \int \frac{y'}{y}\,dt = \ln b - \ln a,

with equality only if x′≡0x' \equiv 0 and y′≥0y' \ge 0: the curve runs straight up the imaginary axis. The vertical segment has length exactly ln⁡(b/a)\ln(b/a).

∎

Theorem— Theorem (Möbius transformations are isometries)

If g(z)=az+bcz+dg(z) = \frac{az + b}{cz + d} with a,b,c,da, b, c, d real and ad−bc=1ad - bc = 1, then gg maps H\mathbb H onto itself and preserves hyperbolic lengths, distances, angles and areas.

Proof

Multiplying numerator and denominator by cz+d‾\overline{cz + d},

Im⁡g(z)=Im⁡((az+b)(czˉ+d))∣cz+d∣2=(ad−bc)Im⁡z∣cz+d∣2=Im⁡z∣cz+d∣2,\operatorname{Im} g(z) = \frac{\operatorname{Im}\big((az + b)(c\bar z + d)\big)}{|cz + d|^2} = \frac{(ad - bc)\operatorname{Im} z}{|cz + d|^2} = \frac{\operatorname{Im} z}{|cz + d|^2},

so gg maps H\mathbb H to H\mathbb H; its inverse z↦dz−b−cz+az \mapsto \frac{dz - b}{-cz + a} is of the same form, so it is a bijection. Its derivative is g′(z)=1(cz+d)2g'(z) = \frac{1}{(cz + d)^2}, so

∣g′(z)∣ ∣dz∣Im⁡g(z)=∣dz∣/∣cz+d∣2Im⁡z/∣cz+d∣2=∣dz∣Im⁡z:\frac{|g'(z)|\,|dz|}{\operatorname{Im} g(z)} = \frac{|dz|/|cz + d|^2}{\operatorname{Im} z/|cz + d|^2} = \frac{|dz|}{\operatorname{Im} z}:

the length element is preserved, hence the length of every curve, hence distances. A holomorphic map with non-zero derivative preserves angles, and the area element dx dy/y2dx\,dy/y^2 transforms by ∣g′(z)∣2/(Im⁡g/Im⁡z)2=1|g'(z)|^2 / (\operatorname{Im} g / \operatorname{Im} z)^2 = 1.

∎

Möbius transformations map circles and lines of C\C to circles and lines and preserve angles, so they map hyperbolic lines to hyperbolic lines. They are plentiful: z↦z+tz \mapsto z + t (t∈Rt \in \R), z↦λzz \mapsto \lambda z (λ>0\lambda > 0) and z↦−1/zz \mapsto -1/z generate them all, and they can move any point to any point and any line to any line — in particular, any line to the imaginary axis. Together with the reflection z↦−zˉz \mapsto -\bar z, they form the whole isometry group of H\mathbb H. Combining this with the proposition: every hyperbolic line is the image of the imaginary axis, so the lines of H\mathbb H are exactly the vertical half-lines and semicircles centred on R\R, and any two points are joined by exactly one line.

Theorem— Theorem (distance formula)

For z,w∈Hz, w \in \mathbb H: cosh⁡d(z,w)=1+∣z−w∣22Im⁡zIm⁡w\displaystyle \cosh d(z, w) = 1 + \frac{|z - w|^2}{2 \operatorname{Im} z \operatorname{Im} w}.

Proof

Both sides are unchanged by Möbius transformations: the left because they are isometries, the right because, by the formulas above, ∣g(z)−g(w)∣2=∣z−w∣2∣cz+d∣2∣cw+d∣2|g(z) - g(w)|^2 = \frac{|z - w|^2}{|cz + d|^2 |cw + d|^2} and Im⁡g(z)Im⁡g(w)=Im⁡zIm⁡w∣cz+d∣2∣cw+d∣2\operatorname{Im} g(z) \operatorname{Im} g(w) = \frac{\operatorname{Im} z \operatorname{Im} w}{|cz + d|^2 |cw + d|^2}. So we may move zz and ww onto the imaginary axis: z=iaz = ia, w=ibw = ib with a<ba < b. Then the right side is 1+(b−a)22ab=a2+b22ab=12(ba+ab)=cosh⁡ln⁡ba1 + \frac{(b - a)^2}{2ab} = \frac{a^2 + b^2}{2ab} = \frac12\left(\frac ba + \frac ab\right) = \cosh \ln\frac ba, which is cosh⁡d(ia,ib)\cosh d(ia, ib) by the proposition.

∎

Theorem— Theorem (infinitely many parallels)

Through a point pp not on a hyperbolic line LL there pass infinitely many lines that do not meet LL.

Proof

Move LL to the imaginary axis by an isometry; reflecting in it by z↦−zˉz \mapsto -\bar z if necessary and then scaling by z↦z/Re⁡pz \mapsto z/\operatorname{Re} p, we may assume p=1+itp = 1 + it with t>0t > 0. For c∈Rc \in \R, the semicircle centred at cc through pp has radius rr with r2=(1−c)2+t2r^2 = (1 - c)^2 + t^2. It meets LL at a point iyiy (y>0y > 0) exactly when c2+y2=(1−c)2+t2c^2 + y^2 = (1 - c)^2 + t^2, i.e. y2=1+t2−2cy^2 = 1 + t^2 - 2c. So for every c≥1+t22c \ge \frac{1 + t^2}{2} there is no such yy: each of these infinitely many semicircles is a line through pp that misses LL. (The vertical line Re⁡z=1\operatorname{Re} z = 1 is another.)

∎

Exactly two of the lines through pp are limiting parallels (here c=1+t22c = \frac{1+t^2}{2}, meeting LL at the boundary point 00, and the vertical line, meeting it at ∞\infty); all lines between them are ultraparallel.

Theorem— Theorem (area of a hyperbolic triangle)

A hyperbolic triangle with angles α,β,γ\alpha, \beta, \gamma has area π−(α+β+γ)\pi - (\alpha + \beta + \gamma). In particular every triangle has angle sum less than π\pi and area less than π\pi.

Proof

Step 1: one vertex at infinity. Consider a "triangle" with one vertex at ∞\infty (where its two vertical sides meet, at angle 00) and two vertices on the unit circle at ei(π−α)e^{i(\pi - \alpha)} and eiβe^{i\beta}, where its angles are α\alpha and β\beta (the angle between a vertical line and the unit circle at eiθe^{i\theta} is θ\theta or π−θ\pi - \theta). Its area is

∫−cos⁡αcos⁡β∫1−x2∞dyy2 dx=∫−cos⁡αcos⁡βdx1−x2=arcsin⁡(cos⁡β)+arcsin⁡(cos⁡α)=π−α−β.\int_{-\cos\alpha}^{\cos\beta} \int_{\sqrt{1 - x^2}}^{\infty} \frac{dy}{y^2}\,dx = \int_{-\cos\alpha}^{\cos\beta} \frac{dx}{\sqrt{1 - x^2}} = \arcsin(\cos\beta) + \arcsin(\cos\alpha) = \pi - \alpha - \beta .

Any triangle with one vertex on the boundary can be moved to this position: send that vertex to ∞\infty, then use z↦λz+tz \mapsto \lambda z + t to make the opposite side the unit circle.

Step 2: the general triangle. Extend the side ABAB beyond BB until it reaches the boundary at an ideal point DD. Let δ\delta be the angle ∠BCD\angle BCD. The triangle ACDACD has angles α\alpha, γ+δ\gamma + \delta, 00, and the triangle BCDBCD has angles π−β\pi - \beta, δ\delta, 00; and ABC=ACD∖BCDABC = ACD \setminus BCD. By step 1,

area⁡(ABC)=(π−α−γ−δ)−(π−(π−β)−δ)=π−α−β−γ.\operatorname{area}(ABC) = \big(\pi - \alpha - \gamma - \delta\big) - \big(\pi - (\pi - \beta) - \delta\big) = \pi - \alpha - \beta - \gamma .

∎

Letting all three vertices run off to the boundary gives an ideal triangle, with all angles 00 and area exactly π\pi — the largest possible. As on the sphere, two triangles with the same angles have the same area, and in fact are congruent: hyperbolic geometry has no similar triangles of different sizes. One also has the hyperbolic law of cosines cosh⁡c=cosh⁡acosh⁡b−sinh⁡asinh⁡bcos⁡γ\cosh c = \cosh a \cosh b - \sinh a \sinh b \cos\gamma (proved, for example, in Anderson, ch. 5), which for small triangles again reduces to the Euclidean one.

ExplanationH

Why the parallel postulate is independent

To show that a statement PP cannot be proved from axioms Σ\Sigma, it is enough to find a model: a structure in which all of Σ\Sigma holds but PP fails. Any proof of PP from Σ\Sigma would be valid in every model, so it would prove something false in this one.

Make "Euclid's other axioms" precise as Hilbert's axioms (1899) for incidence, betweenness, congruence and continuity, without the parallel axiom — so-called neutral geometry. Interpret "point" as a point of H\mathbb H, "line" as a hyperbolic line, "between" and "congruent" via hyperbolic distance. One checks that every axiom of neutral geometry holds: two points lie on exactly one line (shown above); lines are infinitely long and separate the plane; there are enough isometries (the Möbius transformations and reflections) to move any segment or angle to any position, which gives the congruence axioms; and the continuity axioms hold because H\mathbb H is built from real numbers. (Full verifications are in Greenberg, ch. 7, and Hartshorne, ch. 7.) But the parallel postulate fails, by the theorem on infinitely many parallels.

Hence the parallel postulate is independent of the other axioms. More precisely, the argument is one of relative consistency: the model is constructed inside the real numbers — inside Euclidean geometry — so if Euclidean geometry is consistent, so is hyperbolic geometry. Neither geometry is "the true one" as a matter of logic; which one describes a given situation is a question about that situation. (See model theory for the general method, and first-order logic for what "proof" means here.)

Spherical geometry is not a model of neutral geometry: some of the other axioms fail there too (lines are finite and two antipodal points lie on many lines). Indeed, neutral geometry proves that the angle sum of a triangle is at most π\pi (the Saccheri–Legendre theorem), so only the hyperbolic alternative is compatible with Euclid's first four postulates and the continuity axioms.

Formal mathematicsF

Spheres and half-planes in Lean

For spherical geometry we use vectors in R3\R^3 (in Mathlib, Fin 3 → ℝ with the dot product ⬝ᵥ and the cross product ⨯₃). Lagrange's identity is checked coordinate by coordinate; the spherical law of cosines then follows exactly as in the human proof, with the angle γ\gamma at CC specified through the normals C×AC \times A and C×BC \times B:

lagrange_identityLean 4Proved here from basic factsFormally verified
/-- **Lagrange's identity** for the cross product in `ℝ³`:
`(u × v) · (w × x) = (u · w)(v · x) - (u · x)(v · w)`, checked coordinate by coordinate.
(Mathlib has it, for any commutative ring, as `cross_dot_cross`.) -/
theorem lagrange_identity (u v w x : Fin 3 → ℝ) :
    (u ⨯₃ v) ⬝ᵥ (w ⨯₃ x) = (u ⬝ᵥ w) * (v ⬝ᵥ x) - (u ⬝ᵥ x) * (v ⬝ᵥ w) := by
  simp only [cross_apply, dotProduct, Fin.sum_univ_three]
  simp
  ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor
normals_dotLean 4Proved here from basic factsFormally verified
/-- For points `A, B, C` on the unit sphere, the normals `C × A` and `C × B` to the great
circles `CA` and `CB` satisfy `(C × A) · (C × B) = A · B - (A · C)(B · C)`, i.e.
`cos c - cos a cos b` in terms of the sides of the spherical triangle. -/
theorem normals_dot (A B C : Fin 3 → ℝ) (hC : C ⬝ᵥ C = 1) :
    (C ⨯₃ A) ⬝ᵥ (C ⨯₃ B) = A ⬝ᵥ B - (A ⬝ᵥ C) * (B ⬝ᵥ C) := by
  rw [lagrange_identity, hC, one_mul, dotProduct_comm C B]
  ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor
normal_sqLean 4Proved here from basic factsFormally verified
/-- The normal `C × A` has squared length `1 - (A · C)²`, which is `sin² b` when the side `CA`
has length `b` (so `A · C = cos b`). -/
theorem normal_sq (A C : Fin 3 → ℝ) (hA : A ⬝ᵥ A = 1) (hC : C ⬝ᵥ C = 1) :
    (C ⨯₃ A) ⬝ᵥ (C ⨯₃ A) = 1 - (A ⬝ᵥ C) ^ 2 := by
  rw [normals_dot A A C hC, hA]
  ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor
spherical_law_of_cosinesLean 4Proved here from basic factsFormally verified
/-- **The spherical law of cosines.** Let `A, B, C` be on the unit sphere, with sides
`a = ∠BOC`, `b = ∠COA`, `c = ∠AOB` (so `cos a = B · C`, …), and let `γ` be the angle at `C`,
i.e. the angle between the normals `C × A` and `C × B`, whose lengths are `sin b` and `sin a`:
`(C × A) · (C × B) = sin b · sin a · cos γ`. Then `cos c = cos a cos b + sin a sin b cos γ`. -/
theorem spherical_law_of_cosines (A B C : Fin 3 → ℝ) (hC : C ⬝ᵥ C = 1) {a b c γ : ℝ}
    (ha : Real.cos a = B ⬝ᵥ C) (hb : Real.cos b = A ⬝ᵥ C) (hc : Real.cos c = A ⬝ᵥ B)
    (hγ : (C ⨯₃ A) ⬝ᵥ (C ⨯₃ B) = Real.sin b * Real.sin a * Real.cos γ) :
    Real.cos c = Real.cos a * Real.cos b + Real.sin a * Real.sin b * Real.cos γ := by
  have h := normals_dot A B C hC
  rw [hγ, ← ha, ← hb, ← hc] at h
  linarith
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor

That any two great circles meet is proved by linear algebra — rank–nullity gives a non-zero vector orthogonal to both normals — and then rescaling it onto the sphere:

great_circles_meetLean 4Proved here from basic factsFormally verified
/-- **There are no parallels on the sphere.** The great circle with normal `n` is the set of
unit vectors `v` with `v · n = 0`. Any two great circles meet: the linear map
`v ↦ (v · n, v · m)` from `ℝ³` to `ℝ²` has a non-zero kernel by rank–nullity, and a non-zero
kernel vector, rescaled to length `1`, lies on both circles (and so does its antipode). -/
theorem great_circles_meet (n m : Fin 3 → ℝ) :
    ∃ v : Fin 3 → ℝ, v ⬝ᵥ v = 1 ∧ v ⬝ᵥ n = 0 ∧ v ⬝ᵥ m = 0 := by
  -- The 2 × 3 matrix with rows `n` and `m`.
  set M : Matrix (Fin 2) (Fin 3) ℝ := Matrix.of ![n, m] with hM
  have hker : LinearMap.ker M.mulVecLin ≠ ⊥ :=
    LinearMap.ker_ne_bot_of_finrank_lt (by simp)
  obtain ⟨w, hw, hw0⟩ := Submodule.exists_mem_ne_zero_of_ne_bot hker
  have hMw : M *ᵥ w = 0 := by simpa using hw
  have hn : w ⬝ᵥ n = 0 := by
    have := congrFun hMw 0
    simpa [hM, Matrix.mulVec, dotProduct_comm] using this
  have hm : w ⬝ᵥ m = 0 := by
    have := congrFun hMw 1
    simpa [hM, Matrix.mulVec, dotProduct_comm] using this
  -- Rescale `w` to unit length.
  have hpos : 0 < w ⬝ᵥ w := by
    have hnn : 0 ≤ w ⬝ᵥ w := Finset.sum_nonneg fun i _ => mul_self_nonneg (w i)
    rcases hnn.lt_or_eq with h | h
    · exact h
    · exact absurd (dotProduct_self_eq_zero.mp h.symm) hw0
  set s := (Real.sqrt (w ⬝ᵥ w))⁻¹ with hs
  refine ⟨s • w, ?_, ?_, ?_⟩
  · rw [smul_dotProduct, dotProduct_smul, smul_eq_mul, smul_eq_mul, ← mul_assoc, hs,
      ← mul_inv, Real.mul_self_sqrt hpos.le, inv_mul_cancel₀ hpos.ne']
  · rw [smul_dotProduct, hn, smul_zero]
  · rw [smul_dotProduct, hm, smul_zero]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor

For Girard's theorem we formalise only the final arithmetic of the covering argument; the lune formula and the covering by six lunes are not formalised (they need area on the sphere, i.e. surface measure):

girard_bookkeepingLean 4Proved here from basic factsFormally verified
/-- **The bookkeeping step of Girard's theorem.** The three great circles through the sides
of a spherical triangle of area `Δ` (radius `R`) cut out three pairs of antipodal lunes, of
areas `2αR²`, `2βR²`, `2γR²` each. Together the six lunes cover the sphere once, except that
the triangle and its antipodal copy are covered three times each:
`2(2αR² + 2βR² + 2γR²) = 4πR² + 4Δ`. Hence `Δ = R²(α + β + γ - π)`. (The lune areas and the
covering argument are proved in the lesson; this lemma checks the arithmetic.) -/
theorem girard_bookkeeping {R α β γ Δ : ℝ}
    (hcover : 2 * (2 * α * R ^ 2 + 2 * β * R ^ 2 + 2 * γ * R ^ 2) =
      4 * Real.pi * R ^ 2 + 4 * Δ) :
    Δ = R ^ 2 * (α + β + γ - Real.pi) := by
  linarith
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor

For the hyperbolic plane, the two computations at the heart of the isometry theorem and the distance formula are proved here from scratch: the imaginary part of g(z)g(z), the difference g(z)−g(w)g(z) - g(w), and hence the invariance of ∣z−w∣2/(Im⁡zIm⁡w)|z - w|^2/(\operatorname{Im} z \operatorname{Im} w):

im_mobiusLean 4Proved here from basic factsFormally verified
/-- **Möbius maps preserve the upper half-plane.** For real `a, b, c, d` with `a d - b c = 1`,
`Im ((a z + b) / (c z + d)) = Im z / |c z + d|²`. In particular `Im z > 0` implies that the
image has positive imaginary part. (Mathlib: `UpperHalfPlane.im_smul_eq_div_normSq`.) -/
theorem im_mobius {a b c d : ℝ} (hdet : a * d - b * c = 1) (z : ℂ) :
    ((a * z + b) / (c * z + d)).im = z.im / normSq (c * z + d) := by
  rw [Complex.div_im]
  simp only [add_im, add_re, mul_im, mul_re, ofReal_re, ofReal_im, zero_mul, sub_zero,
    add_zero]
  rw [div_sub_div_same]
  congr 1
  linear_combination z.im * hdet
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor
mobius_subLean 4Proved here from basic factsFormally verified
/-- The difference of two image points: if `a d - b c = 1`, then
`g z - g w = (z - w) / ((c z + d)(c w + d))` for `g z = (a z + b) / (c z + d)`. -/
theorem mobius_sub {a b c d : ℝ} (hdet : a * d - b * c = 1) {z w : ℂ}
    (hz : (c : ℂ) * z + d ≠ 0) (hw : (c : ℂ) * w + d ≠ 0) :
    (a * z + b) / (c * z + d) - (a * w + b) / (c * w + d) =
      (z - w) / ((c * z + d) * (c * w + d)) := by
  rw [div_sub_div _ _ hz hw]
  congr 1
  have h : ((a : ℂ) * d - b * c) = 1 := by exact_mod_cast hdet
  linear_combination (z - w) * h
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor
cross_term_invariantLean 4Proved here from basic factsFormally verified
/-- **Möbius maps are hyperbolic isometries.** The hyperbolic distance in the upper half-plane
satisfies `cosh d(z, w) = 1 + |z - w|² / (2 Im z Im w)`. The quantity
`|z - w|² / (Im z · Im w)` is unchanged by `z ↦ (a z + b) / (c z + d)` (`a d - b c = 1`):
by `mobius_sub` and `im_mobius`, numerator and denominator are both divided by
`|c z + d|² |c w + d|²`. -/
theorem cross_term_invariant {a b c d : ℝ} (hdet : a * d - b * c = 1) {z w : ℂ}
    (hz : (c : ℂ) * z + d ≠ 0) (hw : (c : ℂ) * w + d ≠ 0) :
    normSq ((a * z + b) / (c * z + d) - (a * w + b) / (c * w + d)) /
        (((a * z + b) / (c * z + d)).im * ((a * w + b) / (c * w + d)).im) =
      normSq (z - w) / (z.im * w.im) := by
  rw [mobius_sub hdet hz hw, im_mobius hdet, im_mobius hdet, normSq_div, normSq_mul]
  have hz' : normSq ((c : ℂ) * z + d) ≠ 0 := (normSq_pos.mpr hz).ne'
  have hw' : normSq ((c : ℂ) * w + d) ≠ 0 := (normSq_pos.mpr hw).ne'
  rw [div_mul_div_comm, div_div_div_eq, mul_comm (normSq _ * normSq _) (z.im * w.im)]
  rw [mul_div_mul_right _ _ (mul_ne_zero hz' hw')]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor

Mathlib's UpperHalfPlane (written ℍ) is a genuine metric space with the hyperbolic distance. We cite its distance formula, its isometric action of SL(2,R)SL(2, \R), and the logarithmic distance along vertical lines:

cosh_distLean 4Applies a library theoremFormally verified
/-- **The hyperbolic distance formula** in Mathlib's upper half-plane `ℍ`:
`cosh (d z w) = 1 + |z - w|² / (2 Im z Im w)`. This is `UpperHalfPlane.cosh_dist`. -/
theorem cosh_dist (z w : UpperHalfPlane) :
    Real.cosh (dist z w) = 1 + dist (z : ℂ) w ^ 2 / (2 * z.im * w.im) :=
  UpperHalfPlane.cosh_dist z w
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor
sl2_isometryLean 4Applies a library theoremFormally verified
/-- **`SL(2, ℝ)` acts on `ℍ` by isometries.** Mathlib proves the instance
`IsIsometricSMul SL(2, ℝ) ℍ` by writing each element as a composite of translations, dilations
and `z ↦ -1/z`; we use it through `isometry_smul`. -/
theorem sl2_isometry (g : Matrix.SpecialLinearGroup (Fin 2) ℝ) :
    Isometry (fun z : UpperHalfPlane => g • z) :=
  isometry_smul UpperHalfPlane g
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor
dist_verticalLean 4Applies a library theoremFormally verified
/-- **The hyperbolic plane is infinitely large.** On a vertical line the distance is
`|log (Im z) - log (Im w)|`: from `i` to `i y` it is `|log y|`, which grows without bound as `y`
tends to `0` or `∞`. This is Mathlib's `UpperHalfPlane.dist_of_re_eq`. -/
theorem dist_vertical {z w : UpperHalfPlane} (h : z.re = w.re) :
    dist z w = dist (Real.log z.im) (Real.log w.im) :=
  UpperHalfPlane.dist_of_re_eq h
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor

Finally, the failure of the parallel postulate, in the case p=1+ip = 1 + i of the human proof:

many_parallelsLean 4Proved here from basic factsFormally verified
/-- **Infinitely many parallels.** Let `L` be the hyperbolic line `Re z = 0` (the positive
imaginary axis) and `p = 1 + i`. For every real `c ≥ 1`, the semicircle centred at the real
point `c` through `p` is a hyperbolic line through `p`, and it does not meet `L`: a point `i y`
(`y > 0`) on it would satisfy `c² + y² = (1 - c)² + 1`, i.e. `y² = 2 - 2c ≤ 0`. Different `c`
give different lines, so there are infinitely many lines through `p` missing `L`. -/
theorem many_parallels {c : ℝ} (hc : 1 ≤ c) {y : ℝ} (hy : 0 < y) :
    normSq (I * y - c) ≠ normSq (1 + I - c) := by
  simp only [normSq_apply, sub_re, sub_im, mul_re, mul_im, add_re, add_im, I_re, I_im,
    ofReal_re, ofReal_im, one_re, one_im]
  intro h
  nlinarith
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/NonEuclideanGeometry.leanTry it in the Lean web editor

Not formalised here: surface area on the sphere and in H\mathbb H (so neither area theorem is formalised beyond its bookkeeping), the classification of hyperbolic lines, and the independence of the parallel postulate — which would require formalising Hilbert's axioms and verifying them in the model.

ComputationC

Measuring curved triangles

The first experiment takes triangles on the unit sphere — the octant triangle and triangles joining cities on several continents — and computes their angle excess, their area by an exact closed formula, and their area by Monte Carlo: throw 200,000 random points onto the sphere and count the fraction that land inside. It also checks the spherical law of cosines.

Girard's theorem: angle excess equals area on the spherePythonNumerical approximationStatistical evidenceComputationally tested
"""Spherical triangles: angle excess versus area, three independent ways.

For triangles on the unit sphere the experiment computes (1) the angle excess
alpha + beta + gamma - pi from the angles between the planes of the sides,
(2) the area by Monte Carlo: the fraction of 200,000 random points of the
sphere that fall inside the triangle, times 4 pi, with a standard error, and
(3) the area from the exact Van Oosterom-Strackee formula
tan(E/2) = |A.(B x C)| / (1 + A.B + B.C + C.A). Girard's theorem says all three
agree. It also checks the spherical law of cosines on each triangle. The angle
and formula columns are numerical (floating point); the Monte Carlo column is
statistical evidence, with its uncertainty shown.
"""

import numpy as np

def unit(v):
    """The vector v scaled to length 1."""
    v = np.asarray(v, dtype=float)
    return v / np.linalg.norm(v)

def from_lat_lon(lat, lon):
    """Unit vector at latitude, longitude given in degrees."""
    la, lo = np.radians(lat), np.radians(lon)
    return np.array([np.cos(la) * np.cos(lo), np.cos(la) * np.sin(lo), np.sin(la)])

def vertex_angle(a, b, c):
    """The angle at a between the great circles ab and ac."""
    n1, n2 = np.cross(a, b), np.cross(a, c)
    cos_t = np.dot(n1, n2) / (np.linalg.norm(n1) * np.linalg.norm(n2))
    return float(np.arccos(np.clip(cos_t, -1.0, 1.0)))

def angle_excess(a, b, c):
    """alpha + beta + gamma - pi."""
    return vertex_angle(a, b, c) + vertex_angle(b, c, a) + \
        vertex_angle(c, a, b) - np.pi

def exact_area(a, b, c):
    """Van Oosterom-Strackee: the solid angle of the triangle abc."""
    num = abs(np.dot(a, np.cross(b, c)))
    den = 1 + np.dot(a, b) + np.dot(b, c) + np.dot(c, a)
    return float(2 * np.arctan2(num, den))

def monte_carlo_area(a, b, c, n, rng):
    """(estimate, standard error) of the area from n random sphere points."""
    p = rng.normal(size=(n, 3))
    p /= np.linalg.norm(p, axis=1)[:, None]
    inside = np.ones(n, dtype=bool)
    for u, v, w in ((a, b, c), (b, c, a), (c, a, b)):
        normal = np.cross(u, v)
        inside &= np.sign(p @ normal) == np.sign(np.dot(w, normal))
    frac = inside.mean()
    return 4 * np.pi * frac, 4 * np.pi * np.sqrt(frac * (1 - frac) / n)

def law_of_cosines_gap(a, b, c):
    """|cos(side ab) - (cos ac cos bc + sin ac sin bc cos gamma)|."""
    side = {k: np.arccos(np.clip(np.dot(*v), -1, 1)) for k, v in
            {"ab": (a, b), "ac": (a, c), "bc": (b, c)}.items()}
    gamma = vertex_angle(c, a, b)
    rhs = np.cos(side["ac"]) * np.cos(side["bc"]) + \
        np.sin(side["ac"]) * np.sin(side["bc"]) * np.cos(gamma)
    return float(abs(np.cos(side["ab"]) - rhs))

TRIANGLES = {
    "octant (3 right angles)": ((90, 0), (0, 0), (0, 90)),
    "Mexico City-B. Aires-Lagos": ((19.4, -99.1), (-34.6, -58.4), (6.5, 3.4)),
    "Mumbai-Beijing-Jakarta": ((19.1, 72.9), (39.9, 116.4), (-6.2, 106.8)),
    "thin: Cairo-Lagos-Dakar": ((30.0, 31.2), (6.5, 3.4), (14.7, -17.5)),
    "Sydney-Lima-Tokyo": ((-33.9, 151.2), (-12.0, -77.0), (35.7, 139.7)),
    "small: 1 degree sides": ((0, 0), (0, 1), (1, 0)),
}

def main():
    rng = np.random.default_rng(1829)
    print(f"{'triangle':<27}{'excess':>9}{'exact':>9}{'Monte Carlo':>18}"
          f"{'cos law':>9}")
    for label, pts in TRIANGLES.items():
        a, b, c = (from_lat_lon(*p) for p in pts)
        ex = angle_excess(a, b, c)
        area = exact_area(a, b, c)
        mc, se = monte_carlo_area(a, b, c, 200_000, rng)
        gap = law_of_cosines_gap(a, b, c)
        print(f"{label:<27}{ex:9.5f}{area:9.5f}{mc:10.4f} +- {se:.4f}"
              f"{gap:9.1e}")
    print()
    print("Areas on the unit sphere (4 pi = 12.566 is the whole sphere). The")
    print("octant has excess pi/2 and area 1/8 of the sphere. Small triangles")
    print("are almost flat: their angle sum is barely above pi.")
    print("A Monte Carlo value within about 2 standard errors of the exact")
    print("area is what sampling theory predicts.")
    print()
    print("Epistemic status: the excess and the exact formula are floating-")
    print("point computations; the Monte Carlo column is statistical evidence")
    print("with its error bar. Six triangles do not prove Girard's theorem;")
    print("the lesson does. 'cos law' is the residual of the law of cosines.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

The second experiment does the same in the upper half-plane, where the angles are computed in two independent ways (from the side lengths by the hyperbolic law of cosines, and from the tangent directions of the arcs), and the area ∬dx dy/y2\iint dx\,dy/y^2 by Monte Carlo. It also applies random Möbius transformations and pushes a triangle towards an ideal one.

Hyperbolic triangles: angle defect, area and Moebius invariancePythonNumerical approximationStatistical evidenceComputationally tested
"""Hyperbolic triangles in the upper half-plane: angle defect versus area.

Distances come from cosh d(z, w) = 1 + |z - w|^2 / (2 Im z Im w). The angles of
a triangle are computed in two independent ways: from the side lengths by the
hyperbolic law of cosines, and from the Euclidean tangent directions of the
circular arcs (the model is conformal, so Euclidean angles are hyperbolic
angles). The area, the integral of dx dy / y^2 over the triangle, is estimated
by Monte Carlo and compared with the defect pi - (alpha + beta + gamma). The
experiment also applies random Moebius maps z -> (az + b)/(cz + d) with
ad - bc = 1 and checks that side lengths and angles do not change, and it
pushes the vertices towards the boundary to watch the defect approach pi.
Numerical and statistical evidence, not proof.
"""

import cmath
import math

import numpy as np

def hyp_dist(z, w):
    """Hyperbolic distance in the upper half-plane."""
    return math.acosh(1 + abs(z - w) ** 2 / (2 * z.imag * w.imag))

def angles_by_cosine_law(z1, z2, z3):
    """The three angles from the side lengths (hyperbolic law of cosines)."""
    a, b, c = hyp_dist(z2, z3), hyp_dist(z1, z3), hyp_dist(z1, z2)

    def ang(opp, s1, s2):
        num = math.cosh(s1) * math.cosh(s2) - math.cosh(opp)
        return math.acos(max(-1.0, min(1.0, num / (math.sinh(s1) * math.sinh(s2)))))

    return ang(a, b, c), ang(b, a, c), ang(c, a, b)

def geodesic(z, w):
    """('vertical', x) or ('circle', centre, radius) for the line through z, w."""
    if abs(z.real - w.real) < 1e-12:
        return ("vertical", z.real)
    c = (abs(w) ** 2 - abs(z) ** 2) / (2 * (w.real - z.real))
    return ("circle", c, abs(z - c))

def tangent(z, w):
    """Unit Euclidean tangent at z of the geodesic arc from z towards w."""
    g = geodesic(z, w)
    if g[0] == "vertical":
        t = 1j if w.imag > z.imag else -1j
    else:
        t = 1j * (z - g[1])  # perpendicular to the radius
        if ((w - z) * t.conjugate()).real < 0:
            t = -t
    return t / abs(t)

def angles_by_tangents(z1, z2, z3):
    """The three angles as Euclidean angles between tangent vectors."""
    out = []
    for p, q, r in ((z1, z2, z3), (z2, z3, z1), (z3, z1, z2)):
        out.append(abs(cmath.phase(tangent(p, r) / tangent(p, q))))
    return tuple(out)

def same_side(points, g, ref):
    """Boolean array: which points lie on the same side of geodesic g as ref."""
    if g[0] == "vertical":
        return np.sign(points.real - g[1]) == np.sign(ref.real - g[1])
    s = np.abs(points - g[1]) ** 2 - g[2] ** 2
    return np.sign(s) == np.sign(abs(ref - g[1]) ** 2 - g[2] ** 2)

def area_monte_carlo(z1, z2, z3, n, rng):
    """(estimate, standard error) of the hyperbolic area of the triangle."""
    verts = (z1, z2, z3)
    sides = [(verts[i], verts[(i + 1) % 3], verts[(i + 2) % 3]) for i in range(3)]
    xs = [v.real for v in verts]
    top = max(v.imag for v in verts)
    for p, q, _ in sides:
        g = geodesic(p, q)
        if g[0] == "circle" and min(p.real, q.real) < g[1] < max(p.real, q.real):
            top = max(top, g[2])
    x0, x1, y0 = min(xs), max(xs), min(v.imag for v in verts)
    pts = rng.uniform(x0, x1, n) + 1j * rng.uniform(y0, top, n)
    inside = np.ones(n, dtype=bool)
    for p, q, r in sides:
        inside &= same_side(pts, geodesic(p, q), r)
    f = np.where(inside, 1 / pts.imag ** 2, 0.0) * (x1 - x0) * (top - y0)
    return float(f.mean()), float(f.std() / math.sqrt(n))

def mobius(m, z):
    """Apply z -> (az + b) / (cz + d)."""
    a, b, c, d = m
    return (a * z + b) / (c * z + d)

def random_sl2(rng):
    """A random real 2 x 2 matrix with determinant 1."""
    while True:
        a, b, c = rng.uniform(-2, 2, 3)
        if abs(a) > 0.2:
            return a, b, c, (1 + b * c) / a

TRIANGLES = {
    "i, 1+2i, -1+1.5i": (1j, 1 + 2j, -1 + 1.5j),
    "2i, 3i, 1+2i": (2j, 3j, 1 + 2j),
    "0.2i, 2+0.3i, 1+3i": (0.2j, 2 + 0.3j, 1 + 3j),
}

def main():
    rng = np.random.default_rng(1868)
    print("Hyperbolic triangles (curvature -1), angles in radians")
    print(f"{'vertices':<20}{'angle sum':>10}{'defect':>9}{'MC area':>18}"
          f"{'tangent':>10}")
    for label, (z1, z2, z3) in TRIANGLES.items():
        law = angles_by_cosine_law(z1, z2, z3)
        tan = angles_by_tangents(z1, z2, z3)
        gap = max(abs(x - y) for x, y in zip(law, tan))
        area, se = area_monte_carlo(z1, z2, z3, 400_000, rng)
        print(f"{label:<20}{sum(law):10.5f}{math.pi - sum(law):9.5f}"
              f"{area:10.4f} +- {se:.4f}{gap:10.1e}")
    print("'tangent' = largest gap between the two angle computations.")
    print()
    worst_len = worst_ang = 0.0
    z = TRIANGLES["i, 1+2i, -1+1.5i"]
    for _ in range(200):
        m = random_sl2(rng)
        w = [mobius(m, v) for v in z]
        for i in range(3):
            j = (i + 1) % 3
            worst_len = max(worst_len, abs(hyp_dist(z[i], z[j]) -
                                           hyp_dist(w[i], w[j])))
        worst_ang = max(worst_ang, max(abs(p - q) for p, q in zip(
            angles_by_cosine_law(*z), angles_by_tangents(*w))))
    print("200 random Moebius maps with ad - bc = 1:")
    print(f"  largest change in a side length: {worst_len:.1e}")
    print(f"  largest change in an angle:      {worst_ang:.1e}")
    print()
    print("Towards an ideal triangle: vertices -1 + ei, 1 + ei, i/e")
    for e in (0.5, 0.1, 0.01, 0.001):
        s = sum(angles_by_cosine_law(-1 + e * 1j, 1 + e * 1j, 1j / e))
        print(f"  e = {e:<6} angle sum {s:.6f}, defect {math.pi - s:.6f}")
    print("The defect creeps up to pi but never reaches it: area < pi.")
    print()
    print("Epistemic status: floating-point computation and a Monte Carlo")
    print("estimate with its standard error; agreement on a few triangles is")
    print("evidence. The lesson proves area = defect and Moebius invariance.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Both are evidence of different kinds: floating-point computation, accurate to about 10−1510^{-15}, and statistical sampling, accurate only to its standard error. Neither proves anything about all triangles; the theorems above do.

Explore

Explore: the hyperbolic plane

In the Poincaré disc, drag the vertices towards the boundary circle and watch the angle sum fall towards 00 while the area climbs towards π\pi. Then switch to the plane and the sphere and compare: the readout "angle sum −π=K⋅- \pi = K \cdot area" holds in all three, with K=−1K = -1, 00 and +1+1.

A hyperbolic triangle in the Poincaré disc

The sides are arcs meeting the boundary at right angles; the boundary is infinitely far away.

13.3°12.3°15.3°ABC

Poincaré disk model: the sides are arcs of circles that meet the boundary at right angles (dashed: each side extended). The boundary circle is infinitely far away.

  • ∠A13.3°
  • ∠B12.3°
  • ∠C15.3°

∠A + ∠B + ∠C = 40.8°

Angle defect (180° − sum)
139.2° = 2.429 rad
Area (curvature −1), measured numerically
2.429

π − (∠A + ∠B + ∠C) = AreaIn the hyperbolic plane with curvature −1, the defect in radians equals the area. The area is computed separately, by numerical integration.

∠A + ∠B + ∠C − π = K · Area

Flat planeK = 0∠A+∠B+∠C = 180°
SphereK = 1/R²∠A+∠B+∠C > 180°
Hyperbolic planeK = −1∠A+∠B+∠C < 180°

This is a first glimpse of the Gauss–Bonnet theorem: for a triangle whose sides are geodesics (shortest paths), the angle sum minus π equals the total curvature inside it. Here the curvature K is the same everywhere; on other surfaces you add up (integrate) K over the area.

Exercises

Exercises

1. Non-Euclidean geometry: spherical and hyperbolic

Warm-upHuman

A pilot flies from the North Pole due south to the equator, turns to fly a quarter of the way around the equator, and then flies due north back to the pole. What is the angle sum of this triangle, in degrees?

2. Non-Euclidean geometry: spherical and hyperbolic

Warm-upHuman

A triangle on a sphere of radius 22 has angles π2\frac{\pi}{2}, π2\frac{\pi}{2} and π3\frac{\pi}{3}. Its area is kπ3\frac{k\pi}{3}. What is kk?

3. Non-Euclidean geometry: spherical and hyperbolic

CoreHuman

A triangle in the hyperbolic plane (curvature −1-1) has three angles of π6\frac{\pi}{6} each. What is its area?

Choose one

4. Non-Euclidean geometry: spherical and hyperbolic

CoreHuman

Which of these curves are lines (geodesics) of the upper half-plane model H\mathbb H? (Choose all that apply.)

Choose all that apply

5. Non-Euclidean geometry: spherical and hyperbolic

CoreHuman

What is the hyperbolic distance in H\mathbb H between ii and e3ie^3 i?

6. Non-Euclidean geometry: spherical and hyperbolic

CoreHuman

In the theorem that g(z)=az+bcz+dg(z) = \frac{az + b}{cz + d} is an isometry of H\mathbb H we required a,b,c,da, b, c, d real with ad−bc=1ad - bc = 1. What goes wrong for g(z)=−zg(z) = -z, which has a=−1a = -1, b=c=0b = c = 0, d=1d = 1 and ad−bc=−1ad - bc = -1?

Choose one

7. Non-Euclidean geometry: spherical and hyperbolic

CoreFormal

The Lean theorem many_parallels states: for c : ℝ with 1 ≤ c and y : ℝ with 0 < y, normSq (I * y - c) ≠ normSq (1 + I - c). What does it say geometrically?

Choose one

8. Non-Euclidean geometry: spherical and hyperbolic

StretchHuman

Why does the upper half-plane model show that the parallel postulate cannot be proved from the other axioms of plane geometry?

Choose one

9. Non-Euclidean geometry: spherical and hyperbolic

StretchComputational

Write hyp_dist(z, w) for points of the upper half-plane (Python complex numbers with positive imaginary part), using cosh⁡d=1+∣z−w∣22Im⁡zIm⁡w\cosh d = 1 + \frac{|z - w|^2}{2\operatorname{Im} z \operatorname{Im} w}, and defect(z1, z2, z3), the defect π−(α+β+γ)\pi - (\alpha + \beta + \gamma) of the triangle, computing each angle from the side lengths by the hyperbolic law of cosines cos⁡γ=cosh⁡acosh⁡b−cosh⁡csinh⁡asinh⁡b\cos\gamma = \frac{\cosh a \cosh b - \cosh c}{\sinh a \sinh b} (where cc is the side opposite γ\gamma).

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Common misconceptionsH

Common misconceptions

Misconception

"Non-Euclidean geometry contradicts Euclid." It contradicts only the fifth postulate, which it replaces. Hyperbolic geometry is exactly as consistent as Euclidean geometry (each can be modelled inside the other), and every theorem Euclid proved without the fifth postulate — the first 28 propositions of Book I — remains true in it.

Misconception

"The lines of the Poincaré disc are curved." They look curved only in the Euclidean picture of the model. Measured with the hyperbolic metric they are perfectly straight: each is the unique shortest path between any two of its points. The model is a map, and like a flat map of the Earth it distorts — here, it shrinks distances near the boundary, so shortest paths bow towards the centre.

Misconception

"Spherical geometry satisfies all of Euclid's axioms except the parallel postulate." Other axioms fail too: two antipodal points lie on infinitely many great circles, so a line through two points need not be unique, and lines cannot be extended indefinitely — they close up. This is why spherical geometry is not a model of neutral geometry, and why neutral geometry can prove that angle sums never exceed π\pi.

Misconception

"Every hyperbolic triangle has the same angle sum." The angle sum depends on the size of the triangle: it is π\pi minus the area. Tiny triangles have angle sums close to π\pi; ideal triangles have angle sum 00. The same holds on the sphere with excess in place of defect.

Misconception

"The hyperbolic plane is just a saddle or a trumpet-shaped surface." Saddle shapes and Beltrami's pseudosphere have curvature −1-1 only on part of themselves, or represent only a piece of the hyperbolic plane. By a theorem of Hilbert (1901), no complete smooth surface in R3\R^3 has constant negative curvature, so the whole hyperbolic plane cannot be built as a smooth surface in ordinary space; that is why we use models such as the disc and the half-plane. (Crocheted "hyperbolic" surfaces, popularised by Daina Taimiņa, approximate it locally.)

ViewpointsH

Many ways of seeing

Geometry— Curvature and the three model geometries

Gauss's Theorema Egregium (1827) showed that the curvature KK of a surface can be measured from inside it, by measuring distances and angles alone. The sphere, the plane and the hyperbolic plane are the complete simply connected surfaces of constant curvature +1+1, 00 and −1-1, and for a geodesic triangle on any surface the local Gauss–Bonnet formula says α+β+γ−π=∬ΔK dA\alpha + \beta + \gamma - \pi = \iint_\Delta K\,dA, which contains both Girard's theorem and the hyperbolic area formula. One practical consequence: since the sphere has K≠0K \ne 0 and the plane K=0K = 0, no map of any region of the Earth preserves all distances — every atlas distorts something. See curves and surfaces and Riemannian geometry.

Topology— Most surfaces are hyperbolic

Glue the opposite sides of a square and you get a flat torus; can other closed surfaces be given a geometry in which every point looks the same? A regular octagon in the hyperbolic plane can be made with all angles equal to π/4\pi/4: a tiny regular octagon has angles close to the Euclidean 3π/43\pi/4, and as it is enlarged its angles decrease continuously towards 00, so at some size they equal π/4\pi/4. Gluing its sides in the pattern a1b1a1−1b1−1a2b2a2−1b2−1a_1 b_1 a_1^{-1} b_1^{-1} a_2 b_2 a_2^{-1} b_2^{-1} brings all eight corners together with total angle 8⋅π/4=2π8 \cdot \pi/4 = 2\pi, so the result is a smooth hyperbolic surface: the genus-2 surface. By the uniformisation theorem every closed surface carries a metric of constant curvature, whose sign is that of the Euler characteristic: the sphere and projective plane are spherical, the torus and Klein bottle flat, and all the others hyperbolic. Gauss–Bonnet then gives the area: −area=2πχ-\text{area} = 2\pi\chi, so the genus-2 surface has area 4π4\pi, exactly the area of the octagon (6π−8⋅π4=4π6\pi - 8 \cdot \frac{\pi}{4} = 4\pi, using the area formula for hyperbolic polygons). See surfaces and the Euler characteristic.

Algebra— Geometry as a group: SO(3), PSL(2, R) and the modular group

In Klein's spirit (transformation geometry), spherical geometry is the geometry of the rotation group SO(3)SO(3) acting on the sphere, and hyperbolic geometry the geometry of PSL(2,R)=SL(2,R)/{±I}PSL(2, \R) = SL(2, \R)/\{\pm I\} acting on H\mathbb H by Möbius transformations (plus reflections). These groups are as algebraically different as the geometries: SO(3)SO(3) is compact, PSL(2,R)PSL(2, \R) is not. Discrete subgroups of PSL(2,R)PSL(2, \R), the Fuchsian groups, tile the hyperbolic plane. The most famous is the modular group PSL(2,Z)PSL(2, \Z) of integer matrices, generated by z↦z+1z \mapsto z + 1 and z↦−1/zz \mapsto -1/z; its tiling of H\mathbb H by copies of the region ∣Re⁡z∣≤12|\operatorname{Re} z| \le \frac12, ∣z∣≥1|z| \ge 1 underlies the theory of modular forms, a central object of modern number theory. See groups.

Logic— Independence, models and relative consistency

The parallel postulate was the first famous independence result, and its proof set the pattern for all later ones: to show that Σ\Sigma does not prove PP, build a model of Σ∪{¬P}\Sigma \cup \{\neg P\}. The same method, in far more sophisticated forms, shows that the continuum hypothesis is independent of the axioms of set theory (Gödel 1938, Cohen 1963). Note what the models prove: not that hyperbolic geometry is consistent outright, but that it is consistent if Euclidean geometry (equivalently, the theory of the real numbers) is. Tarski showed (1940s) that elementary Euclidean geometry — first-order, with continuity as an axiom scheme — is complete and decidable. See model theory and forcing and independence.

Physics— Velocities in relativity add hyperbolically

The hyperbolic plane appears inside physics, not just as a mathematical possibility. In special relativity, the set of possible velocities of a particle is a hyperbolic space: writing v=ctanh⁡θv = c \tanh \theta, the rapidity θ\theta is a hyperbolic distance from rest, and collinear velocities combine by adding rapidities, tanh⁡(θ1+θ2)=tanh⁡θ1+tanh⁡θ21+tanh⁡θ1tanh⁡θ2\tanh(\theta_1 + \theta_2) = \frac{\tanh\theta_1 + \tanh\theta_2}{1 + \tanh\theta_1 \tanh\theta_2} — Einstein's velocity addition formula. The hyperboloid t2−x2−y2=1t^2 - x^2 - y^2 = 1, t>0t > 0, in Minkowski spacetime, with the metric induced from it, is a model of the hyperbolic plane, and the Lorentz group acts on it by isometries. On cosmic scales, general relativity allows space to be curved; current measurements of the cosmic microwave background find the spatial curvature of the observable universe to be close to zero, within small error bars — a question that, thanks to Gauss, Bolyai and Lobachevsky, is a question of measurement and not of logic. See relativity.

History & global context

History and global context

  • Spherical trigonometry grew out of astronomy. Menelaus of Alexandria's Sphaerica (c. 100 CE) studied spherical triangles. Astronomers in India and in the Islamic world developed spherical trigonometry extensively: Abū al-Wafāʾ al-Būzjānī and his contemporaries stated the spherical law of sines in the 10th century, and al-Bīrūnī (11th century) used spherical trigonometry for geography and to compute the qibla, the direction of Mecca, from any city. Thomas Harriot found the area of a spherical triangle in 1603, but did not publish; Albert Girard published it in 1629.
  • The parallel postulate. Commentators from Ptolemy and Proclus onward tried to prove it. Ibn al-Haytham (11th century) studied quadrilaterals with three right angles; Omar Khayyam (Explanations of the Difficulties in the Postulates of Euclid, 1077) and Naṣīr al-Dīn al-Ṭūsī (13th century) studied quadrilaterals with two right angles at the base and equal sides — the configuration later used by Giovanni Saccheri (Euclides ab omni naevo vindicatus, 1733), who derived many hyperbolic theorems while believing he was refuting them. Johann Heinrich Lambert (1766) noticed that the defect would be proportional to area and compared the hypothesis to a sphere of imaginary radius. Adrien-Marie Legendre published repeated attempts.
  • Discovery. Carl Friedrich Gauss developed the new geometry privately from the 1810s–1820s but did not publish. Nikolai Lobachevsky in Kazan presented it in 1826 and published from 1829; János Bolyai published it as an appendix to his father Farkas Bolyai's textbook in 1832. Bernhard Riemann's lecture On the hypotheses which lie at the foundations of geometry (1854) placed all of this inside a general theory of curved spaces.
  • Models. Eugenio Beltrami (1868) gave the first models, proving relative consistency; Felix Klein (1871) gave a projective model and the names elliptic, parabolic and hyperbolic; Henri Poincaré (1882) found the disc and half-plane models in his work on differential equations and automorphic functions. David Hilbert's Grundlagen der Geometrie (1899) made the axioms, and thus the independence statement, fully precise.
Further reading

Further reading

  • Marvin Jay Greenberg, Euclidean and Non-Euclidean Geometries: Development and History (4th ed. 2008) — axioms, neutral geometry, models and independence, with much history.
  • Robin Hartshorne, Geometry: Euclid and Beyond (2000) — Hilbert's axioms and a careful construction of the hyperbolic plane.
  • James W. Anderson, Hyperbolic Geometry (2nd ed. 2005) — the upper half-plane and disc models, Möbius transformations, area and trigonometry.
  • John Stillwell, Geometry of Surfaces (1992) — spherical, Euclidean and hyperbolic geometry and the surfaces built from them.
  • William P. Thurston, Three-Dimensional Geometry and Topology, Vol. 1 (1997) — the modern view, beautifully illustrated.
  • H. S. M. Coxeter, Non-Euclidean Geometry (1942; 6th ed. 1998) — a classic, synthetic treatment.
  • B. A. Rosenfeld, A History of Non-Euclidean Geometry (1988) — including the work of mathematicians in the medieval Islamic world.