| Crates.io | geonum |
| lib.rs | geonum |
| version | 0.10.0 |
| created_at | 2025-03-29 23:09:32.361238+00 |
| updated_at | 2025-12-10 20:18:57.840718+00 |
| description | geometric number library supporting unlimited dimensions with O(1) complexity |
| homepage | |
| repository | https://github.com/mxfactorial/geonum |
| max_upload_size | |
| id | 1611819 |
| size | 1,913,994 |

scaling scientific computing with the geometric number spec
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
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:
cos(θ)sin(θ)cos(φ), sin(θ)sin(φ)sin(θ+π/2) = cos(θ)/// dimension-free, geometric number
struct Geonum {
magnitude: f64, // multiply
angle: Angle { // add
blade: usize, // counts π/2 rotations
remainder: f64 // current [0, π/2) angle
}
}
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
cargo add geonum
compute components and magnitude with angle.project — dimension free
use geonum::*;
// origin is an angle
let origin = Angle::new(0.0, 1.0);
// endpoint 7 at pi/6 from origin phase
let end_angle = origin + Angle::new(1.0, 6.0);
let end = Geonum::new_with_angle(7.0, end_angle);
// init axes to assert traditional math:
let ex = Angle::new(0.0, 1.0);
let ey = Angle::new(1.0, 2.0); // +pi/2
// compute projections via angle.project
let px = end.mag * end_angle.project(ex); // 7·cos
let py = end.mag * end_angle.project(ey); // 7·sin
// quadratic identity: px² + py² = L²
assert!(((px * px + py * py) - end.mag * end.mag).abs() < 1e-12);
// dimension free: blade 1 vs 1_000_001 identical
let p_small = end.mag * end_angle.project(Angle::new(1.0, 2.0));
let p_huge = end.mag * end_angle.project(Angle::new(1_000_001.0, 2.0));
assert!((p_small - p_huge).abs() < 1e-12);
rotation creates dimensional relationships on demand - no coordinate system scaffolding required
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
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
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
robotics_test.rs
set_theory_test.rs
tensor_test.rs
trigonometry_test.rs
| implementation | size | time | speedup |
|---|---|---|---|
| tensor (O(n³)) | 2 | 342 ns | baseline |
| tensor (O(n³)) | 3 | 772 ns | baseline |
| tensor (O(n³)) | 4 | 1.35 µs | baseline |
| tensor (O(n³)) | 8 | 6.88 µs | baseline |
| geonum (O(1)) | all | 16 ns | 21-430× |
geonum achieves constant 16ns regardless of size, while tensor operations scale cubically from 342ns to 6.88µs
| 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 | 31 ns | 2 values |
| geonum | 30 | 30 ns | 2 values |
| geonum | 1000 | 30 ns | 2 values |
| geonum | 1,000,000 | 30 ns | 2 values |
geonum enables million-dimensional geometric algebra with constant-time operations
| operation | traditional | geonum | speedup |
|---|---|---|---|
| jacobian (10×10) | 1.25 µs | 26 ns | 48× |
| jacobian (100×100) | 91.7 µs | 25 ns | 3668× |
| rotation 2D | 4.3 ns | 37 ns | comparable |
| rotation 3D | 19 ns | 16 ns | 1.2× faster |
| rotation 10D | 160 ns | 19 ns | 8× |
| geometric product | decomposition | 17 ns | direct |
| wedge product 2D | 1.9 ns | 60 ns | trigonometric |
| wedge product 10D | 45 components | 60 ns | constant |
| dual operation | pseudoscalar mult | 10 ns | universal |
| differentiation | numerical approx | 11 ns | exact π/2 rotation |
| inversion | matrix ops | 10 ns | direct reciprocal |
| projection | dot products | 15 ns | trigonometric |
all geonum operations maintain constant time regardless of dimension, eliminating exponential scaling of traditional approaches
.dot(), wedge product .wedge(), geometric product .geo() and *.inv(), division .div() and /, normalization .normalize().rotate(), reflections .reflect(), projections .project(), rejections .reject().scale(), scale-rotate .scale_rotate(), negate .negate().differentiate() via π/2 rotation, integration .integrate() via -π/2 rotation.meet() for subspace intersection with geonum's π-rotation incidence structure.is_orthogonal(), distance .distance_to(), magnitude difference .mag_diff().blade() returns full transformation history, .grade() returns geometric grade.base_angle() resets blade to minimum for grade (memory optimization).increment_blade() and .decrement_blade() for direct blade manipulation.copy_blade() transfers blade structure between geonums.project_to_dimension(n) computes projection to any dimension on demand.create_dimension(length, n) creates standardized n-dimensional basis element.dual() adds π rotation (2 blades), maps grades 0↔2, 1↔3.undual() identical to dual in 4-cycle structure.conjugate() for clifford conjugationGeonum::new(magnitude, pi_radians, divisor) - basic constructorGeonum::new_with_angle(magnitude, angle) - from angle structGeonum::new_from_cartesian(x, y) - from cartesian coordinatesGeonum::new_with_blade(magnitude, blade, pi_radians, divisor) - explicit bladeGeonum::scalar(value) - scalar at grade 0Angle::new(pi_radians, divisor) - angle from π fractionsAngle::new_with_blade(blade, pi_radians, divisor) - angle with blade offsetAngle::new_from_cartesian(x, y) - angle from coordinates.pow(n) for exponentiation preserving angle-magnitude relationship.invert_circle(center, radius) for conformal inversions.is_scalar(), .is_vector(), .is_bivector(), .is_trivector().sin(), .cos(), .tan(), .is_opposite().grade_angle() returns grade-based angle representation in [0, 2π) for external interfacescargo check # compile
cargo fmt --check # format
cargo clippy # lint
cargo test --lib # unit
cargo test --test "*" # feature
cargo test --doc # doc
cargo bench # bench
cargo llvm-cov # coverage
geometric numbers depend on 2 rules:
so:
[4, 0]
[[4, 0], [4, pi/2]]
[[4, 0], [4, pi/2], [4, pi]]
higher dimensions just keep adding components rotated by +pi/2 each time
dimensions are created by rotations and not stacking coordinates
multiplying numbers adds their angles and multiplies their magnitudes:
[2, 0] * [3, pi/2] = [6, pi/2]differentiation is just rotating a number by +pi/2:
[4, 0]' = [4, pi/2][4, pi/2]' = [4, pi][4, pi]' = [4, 3pi/2][4, 3pi/2]' = [4, 2pi] = [4, 0]thats why calculus works automatically and autodiff is o1
and if you spot a blade field in the code, it just counts how many pi/2 turns your angle added
blade = 0 means zero turns
blade = 1 means one pi/2 turn
blade = 2 means two pi/2 turns
etc
blade lets your geometric number index which higher dimensional structure its in without using matrices or tensors:
[4, 0] blade = 0 (initial direction)
|
v
[4, pi/2] blade = 1 (rotated +90 degrees)
|
v
[4, pi] blade = 2 (rotated +180 degrees)
|
v
[4, 3pi/2] blade = 3 (rotated +270 degrees)
|
v
[4, 2pi] blade = 4 (rotated full circle back to start)
each +pi/2 turn rotates your geometric number into the next orthogonal direction
geometric numbers build dimensions by rotating—not stacking
git clone https://github.com/mxfactorial/geonumcd geonumgeonum directory: claude or codexskip CLAUDE.md and AGENTS.md files if youre supplied these "learn with ai" instructions
instead, read these files and tests with parallel agents. do not skip any reading tasks:
core files:
- README.md
- math-1-0.md
- grep "pub fn" ./src/angle.rs
- grep "pub fn" ./src/geonum_mod.rs
test suites:
- tests/numbers_test.rs
- its_a_scalar:8-38
- its_a_vector:39-74
- its_a_real_number:75-110
- its_an_imaginary_number:111-141
- its_a_complex_number:142-176
- its_a_dual_number:177-297
- its_an_octonion:298-343
- its_a_matrix:344-400
- its_a_tensor:401-597
- it_dualizes_log2_geometric_algebra_components:647-682
- its_a_clifford_number:940-1022
- tests/dimension_test.rs
- it_solves_the_exponential_complexity_explosion:520-594
- it_doesnt_need_a_pseudoscalar:595-792
- it_demonstrates_pseudoscalar_elimination_benefits:793-832
- it_proves_dualization_as_angle_ops_compresses_ga:833-898
- it_replaces_k_to_n_minus_k_with_k_to_4_minus_k:899-983
- it_compresses_traditional_ga_grades_to_two_involutive_pairs:1131-1168
- it_proves_rotational_quadrature_expresses_quadratic_forms:1419-1593
- tests/calculus_test.rs
- its_a_limit:40-120
- its_a_derivative:121-166
- its_an_integral:167-218
- it_proves_differentiation_cycles_grades:766-918
- its_a_gradient:312-361
- its_a_divergence:362-412
- its_a_curl:413-455
- its_a_laplacian:503-556
- its_a_line_integral:609-636
- its_a_surface_integral:637-663
- it_proves_fundamental_theorem_is_accumulation_equals_interference:1004-1053
- tests/mechanics_test.rs
- it_changes_kinematic_level_by_cycling_grade:46-195
- it_encodes_velocity:268-323
- it_encodes_acceleration:324-364
- it_encodes_jerk:365-414
- it_encodes_kinetic_energy:959-1046
- it_handles_energy_conservation:1783-1941
- it_handles_momentum_conservation:1942-2052
- it_handles_angular_momentum_conservation:2053-2157
create tests/my_test.rs with use geonum::*;
cargo test --test my_test -- --show-output