Skip to content

@enumeratio/number-theory ​

Number theory past Z/m\mathbb{Z}/m for @cortex-js/compute-engine, over bigints: Gaussian integers, rational reconstruction, Hermite normal form and integer valuations, plus a sweep of Wolfram heads compute-engine doesn't have (divisor sums, Jacobi/Kronecker/Legendre symbols, Stirling and Bell numbers, Frobenius, …). Builds on @enumeratio/residues (declare that first) and @enumeratio/numerals. Every head answers exactly or stays unevaluated — never approximate.

A handful of compute-engine's own heads (Fibonacci, LucasL, Factorial, GCD, NthPrime, PrimePi) are re-declared here with faster exact algorithms — fast doubling, binary splitting, Lehmer's algorithm, a segmented sieve — for the same results; see the declare-fast-* modules.

Usage ​

ts
import { declareNumberTheory } from "@enumeratio/number-theory";

declareNumberTheory(ce); // declares @enumeratio/residues first if not already declared

./src exports the raw TypeScript entry for a workspace consumer. gaussian is a namespace over the plain Gaussian-integer arithmetic the heads box and unbox; hermiteDecomposition, rationalReconstruction, fibonacci/fibonacciMod/lucasL/lucasLMod are also exported directly.

FactorInteger(360)                          // [[2, 3], [3, 2], [5, 1]]
HermiteDecomposition([[1, 2], [3, 4]])      // the unimodular u and Hermite form h with u·m = h

Heads ​

Primes and factoring

Divisor and multiplicative functions

GCD, modular and symbols

Sequences and combinatorial number theory

Past the integers

See also ​

Builds on @enumeratio/residues (residues) and @enumeratio/numerals (numerals). @enumeratio/adeles (adeles) depends on this package for HermiteDecomposition and extends Fibonacci/LucasL to the profinite integers.

Pages ​