@enumeratio/number-theory
Number theory past 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
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 = hHeads
Primes and factoring
FactorInteger/Divisors— prime factorization and the divisor listIsPrime/IsPrimePower/IsSquareFreeNextPrime/NthPrime/PrimePi
Divisor and multiplicative functions
DivisorSigma/DivisorSum/Totient/CarmichaelLambdaMoebiusMu/MangoldtLambda/LiouvilleLambdaPrimeNu/PrimeOmega— distinct and with-multiplicity prime countsIsPerfect/PerfectNumber/MersennePrimeExponent
GCD, modular and symbols
GCD/LCM/ExtendedGCD/IsCoprimeModularInverse/IntegerExponent/QuotientJacobiSymbol/KroneckerSymbol/LegendreSymbol
Sequences and combinatorial number theory
Fibonacci/LucasL— fast doubling, and continuous on the profinite integers@enumeratio/adelesaddsBellNumber/CatalanNumber/Stirling/StirlingS1/Multinomial/SubfactorialPartitionsQ/SquaresR/PowersRepresentations/RamanujanTauFrobeniusNumber/FrobeniusSolve— the largest non-representable value, and every representation, for a coin-problem instanceEulerEat an integer index
Past the integers
GaussianIntegers— ;PowerMod,PowerModList,GCD,LCM,IntegerExponentandDivisorsall reach into it when an operand is genuinely complexRationalReconstruction— the rational nearest a residue modHermiteDecomposition— unimodular with in Hermite normal form; backs@enumeratio/adeles' strong approximation
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
- Source:
packages/symbols/arithmetic/number-theory - Depends on:
boxes,ce-patches,engine,manifest,numerals,residues,structures - In development, also:
config