Recursive AI
LibraryC#Available

onemath

Deterministic math for .NET. Vectors, matrices, correctly rounded functions and exact predicates that give the same bits on every OS, CPU, runtime and thread count.

dotnet add package RecursiveAI.OneMath

A quick look

The same answer, to the last bit, on x64, arm64 and WebAssembly. That is what keeps lockstep peers, replays and saved games in sync.

Getting started
Program.csC#
using RecursiveAI.OneMath;
using RecursiveAI.OneMath.Predicates;
double s = Math64.Sin(1e300);        // correctly rounded
int side = ExactPredicates.Orient2D(0, 0, 1, 0, 0.5, 1e-10);
long raw = FixedBridge.FromDouble(1.5);   // Q31.32
What it does

What it does

Correctly rounded functions

sin, cos, tan, the inverse functions, exp, log, pow, cbrt, hypot and the hyperbolic functions, in float and double. Each returns the representable number nearest the exact value.

Vectors, matrices, quaternions

Vector, matrix, quaternion, affine, rigid-transform and bounds types in float and double, with the evaluation order of every operation written down.

Exact predicates

Orient2D, Orient3D, InCircle, InSphere and segment classification return the sign of the exact value, so geometry code never contradicts itself.

A fixed-point bridge

Q31.32 raw values to and from double, exact within ±2^21, for hosts that keep world coordinates in fixed point.

Physics math

Inertia tensors of solids and compound bodies, and a symmetric 3x3 eigen decomposition for their principal axes.

Stable across 1.x

No 1.x release changes an existing result. A change that would alter one, even a more accurate one, ships as a new member or waits for 2.0.

How it’s checked

One hash on every platform

A hash matrix runs fixed scenarios and compares their SHA-256 manifests across x64 with and without SIMD, one thread and all cores, NativeAOT, browser WebAssembly and macOS arm64. Each release must also reproduce every line of the previous release’s manifest. Only IEEE + - * / and square root decide a result, and an analyzer bans platform math and fused multiply-add at build time.

The package

Go further