---
title: "onemath"
url: https://recursiveai.org/onemath/
description: "Deterministic math for .NET in C#. Vectors, matrices and quaternions, correctly rounded sin, exp, log and pow, exact geometric predicates and a fixed-point bridge, with the same bits on every OS, CPU, runtime and thread count. MIT or Apache-2.0."
---

# 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.

```sh
dotnet add package RecursiveAI.OneMath
```

- [Getting started](https://recursiveai.org/onemath/docs/getting-started/)
- [Docs](https://recursiveai.org/onemath/docs/)
- [Cookbook](https://recursiveai.org/onemath/cookbook/)
- [GitHub](https://github.com/recursive-ai-oss/onemath-csharp)
- [NuGet](https://www.nuget.org/packages/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](https://recursiveai.org/onemath/docs/getting-started/)

*Program.cs · C#*

```
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
```

### 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.

## 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.

- [Hash matrix](https://recursiveai.org/onemath/docs/hash-matrix/)
- [How rounding is checked](https://recursiveai.org/onemath/docs/functions/)

## The package

- **RecursiveAI.OneMath**: Types, functions, predicates, the fixed-point bridge and physics math. No dependency beyond the .NET base class library. 1.0.0.
- **Matrices**: Column vectors, the opposite of System.Numerics. `FromSystemNumerics` and `ToSystemNumerics` convert both ways.
- **Speed**: Correct rounding costs time. In informal single-thread measurements it takes from about 3 times the platform’s `Math` for sin to about 21 times for cosh.
- **Used by**: [onepath](https://recursiveai.org/onepath/) and [onephysics](https://recursiveai.org/onephysics/) build on it.
- **.NET**: .NET 10 on Windows, Linux, macOS and browser WebAssembly. NativeAOT and trimming are supported. MIT or Apache-2.0.

## Go further

- [GitHub](https://github.com/recursive-ai-oss/onemath-csharp)
- [NuGet](https://www.nuget.org/packages/RecursiveAI.OneMath)
- [Getting started](https://recursiveai.org/onemath/docs/getting-started/)
- [All docs](https://recursiveai.org/onemath/docs/)
- [Cookbook](https://recursiveai.org/onemath/cookbook/)
- [Exact predicates](https://recursiveai.org/onemath/cookbook/exact-predicates/)
- [From System.Numerics](https://recursiveai.org/onemath/cookbook/port-from-system-numerics/)
- [Changelog](https://github.com/recursive-ai-oss/onemath-csharp/blob/v1.0.0/CHANGELOG.md)
