Why change the arithmetic?

In the p-adic metric, numbers are close when the low-order digits of their expansions agree. This gives computation a different geometry: the p-adic norm of a sum cannot exceed the largest norm of its summands.

This property motivates investigating ways to control the growth of intermediate values, including gradients. But derivatives also need restrictions: changing the numerical type alone does not guarantee stability. A bounded p-adic norm does not imply a bounded reconstructed real value, either. Controlling exploding gradients is a motivation for this work; the experiment tests the more basic requirement of arithmetic-module compatibility with the original model.

A minimal test

The proposed module converts inputs and fitted coefficients to p-adic representations, performs the computation, and reconstructs a rational output. The data and the surrounding system should retain their original format.

I fitted a one-feature linear regression on the scikit-learn Diabetes dataset, using feature index 2 and the last 20 observations as the test set. The baseline achieved MSE 2548.07 and R² = 0.47. These metrics describe the original regression; the central experimental criterion is whether reconstructed outputs agree with its predictions.

The main pyAdic experiment used p = 2, precision 50, and an absolute tolerance of 10⁻⁶. Successfully reconstructed predictions: 0 of 20.

Baseline linear regression and rational reconstruction results for the 20 test observations
The baseline regression and a verification run with pyAdic (p = 2, precision 50). None of the 20 predictions was reconstructed within the absolute tolerance of 10⁻⁶.

Where the results diverged

TestObservation
pyAdic and linear regressionMost displayed reconstructions returned False instead of a rational number; the remaining outputs did not reproduce the baseline predictions.
Varying precisionReconstructed values changed substantially, sometimes changing sign.
SageMath, 80 significant p-adic digitsForward conversion succeeded, but reconstructed predictions differed from the baseline.
Reversing digit orderOrdinary addition failed to preserve the correspondence because of the direction of carry propagation.

The discrepancy appeared even without regression: converting 0.04716281 to a p-adic representation and back in pyAdic, with p = 2 and absolute precision 40, produced a value with a different sign and order of magnitude.

A finite p-adic approximation does not uniquely determine a rational number without additional restrictions. Representing an input float as an exact fraction can also require a large numerator and denominator. Precision and reconstruction conditions therefore form part of the module’s design.

What the result establishes

For the tested implementations and settings, the conversion–computation–reconstruction pipeline failed to preserve even a linear model’s outputs. It does not yet provide a compatible module for a more complex neural network.

This conclusion concerns the tested integration scheme and does not extend to all p-adic machine-learning methods. Further directions include data and operations defined over a p-adic field from the outset, explicit reconstruction guarantees, and selecting the prime p and precision against a stated criterion. A neural-network formulation would also need an architecture, a loss function, and weight-update rules.