Skip to content

mxfactorial/geonum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


dual


scaling scientific computing with the geometric number spec

build docs dependency status crates.io Discord contribute

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", youve thrown away its compass and condemned it to hobble through a mountain of "scalars" known as "matrix" and "tensor" operations—where every step requires expensive dot & cross product computations to reconstruct the simple detail of which direction your number is facing

setting a metric with euclidean and squared norms between "scalars" creates a k^n component orthogonality search problem for transforming vectors

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

geonum reduces k^n(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(θ)
/// a geometric number
struct Geonum {
    length: f64,      // multiply
    angle: Angle {    // add
        blade: usize,     // counts π/2 rotations and enables projection
        value: f64        // angle within current π/2 segment [0, π/2)
    }
}

use

cargo add geonum

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

benches

rank-3 tensor comparison

implementation size time
tensor (O(n³)) 2 1.01 µs
tensor (O(n³)) 3 2.29 µs
tensor (O(n³)) 4 4.04 µs
tensor (O(n³)) 8 8.50 µs
tensor (O(n³)) 16 71.33 µs
geonum (O(1)) any 19.73 ns

geonum achieves constant O(1) time complexity regardless of problem size, 205× faster than tensor operations at size 4 and 3615× faster at size 16, eliminating cubic scaling of traditional tensor implementations

extreme dimension comparison

implementation dimensions time storage complexity
traditional ga 10 682.87 ns (partial) O(2^n) = 1024 components
traditional ga 30 theoretical only O(2^n) = 1 billion+ components
traditional ga 1000 impossible O(2^1000) ≈ 10^301 components
traditional ga 1,000,000 impossible O(2^1000000) components
geonum (O(1)) 10 37.53 ns O(1) = 2 components
geonum (O(1)) 30 38.67 ns O(1) = 2 components
geonum (O(1)) 1000 37.73 ns O(1) = 2 components
geonum (O(1)) 1,000,000 37.29 ns O(1) = 2 components

geonum enables geometric algebra in million-dimensional spaces with constant time operations, achieving whats physically impossible with traditional implementations (requires more storage than atoms in the universe)

multivector ops

operation dimensions time traditional ga complexity
grade extraction 1,000,000 158.80 ns O(2^n)
grade involution 1,000,000 167.10 ns O(2^n)
clifford conjugate 1,000,000 99.35 ns O(2^n)
contractions 1,000,000 275.60 ns O(2^n)
anti-commutator 1,000,000 165.84 ns O(2^n)
all ops combined 1,000 732.82 ns impossible at high dimensions

geonum performs all major multivector operations with exceptional efficiency in million-dimensional spaces, maintaining sub-microsecond performance for grade-specific operations that would require exponential time and memory in traditional geometric algebra implementations

features

  • dot product, wedge product, geometric product
  • inverse, division, normalization
  • million-dimension geometric algebra with O(1) complexity
  • conformal geometric algebra without 32-component vectors
  • projective geometric algebra without homogeneous coordinates
  • multivector support and trivector operations
  • rotations, reflections, projections, rejections
  • exponential, interior product, dual operations
  • meet and join, commutator product, sandwich product
  • left-contraction, right-contraction
  • anti-commutator product
  • grade involution and clifford conjugate
  • grade extraction
  • duality operations without pseudoscalars (blade arithmetic replaces I = e₁∧...∧eₙ)
  • square root operation for multivectors
  • undual operation (complement to the dual operation)
  • regressive product (alternative method for computing the meet of subspaces)
  • automatic differentiation through angle rotation (v' = [r, θ + π/2]) (differential geometric calculus)
  • replaces category theory abstractions with angle relationships
  • unifies discrete and continuous operations through angle arithmetic
  • eliminates abstract mathematical formalism with geometric operations
  • enables scaling precision in statistical modeling through direct angle quantization
  • supports time evolution via simple angle rotation (angle += energy * time)
  • provides statistical methods for angle distributions (arithmetic/circular means, variance, expectation values)
  • enables O(1) machine learning operations that would otherwise require O(n²) or O(2^n) complexity
  • implements perceptron learning, regression modeling, neural networks and activation functions
  • replaces tensor-based neural network operations with direct angle transformations
  • enables scaling to millions of dimensions with constant-time ML computations
  • eliminates the "orthogonality search" bottleneck in traditional tensor based machine learning implementations
  • manifold navigation through angle-encoded paths
  • optical transformations via direct angle operations (refraction, aberration, OTF)
  • Manifold trait for collection operations with lens-like path transformations

tests

cargo 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

eli5

geometric numbers depend on 2 rules:

  1. all numbers require a 2 component minimum:
    1. length number
    2. angle radian
  2. angles add, lengths multiply

so:

  • a 1d number or scalar: [4, 0]
    • 4 units long facing 0 radians
  • a 2d number or vector: [[4, 0], [4, pi/2]]
    • one component 4 units at 0 radians
    • one component 4 units at pi/2 radians
  • a 3d number: [[4, 0], [4, pi/2], [4, pi]]
    • one component 4 units at 0 radians
    • one component 4 units at pi/2 radians
    • one component 4 units at pi radians

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 lengths:

  • [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

learn with ai

  1. install rust: https://www.rust-lang.org/tools/install
  2. create an api key with anthropic: https://console.anthropic.com/
  3. purchase api credit
  4. install claude code
  5. clone the geonum repo: git clone https://github.com/mxfactorial/geonum
  6. change your current working directory to geonum: cd geonum
  7. start claude from the geonum directory: claude
  8. configure claude with your api key
  9. supply it this series of prompts:
    read README.md
    
    read the math-1-0.md geometric number spec
    
    read tests/numbers_test.rs
    
    read tests/dimension_test.rs
    
    read tests/machine_learning_test.rs
    
    read tests/em_field_theory_test.rs
    
    run 'grep "pub fn" ./src/angle.rs' to learn the angle module
    
    run 'grep "pub fn" ./src/geonum_mod.rs' to learn the geonum module
    
    now run 'touch tests/my_test.rs'
    
    import geonum in tests/my_test.rs with use geonum::*;
    
  10. describe the test you want the agent to implement for you while using the other test suites and library as a reference
  11. execute your test: cargo test --test my_test -- --show-output
  12. revise and add tests
  13. ask the agent to summarize your tests and how they benefit from angle-based complexity
  14. ask the agent more questions:
    • what does the math in the leading readme section mean?
    • how does the geometric number spec in math-1-0.md improve computing performance?
    • what is the tests/tensor_test.rs file about?