Complex geometry for quantum mechanics, exactly
Complex numbers, qubit states and unitary gates written as rational geometry (quadrance, spread, Cayley parametrisations), every identity checked exactly, and an experiment that runs the same circuits exactly and in float on CPUs and GPUs.
Abstract
Complex numbers with rational real and imaginary parts, the Gaussian rationals , carry most of the geometry quantum mechanics uses, exactly. This paper states that geometry in quadrance and spread. Rational points of the circle come from the Cayley parametrisation . Qubit states are rays with Gaussian-rational amplitudes, and their Born probabilities are exact rationals. The Bloch sphere is the inverse stereographic image of , reached through the Hopf map. Fidelity is a spread: is the Hermitian spread between rays, a quarter of the chord quadrance on the Bloch sphere, and the Bloch spread is the second spread polynomial of it. Gates are Cayley transforms of rational Hermitian matrices, and rotations come from rational quaternions. The complexified circle , with the point , ties the circle's rational phases to these Cayley steps. Every identity was checked exactly in Raya, 16 checks on up to 2,000 random instances each and every one passing on x86-64 and arm64, and symbolically in SymPy (23 checks).
An exact projective state-vector simulator over the Gaussian integers ran the same circuits as PyTorch complex64 and complex128: Cayley-rational rotations with H, S and CNOT, up to 4,096 layers. The exact unitarity check held at every checkpoint. Two independent exact implementations, Raya and Python, produced byte-identical states, and the Raya states were identical on Xeon and Graviton4. Exact cost is the limit: the size of each amplitude grows linearly with depth times width (115,000 bits per component at 8 qubits and 4,096 layers), so exact runs stopped at 10–14 qubits. At 10 qubits and 4,096 layers, measured exactly against the exact ray, complex64 had a fidelity error of and complex128 . Norm drift was and , and Born-probability errors were up to and . On the Xeon, the complex128 norm drift at the deepest checkpoint is predicted to within 2.1% by the exact quadrance of the rounded gate entries alone. Gate entries computed with atan, cos and sin gave 1.1–1.5 times the fidelity error of entries from one rational division, and on the Xeon 4 times the complex128 norm drift (that ratio depends on the machine's ). At 20–28 qubits on an RTX 4090 and an H100, mirror circuits returned to with spreads of to (complex128) and to (complex64). Float results were bit-identical between runs on one machine, but differed across CPUs; only some machine pairs matched (the two GPUs in complex64, and the RTX 4090 with Graviton4 in complex128 with rational entries). One cause is a that PyTorch's CPU build returned one ulp low on the Xeon. Exact simulation does not replace float simulation at scale. It is a reference that makes float errors measurable exactly.
The problem
Quantum mechanics is written with complex numbers, and most of what is computed from a state is a ratio of quadrances: a Born probability is , a fidelity is . Those are rational functions of the amplitudes. The transcendental functions come in with the gates: a rotation is usually written , and a simulator then rounds and , multiplies, rounds again, and carries the rounding through every layer.
This paper asks two questions. First, how much of the geometry of qubits can be stated exactly over the Gaussian rationals , in N. J. Wildberger's rational trigonometry (quadrance in place of distance, spread in place of angle)? Second, what does an exact state-vector simulator built on that geometry cost, and what does it show about float simulators?
Method
Quadrance and spread in the complex plane
A complex number with is a Gaussian rational. Its quadrance is
and quadrance is multiplicative, (the Brahmagupta–Fibonacci identity). For two non-zero complex numbers, carries both the dot and the cross of the two directions: . The spread between the directions of and is
a rational number in : 0 for the same direction, 1 for perpendicular directions. Multiplying by scales every quadrance by and turns every direction by the spread : complex multiplication is a rational rotation-dilation (Figure 1).

Rational points on the circle
The line through with slope meets the unit circle again at
This Cayley (stereographic) parametrisation is a bijection between and the rational points of the circle (Figures 2–3).


Turning times multiplies the spread by a spread polynomial, with , and (Figure 4). A rational point other than has infinite order (its angle is an irrational fraction of a turn, by Niven's theorem), so its powers never close up and fill the circle densely (Figure 5).
![Spread polynomials S1 to S5 on [0,1] with exact rational points](/whitepapers/complex-geometry-quantum-mechanics/img/f05-spread-polynomials.png)

Möbius maps with rational coefficients
A Möbius map with and sends to itself, composes by matrix multiplication, and keeps the cross-ratio exactly. The Cayley transform sends the rational points of the real line to rational points of the unit circle and the upper half plane into the unit disc (Figures 6–7).


Qubits as rays
A qubit state is a ray in : the vector up to a non-zero complex scalar. With nothing needs normalising. The Born probabilities are quotients of quadrances,
exact rationals for every Gaussian-rational state (Figure 8). For example has and .

The Bloch sphere and the Hopf map
The Hopf map sends a ray to its Bloch vector,
and the identity puts every Gaussian-rational state exactly on the unit sphere. Writing , it is the inverse stereographic projection
so the rational points of the Bloch sphere are exactly the images of (Figures 9–10). The example above lands on . The fibre over a Bloch point is the circle of states with ; on a rational fibre the rational points are the multiples by Cayley points , and the Hopf map is constant on them exactly (Figures 11–12). The state , with on the nose, lies over .




Fidelity is a spread
For two vectors the fidelity of their rays is
and is the Hermitian spread between the rays: the same formula as Wildberger's spread , with the Hermitian product in place of the dot product. It is the Fubini–Study geometry of projective Hilbert space stated without an angle (for readers used to angles, is what the Fubini–Study distance gives as ). The complex Lagrange identity writes it as a sum of quadrances of minors (an area over the product of two quadrances),
which is also the numerically stable way to compute it: no cancellation between two numbers near 1.
On a qubit, with Bloch vectors :
The infidelity is a quarter of the chord quadrance on the Bloch sphere, and the spread between the Bloch vectors is the second spread polynomial of the spread between the rays: the Bloch angle is twice the Fubini–Study angle (Figures 13–14). For and : , , and the Bloch spread is .


Unitaries without transcendental functions
For a Hermitian matrix with entries in , the Cayley transform
is unitary with entries in ; is always invertible (its eigenvalues are ), the map inverts as , and every unitary without the eigenvalue arises this way exactly once. It is the Crank–Nicolson step of the Schrödinger equation. For one qubit and ( a Pauli matrix, ):
which is with : the rotation's cosine and sine are a rational point of the circle, and no angle is ever formed. . The Bloch vector turns by the rational rotation with cosine and sine , , and stays exactly on the sphere (Figure 15).

Pauli algebra and rational quaternions
The Pauli matrices have Gaussian-integer entries and . The map is multiplicative, so a quaternion with rational coefficients gives
and the rotation of with has rational entries (Euler–Rodrigues), with and exactly. Every rational rotation of comes from a rational quaternion. Euler's four-square identity makes composition exact (Figure 16).

How dense the rational unitaries are, and what they miss
Rational points are dense on the circle, on and on , so any rotation can be approximated by a rational one. What cannot be done is to hit most named gates exactly over : the Hadamard gate and the T gate need (their entries lie in , the ring of exact Clifford+T synthesis), and apart from rotations by 60°, 90°, 120° and 180° (Niven's theorem) no rational rotation has a rational angle in degrees. Two measurements quantify the approximation (Figures 17–18): the best Cayley-rational stand-in for the T gate as the denominator grows, and the nearest rational unit quaternion of bounded height for random targets on .


The complexified circle
Keep the circle's equation and its rational parametrisation, and let the numbers be complex rationals instead of rationals: that simple step is the right entry point for quantum mechanics. The circle becomes the complex circle
and the same formulas , with , , give points of it. For example, take : then , and
with exactly. Drawn this way, a point of the complex circle is a pair of points in two complex planes side by side (Figure 19); the whole curve is a surface in four real dimensions.
The coordinate makes the structure visible. Since , the complex circle is the hyperbola with , and
is the Cayley parametrisation again. For the example, and . Real gives : those are the phases of quantum mechanics, as rational points. Complex with gives (here ): with the Cayley transform above, so the upper half plane of parameters goes into the unit disc (Figure 20). In operator form this is the Cayley step with a generator that is not Hermitian: a contraction, the exact-arithmetic version of a decaying (imaginary-time) step. The quantum state space itself is a different complexification of the circle: the Hermitian sphere in (a 3-sphere), not the bilinear . The two meet exactly in the real circle: subtracting the real part of from leaves , which forces .


The exact simulator
The simulator keeps the state as a ray of Gaussian integers: integer vectors for , up to a scalar. Each gate acts by its small integer numerator matrix:
- the Cayley rotation with , , on axis X, Y or Z;
- as (its is a scalar on the ray, so it never enters the arithmetic);
- and CNOT, which only permute and negate integers.
The quadrance is carried separately as an exact integer, multiplied by per rotation and by 2 per . At every checkpoint the simulator recomputes from the vector and compares it with : equality is an exact unitarity check, and it held at every checkpoint of every run. The integer content (gcd of all components) is divided out at checkpoints. Born probabilities are , exact rationals.
Two independent implementations were written, one in Raya and one in Python. Both write each checkpoint state as hexadecimal integers, so they can be compared byte for byte.
Circuits
A layer on qubits is: a Cayley rotation on every qubit (axis and drawn from , scales from 5 to 34), then on about a quarter of the qubits and on another quarter, then a CNOT ladder on alternating pairs. The circuits come from a fixed SplitMix64 seed and are prefix-consistent, so one run produces every checkpoint (1, 2, 3, 4, 6, 8, …, 3,072, 4,096 layers). Every simulator reads the same circuit.
The float simulators and how their error is measured
The float side is PyTorch state-vector simulation in complex64 and complex128, the same circuits, on CPUs and GPUs. Gate entries are built two ways: rational (the entries and , one correctly rounded division in the working precision) and trig (the textbook route: , then and by PyTorch in the working precision on the device). uses PyTorch's in the working precision (correctly rounded on Graviton4, one ulp low on the Xeon; see Results). Nothing renormalises the state.
Every float number is an exact dyadic rational, so the error of a float state against the exact ray can itself be computed exactly, with integers only:
- fidelity error: the Hermitian spread between the exact ray and the float state , an exact rational;
- probability error: , reading Born probabilities off the float state as a float user would;
- norm drift: .
At 16–28 qubits no exact reference is feasible, so three references that need none are used: norm drift (summed in double-double, exact products and compensated sums, so the measurement adds no error); mirror circuits (the circuit, then its exact inverse with and , whose exact output is , so the spread from it is , computed without cancellation); and the spread between the complex64 and complex128 states of the same run. Bit identity is checked with the SHA-256 of the raw state bytes.
Machines and software
Exact runs on Intel Xeon and AWS Graviton4 CPUs, single-threaded; float runs with PyTorch on the same CPUs and on an RTX 4090 and an H100. The full machine list and versions are under Reproduction notes.
Results
Every identity, exactly
| check | statement | exact | float64 residual |
|---|---|---|---|
| C1 | 2,000 / 2,000 | 5.7e-16 | |
| C2 | ; spread in , turning-invariant | 2,000 / 2,000 | 4.9e-16 |
| C3 | on the unit circle, , inverse ; Riptide's rational-quantum library agrees | 2,000 / 2,000 | 3.3e-16 |
| C4 | (float side via atan, cos, sin) | 1,997 / 1,997 | 8.7e-16 |
| C5 | , (float side ) | 500 / 500 | 2.9e-15 |
| C6 | Möbius maps over keep cross-ratios; composition; Cayley transform | 2,000 / 2,000 | 4.1e-14 |
| C7 | inverse stereographic projection on , and back | 2,000 / 2,000 | 2.2e-16 |
| C8 | Hopf map on , constant on rational fibres, = stereographic image of | 2,000 / 2,000 | 2.2e-16 |
| C9 | Born rule , | 2,000 / 2,000 | 0 |
| C10 | , , Bloch spread | 2,000 / 2,000 | 6.6e-13 |
| C11 | = Lagrange sum of minor quadrances (dims 2, 3, 4, 5, 8); unitarily invariant | 1,000 / 1,000 | 1.9e-14 |
| C12 | Cayley transform unitary, invertible, (dims 2–4); single-qubit closed form | 300 / 300 (+600 / 600) | 1.9e-15 |
| C13 | Pauli products | 9 / 9 | 0 |
| C14 | quaternions: , multiplicative, rational orthogonal, conjugation | 2,000 / 2,000 | 2.2e-16 |
| C15 | a Cayley spin stepper from Riptide's rational-quantum library: 30 Cayley steps keep and exactly | 40 / 40 | 0 |
| C16 | complexified circle over , , , ; the example | 2,000 / 2,000 | 2.8e-14 |
The float column is the same formula evaluated in binary64. Most residuals are a few units of rounding. Two are larger, and both come from cancellation: C10 computes by subtracting two numbers near 1 (6.6e-13 relative), and C6 compares cross-ratios after a Möbius map (4.1e-14). The Lagrange form of in C11 avoids that cancellation. SymPy checked 23 statements symbolically (22 identities and the evaluation of Wildberger's example), including the general Cayley transform, Euler's four-square identity, the cross-ratio invariance and the three complexified-circle identities.
What exact simulation costs


| qubits | Raya: deepest checkpoint | time | Python: deepest checkpoint | time | bits per component |
|---|---|---|---|---|---|
| 2 | 4,096 | 1.0 s | 1,024 | < 0.1 s | 27,891 |
| 4 | 4,096 | 12 s | 1,024 | 0.2 s | 56,792 |
| 6 | 4,096 | 1.7 min | 1,024 | 1.0 s | 85,551 |
| 8 | 4,096 | 12 min | 1,024 | 7.1 s | 114,841 |
| 10 | 4,096 | 78 min | 4,096 | 10.5 min | 143,373 |
| 12 | 2,048 (cap) | 1.9 h | 4,096 | 63 min | 172,483 |
| 14 | 1,024 (cap) | 2.6 h | 2,048 (cap) | 1.5 h | 100,701 at 2,048 |
Three things show up in these runs. The state grows by about 3.5 bits per qubit per layer (35 bits per layer at 10 qubits): one rotation per qubit multiplies each amplitude by a numerator of size (5–34), and little cancels (about 15% below the no-cancellation estimate). Dividing out the integer content at checkpoints removed about 5% of the bits. The projective half-angle form, the numerator of the half rotation, gives the same rays with half the bits. Its matrix, though, is rational only up to the scale .
Python's integers were 6 times faster than Raya's for this workload: 7.1 s against 44.7 s for 8 qubits at 1,024 layers (see the next section). Both implementations produced byte-identical states at every common checkpoint. All 24 checkpoints of the 10-qubit run match between Raya on the Xeon and Python on the second Xeon; all 100 state files written by both implementations on the Xeon match; and all 60 state files written by Raya on both the Xeon and Graviton4 match.
Float simulators against the exact answer


| machine | type, gates | spread at 1,024 | spread at 4,096 | probability at 4,096 | drift at 4,096 |
|---|---|---|---|---|---|
| Xeon 8488C | complex64, rational | 1.80e-11 | 7.46e-11 | 8.59e-07 | +1.48e-04 |
| Xeon 8488C | complex64, trig | 2.17e-11 | 8.22e-11 | 6.77e-07 | −1.14e-04 |
| Xeon 8488C | complex128, rational | 6.77e-29 | 2.65e-28 | 3.70e-15 | −6.86e-13 |
| Xeon 8488C | complex128, trig | 9.97e-29 | 3.86e-28 | 1.55e-14 | −2.79e-12 |
| Graviton4 | complex128, rational | 6.60e-29 | 2.68e-28 | 1.41e-14 | +2.53e-12 |
| RTX 4090 | complex64, rational | 1.80e-11 | 7.25e-11 | 7.17e-07 | +1.36e-04 |
| RTX 4090 | complex128, rational | 6.60e-29 | 2.68e-28 | 1.41e-14 | +2.53e-12 |
| H100 | complex64, trig | 2.06e-11 | 8.00e-11 | 2.22e-06 | +4.01e-04 |
| H100 | complex128, rational | 6.50e-29 | 2.52e-28 | 3.75e-15 | −6.83e-13 |
| H100 | complex128, trig | 8.43e-29 | 3.36e-28 | 1.28e-14 | −2.30e-12 |

The fidelity error grows linearly with depth: about per layer for complex64 and per layer for complex128 at 10 qubits. That is the signature of independent rounding errors adding up in amplitude like a random walk, since a spread is a squared quantity. Over the 8 seeds at 10 qubits and 4,096 layers the median was (complex64) and (complex128), and no seed was more than 1.3 times the median. In plain numbers, complex128 keeps the direction of the state to about 14 significant digits after 4,096 layers. For circuits like these it is accurate, and exact arithmetic adds no accuracy that matters for physics. What exact arithmetic adds is the ability to measure that error at all, exactly.
Norm drift is a far larger error than the fidelity error: against for complex64. The float state keeps its direction (its ray) much better than its length. Reading probabilities as , the projective Born rule, removes the drift term.

Gate entries built the textbook way, and , carry one or two ulps of error on some entries. Entries from the rational division are correctly rounded every time. Over 8 seeds at 10 qubits and 4,096 layers, the trig entries gave a 1.13× (complex64) and 1.45× (complex128) larger fidelity error, and on the Xeon a 4× larger complex128 norm drift and Born-probability error. On Graviton4 and the RTX 4090 the drift ratio reverses (0.17× and 0.36× at 10 qubits), because their errs in the other direction and partly cancels the trig entries' quadrance error. The rotation is the same in both cases; the only difference is where its cosine and sine come from.
Why the norm drifts


Every float rotation in these simulators has the form , and exactly. So each gate scales the state's quadrance by the exact rational of its rounded entries, and scales it by with the rounded . Multiplying those exact quadrances, and modelling no other rounding, predicts the measured complex128 drift to within 2.1% at the deepest checkpoint (4,096 layers, or 1,024 at 20 qubits) of all 11 modelled complex128 runs, all on the Xeon: the drift comes from gates that are slightly non-unitary, not from the arithmetic of applying them. For complex64 the same model is right in sign and order of magnitude (0.66–1.81× the measurement), because float32 accumulation adds rounding of the same size.
This also explains why the complex128 drift had opposite signs on different machines. PyTorch 2.15.0's CPU build returned on the Xeon 8488C, one ulp below the correctly rounded value. On Graviton4 it returned the correctly rounded . The exact quadrance of one is on the Xeon and on Graviton4. With about a quarter of the qubits receiving in every layer, that one ulp sets the sign and most of the size of the complex128 drift. The GPU pods built their gate entries on their own host CPUs. From the sign and size of the drift, the H100 pod matched the Xeon value; the bit-identity results below show the RTX 4090 pod matched Graviton4. The host CPU model was not recorded.
16 to 28 qubits: references without an exact state
| qubits | layers | spread c64 vs c128 | drift c64 | drift c128, RTX 4090 / H100 | time RTX 4090 | time H100 |
|---|---|---|---|---|---|---|
| 20 | 4,096 | 1.42e-10 | 2.72e-04 | +5.06e-12 / −1.40e-12 | 25 s | 15 s |
| 24 | 1,024 | 4.25e-11 | 8.14e-05 | +1.51e-12 / −4.43e-13 | 129 s | 48 s |
| 26 | 512 | 2.30e-11 | 4.56e-05 | +8.11e-13 / −2.42e-13 | 294 s | 114 s |
| 28 | 256 | 1.23e-11 | 2.69e-05 | +4.41e-13 / −1.10e-13 | 683 s | 289 s |


Mirror circuits gave a reference at every size. At 28 qubits with 64 forward and 64 inverse layers, the weight off was in complex64 and in complex128, the same on both GPUs. At 20 qubits and 1,024 + 1,024 layers it was and . These numbers grow linearly with depth and only slowly with width, as the exact comparison at 4–10 qubits does. That supports extrapolating the small exact comparisons to the large float runs.
Bit identity

Repeating a run on the same machine gave the same bytes every time, on the three machines where runs were repeated (Xeon, RTX 4090, H100). Across machines the float states differed. In complex64 the two GPUs agreed with each other but not with either CPU, and the two CPUs disagreed with each other. In complex128 with rational gate entries the RTX 4090 agreed with Graviton4, and the H100 with neither (with trig entries all four differed): that is the difference above, together with differences in how products and sums are fused. The exact states had one answer everywhere: the same bytes from Raya on Xeon and Graviton4 and from Python.
Limitations and next steps
The limits of these results, each with its cause and, where one is planned, the next step.
- Exact simulation is far slower than float simulation. The size of each of the amplitudes grows linearly with depth × width, and the work per layer grows with the state size, so total cost grows like . The exact runs reached 10–14 qubits and a few thousand layers in hours; the float runs at 28 qubits and 256 layers took 5 minutes on an H100. Cause: the number of digits an exact ray needs, measured in Figure 21. Exact arithmetic is a reference and a measuring instrument in this paper, not a faster way to simulate.
- Raya's big-integer arithmetic was 6 times slower than CPython's on the exact simulator (7.1 s against 44.7 s, 8 qubits × 1,024 layers), so the deepest 12- and 14-qubit runs came from the Python implementation. Cause: under investigation.
- **Not every gate is rational over .** and T need . is kept exact by carrying its as a scalar on the ray, which is legitimate because only rays are physical. A T gate needs the cyclotomic field (, the ring of exact Clifford+T synthesis), or a rational approximation (Figure 18). Rotations by named angles such as π/8 are approximations in this gate set; the rotations used are exact at their own rational parameters.
- Exact is not more accurate physics. For these circuits complex128 keeps the direction of the state to about 14 digits after 4,096 layers. Exact arithmetic gives reference answers and exact error measurements; it does not change physical predictions at this level.
- One family of circuits. Random Cayley-rational rotations with H, S and CNOT ladders: 8 seeds for the spread of errors, one seed elsewhere. Circuits with near-cancelling amplitudes, mid-circuit measurement or noise were not tested.
- Plain PyTorch state vectors as the float baseline, written for this study (one kernel per gate, no fusion). Production simulators such as cuStateVec or Qiskit Aer were not measured; their rounding will differ in detail.
- The GPU pods' host CPUs were not recorded, so which each pod used is inferred from the drift and the bit-identity results, not observed.
Reproduction notes
- Circuits. A SplitMix64 generator with seed 20261130 (seeds 1–8 for the sweep) draws, per layer, one Cayley rotation per qubit (axis X, Y or Z; from ), then H on about a quarter of the qubits and S on another quarter, then CNOTs on pairs on even layers and on odd layers. Qubit is bit of the basis index.
- Exact side. Gaussian-integer state vectors with the gate numerators above; the quadrance carried separately and compared with at every checkpoint; integer content divided out at checkpoints. Any arbitrary-precision integer library reproduces the states byte for byte.
- Float side. PyTorch state vectors with the gate entries described in Method, no renormalisation; norm sums in double-double; mirror circuits with and . Errors against the exact ray computed with integers from the float bits.
- Machines. EC2 instances over SSM only, each with a hard auto-terminate; RunPod pods with a time and dollar watchdog. Every machine was terminated when its lane finished.
Machines and software
| machine | used for |
|---|---|
| Intel Xeon Platinum 8488C, 32 vCPU | Raya + Python exact runs, PyTorch 2.15.0 CPU float runs, SymPy, density, analysis and figures |
| AWS Graviton4, 4 vCPU | Raya exact runs and float runs for cross-architecture identity |
| Intel Xeon and AWS Graviton4 (a second pair) | 8-seed sweep, Python exact frontier at 12–14 qubits, gate-entry check |
| NVIDIA GeForce RTX 4090 24 GB, driver 595.112.07 | PyTorch 2.9.1 (CUDA 12.8) float runs, 4–28 qubits |
| NVIDIA H100 80GB HBM3, driver 595.112.07 | PyTorch 2.9.1 (CUDA 12.8) float runs, 4–28 qubits |
Software: Raya 0.4.0 (Riptide SDK 0.4.0) with Riptide's exact-arithmetic libraries; Python 3.12 with PyTorch 2.15.0 (the +cpu wheel on x86-64, the +cu132 wheel run on the CPU on Graviton4), NumPy 2.5.5, SymPy 1.14.0 and mpmath; PyTorch 2.9.1+cu128 on the GPU pods. Every machine was rented for this work and terminated afterwards; the total cost was about $10 (EC2 about $7.8, RunPod $1.90).
References
- N. J. Wildberger, Divine Proportions: Rational Trigonometry to Universal Geometry, Wild Egg, 2005.
Date and version
Version 1.2, 30 November 2026. All measurements from 30 November 2026. Updated 1 December 2026: limitations section retitled.
Working with Riptide
Riptide works with a small number of teams. Each engagement starts with 4 weeks inside your systems, learning how your models, data and infrastructure work. Only then does Riptide apply its software to them. Contact samario@riptidecompute.com or riptidecompute.com/evaluate.