SkillAgentSearch skills...

Geonum

geometric number library supporting unlimited dimensions with O(1) complexity

Install / Use

/learn @mxfactorial/Geonum

README

<br> <p align="center"><img width="225" alt="dual" src="shield.gif"></p> <br> <p align="center">scaling scientific computing with the <a href="https://gist.github.com/mxfactorial/c151619d22ef6603a557dbf370864085" target="_blank">geometric number</a> spec</p> <div align="center">

build docs dependency status crates.io Discord contribute

</div>

geonum

removing an explicit angle from numbers in the name of "pure" math throws away primitive geometric information

once you amputate the angle from a number to create a "scalar", you throw away its compass

computing angles when they deserve to be static forces math into a cave where numbers must be cast from linearly combined shadows

you start by creating a massive artificial "scalar" superstructure of "dimensions" to store every possible position where your scalar vector component can appear—and as a "linear combination" of the dimensions it "spans" with other scalars called "basis vectors"

this brute force scalar alchemy explodes into scalars everywhere

with most requiring "sparsity" to conceal how many explicit zeros appear declaring nothing changed

the omission of geometry is so extreme at this point its suspicious

now your number must hobble through a prison of complicated "matrix" and "tensor" operations computing expensive dot & cross products in a scalar-dimension chain gang with other "linearly independent" scalars—only to reconstruct the simple detail of the direction its facing

and if you want to change its rate of motion, it must freeze all other scalar dimensions in a "partial derivative" with even more zeros

protect your numbers

setting a metric with euclidean and squared norms between "linearly combined scalars" creates an n-dimensional, rank-k (n^k) component orthogonality search problem for transforming vectors

and supporting traditional geometric algebra operations requires 2^n components to represent multivectors in n dimensions

geonum reduces n^k(2^n) to 2

geonum dualizes (⋆) components inside algebra's most general form

setting the metric from the quadrature's bivector shields it from entropy with the log2(4) bit minimum:

  • 1 scalar, cos(θ)
  • 2 vector, sin(θ)cos(φ), sin(θ)sin(φ)
  • 1 bivector, sin(θ+π/2) = cos(θ)
/// dimension-free, geometric number
struct Geonum {
    magnitude: f64,   // multiply
    angle: Angle {    // add
        blade: usize,    // π/2 rotation count
        t: f64           // tan(θ/2) blade projection ratio
    }
}
  • project(onto: Angle) -> angle_diff.cos() into any dimension without defining it first
  • dual() = blade + 2, duality operation adds π rotation and involutively maps grades (0 ↔ 2, 1 ↔ 3)
  • grade() = blade % 4, geometric grade
  • differentiate() = angle + π/2, polynomial coefficients computed from sin(θ+π/2) = cos(θ) quadrature identity
  • replaces "pseudoscalar" with blade arithmetic

how dimensions work

dimensions = blade, how many dimensions the angle spans

traditional: dimensions are coordinate axes - you stack more coordinates

Geonum: dimensions are rotational states - you rotate by π/2 increments

| dimension | traditional | Geonum | | --------- | ------------ | ------------------- | | 1D | (x) | [magnitude, 0] | | 2D | (x, y) | [magnitude, π/2] | | 3D | (x, y, z) | [magnitude, π] | | 4D | (x, y, z, w) | [magnitude, 3π/2] |

geometric numbers break numbers free from pencil & paper math requiring everything to be described as scalars and roman numeral stacked arrays of scalars

a bladed angle lets them travel and transform freely without ever needing to know which dimension theyre in or facing

use

cargo add geonum

example

draw points and lines from one angle — dimension free

use geonum::*;

let origin = Geonum::new(5.0, 0.0, 1.0);

// target angles
let a0 = Angle::new(1.0, 6.0);  // π/6
let a1 = Angle::new(1.0, 3.0);  // π/3
let a2 = Angle::new(1.0, 2.0);  // π/2
let a3 = Angle::new(2.0, 3.0);  // 2π/3

// project onto angles — the projection IS the line between points
let line_to_p0 = origin.angle.project(a0);
let p0 = Geonum::new_with_angle(origin.mag * line_to_p0, a0);

let line_to_p1 = p0.angle.project(a1);
let p1 = Geonum::new_with_angle(p0.mag * line_to_p1, a1);

let line_to_p2 = p1.angle.project(a2);
let p2 = Geonum::new_with_angle(p1.mag * line_to_p2, a2);

let line_to_p3 = p2.angle.project(a3);
let p3 = Geonum::new_with_angle(p2.mag * line_to_p3, a3);

// every projection is cos(angle_diff)
let step = std::f64::consts::PI / 6.0;
assert!((line_to_p0 - step.cos()).abs() < 1e-10);
assert!((line_to_p1 - step.cos()).abs() < 1e-10);

// lineage: p3 traces back to origin through all projection coefficients
let lineage = origin.mag * line_to_p0 * line_to_p1 * line_to_p2 * line_to_p3;
assert!((p3.mag - lineage).abs() < 1e-10);

// dimension free: project to blade 1_000_000 with same O(1) operation
let a_million = Angle::new_with_blade(1000000, 2.0, 3.0);
let p_million = Geonum::new_with_angle(p3.mag * p3.angle.project(a_million), a_million);
assert!((p_million.mag - p3.mag).abs() < 1e-10);

projection creates dimensional relationships on demand — no basis vectors, no coordinate scaffolding

see tests to learn how geometric numbers unify and simplify mathematical foundations including set theory, category theory and algebraic structures:

❯ ls -1 tests
addition_test.rs
affine_test.rs
algorithms_test.rs
angle_arithmetic_test.rs
arithmetic_test.rs
astrophysics_test.rs
calculus_test.rs
category_theory_test.rs
cga_test.rs
chemistry_test.rs
computer_vision_test.rs
dimension_test.rs
economics_test.rs
em_field_theory_test.rs
fem_test.rs
finance_test.rs
linear_algebra_test.rs
machine_learning_test.rs
mechanics_test.rs
ml_attention_test.rs
ml_training_test.rs
monetary_policy_test.rs
motion_laws_test.rs
multivector_test.rs
numbers_test.rs
optics_test.rs
optimization_test.rs
pga_test.rs
qm_test.rs
rendering_test.rs
robotics_test.rs
set_theory_test.rs
tensor_test.rs
trigonometry_test.rs

benches

tensor operations: O(n³) vs O(1)

| implementation | size | time | speedup | | -------------- | ---- | ------- | -------- | | tensor (O(n³)) | 2 | 372 ns | baseline | | tensor (O(n³)) | 3 | 836 ns | baseline | | tensor (O(n³)) | 4 | 1.47 µs | baseline | | tensor (O(n³)) | 8 | 7.80 µs | baseline | | geonum (O(1)) | all | 15 ns | 25-520× |

geonum achieves constant 15ns regardless of size, while tensor operations scale cubically from 372ns to 7.80µs

extreme dimensions

| implementation | dimensions | time | storage | | -------------- | ---------- | ---------- | -------------------------- | | traditional GA | 10 | 7.18 µs | 2^10 = 1024 components | | traditional GA | 30+ | impossible | 2^30 = 1B+ components | | traditional GA | 1000+ | impossible | 2^1000 > atoms in universe | | geonum | 10 | 35 ns | 2 values | | geonum | 30 | 34 ns | 2 values | | geonum | 1000 | 35 ns | 2 values | | geonum | 1,000,000 | 35 ns | 2 values |

geonum enables million-dimensional geometric algebra with constant-time operations

operation benchmarks

| operation | traditional | geonum | speedup | | ------------------ | ----------------- | ------ | ------------------ | | jacobian (10×10) | 1.42 µs | 23 ns | 62× | | jacobian (100×100) | 102 µs | 23 ns | 4435× | | rotation 2D | 4.9 ns | 5 ns | comparable | | rotation 3D | 20 ns | 20 ns | comparable | | rotation 10D | 173 ns | 21 ns | 8× | | geometric product | decomposition | 18 ns | direct | | wedge product 2D | 2.2 ns | 21 ns | trigonometric | | wedge product 10D | 45 components | 21 ns | constant | | dual operation | pseudoscalar mult | 10 ns | universal | | differentiation | numerical approx | 3 ns | exact π/2 rotation | | inversion | matrix ops | 13 ns | direct reciprocal | | projection | dot products | 12 ns | trigonometric |

all geonum operations maintain constant time regardless of dimension, eliminating exponential scaling of traditional approaches

features

core operations

  • dot product .dot(), wedge product .wedge(), geometric product .geo() and *
  • inverse .inv(), division .div() and /, normalization .normalize()
  • rotations .rotate(), reflections .reflect(), projections .project(), rejections .reject()
  • scale .scale(), scale-rotate .scale_rotate(), negate .negate()
  • differentiation .differentiate() via π/2 rotation, integration .integrate() via -π/2 rotation
  • meet .meet() for subspace intersection with geonum's π-rotation incidence structure
  • orthogonality test .is_orthogonal(), distance .distance_to(), magnitude difference .mag_diff()

angle-blade architecture

  • blade count tracks π/2 rotations: 0→scalar, 1→vector, 2→bivector, 3→trivec

Related Skills

View on GitHub
GitHub Stars18
CategoryCustomer
Updated8d ago
Forks3

Languages

Rust

Security Score

95/100

Audited on Mar 21, 2026

No findings