Float106 Precision
Relevant source files
The following files were used as context for generating this wiki page:
Float106 (also referred to as DoubleFloat) is a high-precision numerical infrastructure within the DeepCausality project designed for topological physics and advanced tensor calculus. It provides precision beyond the standard f64 limit (~16 decimal digits), reaching approximately 31 decimal digits (106 bits of significand). This is achieved through "Double-Double" arithmetic, representing a number as the unevaluated sum of two f64 values.
The system is critical for mitigating cumulative rounding errors in multi-stage transcendental computations, such as those found in Causaloid evaluations or manifold curvature calculations. By abstracting precision behind algebraic traits, the project allows developers to switch between f32, f64, and Float106 by changing a single type alias, enabling a flexible trade-off between performance and numerical stability.
Sources: openspec/changes/archive/num_float_double_double.md:9-16, examples/mathematics_examples/README.md:46-51
Numerical Architecture
Float106 is implemented as a non-primitive type in the deep_causality_num crate. It utilizes the sum of two 64-bit floats to extend the mantissa while maintaining the same exponent range as f64.
Data Representation
The core structure, DoubleFloat, is 16-byte aligned to facilitate efficient SIMD (Single Instruction, Multiple Data) operations. It is represented as:
$$ x = x_{hi} + x_{lo} $$
where the low component ($x_{lo}$) accounts for the error in the high component ($x_{hi}$), specifically maintaining the invariant $|x_{lo}| \le 0.5 \text{ulp}(x_{hi})$.
Sources: openspec/changes/archive/num_float_double_double.md:20-24, openspec/changes/archive/num_float_double_double.md:120-134
Algebraic Hierarchy
Float106 implements a rigorous algebraic hierarchy, allowing it to function as a RealField within the project's HKT (Higher-Kinded Type) framework. This enables its use in any component requiring field operations, such as tensors, multivectors, and manifolds.
The hierarchy ensures that Float106 integrates seamlessly with deep_causality_tensor and deep_causality_multivector.
Sources: openspec/changes/archive/num_float_double_double.md:27-105
Implementation Logic
The high precision of Float106 is maintained through Error-Free Transformations (EFT). These algorithms ensure that the sum or product of two floating-point numbers is represented exactly by a result and an error term.
Mathematical Algorithms
| Algorithm | Purpose | Logic |
|---|---|---|
| Knuth's TwoSum | Exact Addition | Computes $s = fl(a+b)$ and error $e$ exactly. |
| Dekker's TwoProd | Exact Multiplication | Computes $p = fl(a \cdot b)$ and error $e$ using FMA (Fused Multiply-Add). |
| Iterative Refinement | High-Precision Division | Uses an initial f64 estimate followed by refinement steps to compute the low-order component. |
Sources: openspec/changes/archive/num_float_double_double.md:108-117, openspec/changes/archive/num_float_double_double.md:183-199
Specialized Arithmetic Operations
- Normalization: The
new(hi, lo)constructor normalizes the pair to maintain precision invariants. - Transcendental Functions: Functions like
sin,exp, andlogare implemented using range reduction and Taylor series expansion calibrated for 106-bit precision. - Comparison: Equality and ordering are performed lexicographically, with the
hicomponent dominating.
Sources: openspec/changes/archive/num_float_double_double.md:130-133, openspec/changes/archive/num_float_double_double.md:255-276
Practical Application and Performance
Float106 is not intended as a global replacement for f64 but rather as a targeted tool for workloads where drift accumulation is significant.
Performance Decision Matrix
The project provides a guideline for selecting the appropriate precision based on the workload shape.
| Workload Shape | Recommended Type | Rationale |
|---|---|---|
| Integer/Simple Fractions | f32 or f64 | Float106 costs 3-5x runtime for no accuracy gain. |
| Time-stepping (Heat Eq) | f64 | Error is often damped by the operator. |
| Chained Transcendental | Float106 | Rounding errors amplify across cascaded rotations or boosts. |
| Ill-conditioned Systems | Float106 | Mantissa bits buy back digits lost to high condition numbers. |
Sources: examples/mathematics_examples/README.md:73-100
Precision Drift Comparison
In the capstone_spinor_minkowski example, Float106 demonstrates a significant recovery of precision during parallel transport along a worldline.
The drift is reduced by fifteen orders of magnitude simply by re-aliasing the float type.
Sources: examples/mathematics_examples/README.md:57-65
System Integration
Crate Dependencies
Float106 (DoubleFloat) is primarily housed in deep_causality_num but is consumed across the monorepo:
- deep_causality_tensor: Uses Float106 for CPU-based high-precision contraction.
- deep_causality_multivector: Prevents "catastrophic cancellation" in geometric products.
- deep_causality_topology: Critical for calculating the Riemann Curvature Tensor on manifolds where second derivatives magnify loss.
Sources: openspec/changes/archive/num_float_double_double.md:330-358, AGENTS.md:155-165
Hardware Backend Support
| Backend | Support Level | Implementation Note |
|---|---|---|
| CPU | Full | Natively supported via Vec<DoubleFloat>. |
| MLX (GPU) | Lossy | Downcasts to f32 for GPU operations; precision loss warnings apply. |
Sources: openspec/changes/archive/num_float_double_double.md:333-348
Summary
Float106 Precision provides a necessary numerical buffer for the DeepCausality framework's most demanding physical and mathematical simulations. By utilizing Double-Double arithmetic and Error-Free Transformations, it offers 31 decimal digits of precision while maintaining compatibility with standard f64 structures. While it introduces a performance overhead, its ability to eliminate numerical drift in complex, chained transcendental computations makes it a core infrastructure component for advanced causal reasoning in dynamic systems.
Sources: openspec/changes/archive/num_float_double_double.md:9-16, examples/mathematics_examples/README.md:104-106