r/Physics • • 1h ago

Question Can computational physics replace float32/float64 with exact rational and integer arithmetic to eliminate drift and guarantee conservation laws?

Hi everyone,

In computational physics, orbital mechanics, climate modeling, and fluid dynamics, we almost universally rely on IEEE-754 floating-point numbers (float32 and float64). While floats are convenient, they are inherently approximate: over multi-century orbital integrations or millions of fluid time steps, tiny rounding errors, subtractive cancellation, and hardware discrepancies accumulate—leading to silent drift, artificial mass or energy loss, and trajectories that diverge between CPUs and GPUs.

I have been exploring whether we can eliminate this drift at the mathematical foundation by rebuilding physical models purely on exact integer and rational arithmetic instead of floats. In my framework (UNIQUANT), I tested this across several physics and numerical domains (and machine-verified the core conservation and error-bound theorems in Lean 4):

  • Timekeeping & Orbital Cycles: Defining an exact rational time quantum (q = 75/1012 s), 529-year (23^2) anchor cycles, bounded quadratic lunar stepping, and 299 = 13 × 23 rational phase lattices where specific oscillatory modes vanish identically.
  • Observer Geometry & Reference Frames: Deriving exact zero-point apparent accelerations (-2 * kappa * v^2 / (1 + kappa * r)^3), orthonormal three-anchor reference triads with full SO(3) rotational invariance, and spatial correlation bias (N_eff < N) in distributed sensor networks.
  • Hydrodynamics & PDE Solvers: Replacing floating-point updates with backlog-free integer volume ledgers, cancellation-free trapezoidal channel geometry, tridiagonal M-matrix integer solvers with certified L_infinity error bounds, and overflow-free 128/256-bit multi-limb arithmetic for bit-exact CPU/CUDA execution.

My questions for the computational physicists here:

  1. Where do you see the practical limits of pure integer/rational arithmetic in large-scale physical simulations (e.g., strongly nonlinear PDEs or turbulence) before denominator growth or multi-limb overhead becomes prohibitive?
  2. Have you encountered cases in your own work where floating-point drift or CPU/GPU non-associativity caused real physical artifacts that required rethinking the underlying arithmetic?

For anyone interested in the derivations or the Lean 4 proofs, the code and repositories are here:

0 Upvotes

7 comments sorted by

9

u/StudyBio 55m ago

Are rational numbers not also inherently approximate if your simulation involves pi, or trig functions, etc.?

4

u/BitcoinsOnDVD 47m ago

Stop coping! It's Lean formalized! LEEEAAAAAN!!! /s

3

u/StudyBio 31m ago

Lean formalization, known for its widespread use by computational physicists

1

u/BitcoinsOnDVD 27m ago

LEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAN!!!!!!!

5

u/Banes_Addiction Particle physics 46m ago edited 36m ago

I am not a computational physicist but I have quite a bit of experience with complex calculations for particle physics.

And I have never wanted an analytical rational number instead of a float.

Everything in science is about checking your assumptions and calculating your uncertainties. So if you are doing a calculation you have to actually demonstrate that the way you are doing the calculation works, and exactly how well it works.

Sometimes, yeah, you find a calculation you need to reorder or something to make it work. But you never need a systematic uncertainty on the numerical precision. If you did your job right, numerical precision should be a tiny fraction of your other uncertainties. And if it's not, you find a way to fix your calculation.

Float32 is accurate to around 7dp. That's not really enough. Float64 is accurate to 16fp. That usually is. And 128 bit is just available too. I have literally never seen a problem where the clever solution was using 128 bits. It's always making your calculation do something cleverer.

So I have sort of a moral objection to this, because in theory it prevents the need to actually check your work, which you still have to do anyway.

Have you encountered cases in your own work where floating-point drift or CPU/GPU non-associativity caused real physical artifacts that required rethinking the underlying arithmetic? 

I have seen problems where numerical precision just absolutely wrecked a calculation that seemed like it should work. And the solution was just reordering the operations. Not throwing away the concept of floating point numbers, which work really well.

I once flamed a senior scientist in a real meeting for presenting something like this. "here are my assumptions in my calculation" and it had "AMD x86_64 processor" in it as like an offhand comment. Sorry, uh, what do you mean your answer depends on the CPU manufacturer? That means it's wrong. Do you literally want us to have to put out a result out and tell me we had to put an uncertainty on whether we run it on your laptop or mine?"

1

u/formula_translator Atomic physics 18m ago

I have literally never seen a problem where the clever solution was using 128 bits.

I’ve seen people use them when doing linear algebra with very nearly linearly dependent basis vectors. Whether that is smart? Well ..,

1

u/tpolakov1 Condensed matter physics 26m ago

Lol, the brainlets will now now tell on themselves with Lean. LMAO, even.