Multinumbers, measured
A multinumber is a polynomial in several variables with integer coefficients, built as a box of boxes. Built literally, one object per element, it is too slow to use. This paper measures how slow, how far a packed 64-bit layout in Raya closes the gap, how it compares with the standard computer-algebra libraries, and what it can do today on three real problems.
Abstract
N. J. Wildberger builds arithmetic out of boxes: a natural number is a box of zeros, a polynumber is a box of naturals (a polynomial in one variable), and a multinumber is a box of polynumbers, which, read the right way, is a polynomial in several variables with integer coefficients. Riptide's number-types note implements these types in Raya and said that the literal construction, one object per element, was not feasible at useful sizes. On 1 December 2026 that claim was measured on AWS Fargate (Graviton3 and Xeon Platinum 8259CL, one thread), with every answer checked against FLINT, Singular and SymPy by its term count and its value at a test point modulo (72 experiments, 0 mismatches; Singular did not finish its step at 1,024 terms and above on the sparse family, so those cases were checked against FLINT and SymPy only).
- The literal construction: 2.1 minutes for a 256-term product, 41.2 minutes at 512 terms; 1,024 terms ran 1.9 hours without finishing, and 2,048 terms used 9.9 GB within 5 minutes. Its time grows like ; extrapolated, 2,048 terms would take about 6.3 days.
- The packed multinumber does the 2,048-term product in 754 ms, exactly.
- Against the libraries: FLINT is 81× faster than the packed multinumber on that product (9.26 ms) and faster everywhere, by 6× to 1,300×. Singular is 2–4× faster up to 2,048 terms. SymPy is 1.4–16× slower on the dense family and about even on a sparse 8-variable one.
- Applications: protein loop closure over 3,616 PDB windows, inverse kinematics of 3-joint arms for 1,000 targets, and three generating-function families all ran end to end with exact answers, 2–40× behind FLINT. Against SymPy running the same algorithm, the packed multinumber is 5.6× faster on PUMA-like arm IK, 4–6× on forward kinematics, 5–30× on counting problems and 1.9× on general arms; on loop closure SymPy's same algorithm is about 2× faster, and only SymPy's own
resultant()is slower (5.5×).
What this lets you do
- Write exact multivariate algebra in Raya with no big-integer library. Up to 8 variables, exponents up to 127 and coefficients that fit in a signed 64-bit integer. Every operation is exact or stops with an error; nothing wraps around.
- Batch small polynomial systems. Robot-arm inverse kinematics for one arm and many targets, forward kinematics up to 7 joints, and small counting problems fit the layout well, and run 4–30× faster than SymPy.
- Know where the line is. This paper gives the sizes where the 64-bit layout runs out (loop closure needs about 636-bit coefficients, lattice paths fit up to 31 steps and pass the limit by 40) and where FLINT should be used instead.
The number types are a prototype, not a shipped Raya library. Their definitions and earlier results are on the number-types note.
What a multinumber is
A multinumber is a box of polynumbers. Each polynumber inside it is one monomial: how many times the natural appears in it is the exponent of the variable , and how many times that polynumber appears in the multinumber is the coefficient. So the box is . Multiplying two multinumbers multiplies every pair of monomials and collects like terms.
- The object version is the literal definition: every box is an object, and a coefficient of 3 is three copies of the box. It is the reference the number-types note compared against.
- The packed multinumber stores each monomial as one 64-bit word, one byte per variable, with a 64-bit integer coefficient. That allows up to 8 variables with exponents up to 127. When a coefficient would pass or an exponent would pass 127, it stops with an error. The check is conservative, so it sometimes stops when the true answer would still fit.
Method
This section describes the packed multinumber measured here at the level of the algorithm. The code is a Raya prototype and is not published.
- One monomial in one word. Byte of a 64-bit word holds the exponent of (), in its low 7 bits; bit 7 of every byte is a guard. Multiplying two monomials adds their exponents, which is one integer addition of the two words: no carry can cross a byte while each exponent stays below 128, and if a sum reaches 128 its guard bit is set, which the code checks with one mask and reports as an overflow. This is the packed exponent vector of Monagan and Pearce, with Wildberger's reading: a polynumber is an mset of naturals, and pooling two msets adds their counts.
- A multinumber is a list of (word, coefficient) pairs sorted by word, with signed 64-bit coefficients. Addition is a merge of two sorted lists.
- Multiplication. Before the product starts, a bound check compares the bit lengths of the largest coefficient on each side and of the shorter factor's length with the 62-bit limit; if the result could pass , the product stops with an error instead of wrapping. Then every pair of terms is formed (one word addition and one coefficient multiplication), and like terms are collected in an open-addressing hash table from word to coefficient, sized from the two lengths. The table's entries are finally sorted by word. The check uses bit lengths, not exact maxima, so it sometimes refuses a product whose true answer would fit (Fateman's benchmark at = 14 and 15).
- The lab variant used when the 64-bit lane overflows keeps the same words and runs the same product with coefficients modulo 31-bit primes, one prime after another. The Chinese remainder theorem lifts the residues to exact integers, and the loop stops once two further primes leave the lifted result unchanged.
- Resultants in the applications are determinants of Sylvester matrices whose entries are multinumbers. They are computed without division, by dynamic programming over subsets of columns (a Laplace expansion that stores each minor once), so only ring operations are needed and every implementation runs the same algorithm. In the arm applications every sine and cosine is replaced by its half-angle tangent , as and , so the equations are polynomial with rational coefficients.
The object version is the literal construction: every box is an object, and a coefficient of 3 is three copies of the same box.
Setup
- Machines. AWS Fargate tasks on Graviton3 (Neoverse V1) and Intel Xeon Platinum 8259CL, one thread each. Each implementation ran in its own task with a time cap and a memory limit (12 GB for SymPy); peak memory was recorded for every run.
- Implementations. The packed multinumber and the object version in Raya 0.4.0 (AOT); FLINT 3.0.1 (
fmpz_mpoly_mul, one thread) from C; Singular 4.3.2; SymPy 1.12 (sparse ring polynomials over gmpy2 integers). Each library multiplied the same operands, read from the same file. - Correctness. Every result was checked across implementations and across the two chips by its term count and its value at a test point modulo . The object version matched the packed product at every size it finished.
- Operands. The scaling family uses 4 variables, exponents 0–15 and coefficients 1–3, with distinct terms in each factor (a 2,048-term product has 4.2 million term pairs and about 670,000 distinct result terms). The sparse family uses 8 variables, where almost every pair gives a new term.
Results
"Not feasible", measured

| terms | result terms | packed | FLINT | SymPy | Singular | object version |
|---|---|---|---|---|---|---|
| 15 | 225 | 51.2 µs | 6.04 µs | 99.6 µs | 25 µs | 13.7 ms |
| 64 | 4,080 | 1.38 ms | 238 µs | 2.41 ms | 449 µs | 638 ms |
| 128 | 15,974 | 6.38 ms | 1.11 ms | 9.68 ms | 1.95 ms | 8.72 s |
| 256 | 59,750 | 30 ms | 4.7 ms | 42.2 ms | 8.35 ms | 2.1 min |
| 512 | 189,836 | 137 ms | 3 ms | 268 ms | 31.7 ms | 41.2 min |
| 1,024 | 427,741 | 293 ms | 5.4 ms | 957 ms | 104 ms | not finished in 1.9 h (≈ 9.7 h) |
| 2,048 | 670,451 | 754 ms | 9.26 ms | 4.25 s | 343 ms | not finished in 30 min (≈ 6.3 days) |
| 8,192 | 902,328 | 4.28 s | 55.6 ms | 1.1 min | 168 ms | not run |
| 32,768 | 923,231 | 53.75 s | 40.5 ms | – | 184 ms | not run |
Fitted over 64 to 2,048 terms, the time grows like for the packed multinumber, for FLINT and for SymPy, and like for the object version over the sizes it finished. A product has term pairs, so an exponent near 2 is a constant cost per pair; the packed exponent stays below 2 because this family has at most distinct monomials. The object version's exponent near 4 is pairs times distinct result terms: collecting like terms compares each new element with every result term found so far. At 2,048 terms it builds 17 million pair objects before collecting them.
So the number-types note's line stands, and it now has the numbers: measured, the object version is 268× (15 terms) to 18,000× (512 terms) slower than the packed one, and extrapolated about 700,000× at 2,048 terms.
Against FLINT, Singular and SymPy
| family | terms | packed | FLINT | packed vs FLINT | packed vs SymPy | packed vs Singular |
|---|---|---|---|---|---|---|
| 4 variables | 15 | 51.2 µs | 6.04 µs | FLINT 8.5× faster | packed 1.9× faster | Singular 2.0× faster |
| 4 variables | 256 | 30 ms | 4.7 ms | FLINT 6.4× faster | packed 1.4× faster | Singular 3.6× faster |
| 4 variables | 2,048 | 754 ms | 9.26 ms | FLINT 81× faster | packed 5.6× faster | Singular 2.2× faster |
| 4 variables | 8,192 | 4.28 s | 55.6 ms | FLINT 77× faster | packed 16× faster | Singular 25× faster |
| 8 variables | 256 | 34.5 ms | 4.68 ms | FLINT 7.4× faster | packed 1.4× faster | Singular 3.2× faster |
| 8 variables | 2,048 | 3.99 s | 352 ms | FLINT 11× faster | about even | – |
| 8 variables | 8,192 | 1.4 min | 6.59 s | FLINT 13× faster | SymPy out of memory | – |

On the Xeon the picture is the same: 704 ms for the 2,048-term product against FLINT's 21.1 ms. On the sparse family the packed multinumber uses about 4× less memory than SymPy (330 MB against 1.33 GB at 2,048 terms).
Three applications
Each application runs the same algorithm in every implementation, the same polynomial matrices and the same resultants, and where a library has its own resultant that is timed too. The packed multinumber runs in its 64-bit lane first. When that lane stops on overflow, a lab variant of the packed multinumber takes over; it always finishes, with the exact answer. That variant was written for this study and is not in the library yet.

Protein loop closure. Keep residues 1–3 of a protein backbone rigid at both ends and ask every way the middle can close; eliminating two half-turn parameters gives one degree-16 polynomial whose real roots are the closures. Over 3,616 consecutive tripeptide windows from 30 PDB entries the answer is exact for every window: 2, 4, 6, 8 and 12 real closures in 1,895, 1,249, 310, 161 and 1 windows, the same shape as the 3.78-million-window distribution in Protein backbones in rational trigonometry. The 64-bit lane cannot hold even the starting equations (about 70-bit coefficients at PDB precision), and the final polynomial needs about 636 bits, so the lab variant does the work: 4.86 ms per window, against 0.12 ms for FLINT's resultant(), 1.23 ms for Singular, 2.29 ms for SymPy running the same algorithm and 26.6 ms for SymPy's resultant(). Here SymPy's same-algorithm path is about 2× faster than the packed multinumber.
Robot-arm inverse kinematics. The position IK of a 3-joint arm in half-angle tangents, so every sine and cosine is rational, reduces to one degree-16 polynomial per target. For a PUMA-like elbow arm, 1,000 targets take 120 ms in the 64-bit lane (FLINT's resultant 23.2 ms, Singular 107 ms, SymPy's same algorithm 669 ms, SymPy's resultant 2.31 s): 161 targets are unreachable, 830 have 2 solutions and 9 have 4. A general arm with twist cosines 3/5 and 5/13 pushes the coefficients to 77 bits; the lab variant takes 546 ms (FLINT 30.7 ms, SymPy's same algorithm 1.02 s). The symbolic forward map of an -joint arm stays small (19 bits at 7 joints) and runs 2–7× behind FLINT and 4–6× ahead of SymPy.
Generating functions. Multiplying polynomials counts things. The packed multinumber computes lattice paths up to in its 64-bit lane (there are 5,550,996,791,340 30-step paths to (10, 10, 10)), vector partitions up to a 5 × 5 grid (37,638 distinct classes; the largest holds 27,339,258 sets), and Fateman's benchmark with up to in 52.7 ms (FLINT 2.87 ms, SymPy 1.59 s). Beyond those sizes (lattice paths fail at the next size tested, ) the counts or exponents pass the 64-bit layout's limits; the lab variant continues (Fateman at in 13.2 s against FLINT's 0.33 s).
| use | fits the packed layout? | verdict |
|---|---|---|
| Robot-arm IK, one arm and many targets | yes for PUMA-like arms; lab variant for general twists | promising: exact, faster than SymPy, 2–5× behind FLINT in 64 bits |
| Forward kinematics, up to 7 joints | yes | works; 2–7× behind FLINT |
| Generating functions | only while counts stay under and exponents under 128 | fine for small cases; FLINT 10–20× faster |
| Protein loop closure | no: about 70-bit equations and 636-bit results | exact through the lab variant, 20–40× behind FLINT; SymPy's same algorithm is about 2× faster; use FLINT in production |
| Multivariate post-quantum cryptography (UOV, MAYO) | no: real keys use 44–160 variables | only an 8-variable toy runs, 3–4× behind FLINT |
Limitations and next steps
The limits of these results, each with its cause and, where one is planned, the next step.
- FLINT is faster everywhere, by 6× on tiny sparse products to about 1,300× on large dense ones. Cause: the gap is in the multiplication algorithm, not in the storage; FLINT also switches to a dense algorithm once the result is small enough, so its time stays flat from 8,192 to 32,768 terms while the packed multinumber's keeps growing with the pairs.
- Singular is 2–4× faster up to 2,048 terms, and 25–300× faster once the result fills up. Cause: as with FLINT, the multiplication algorithm; Singular also switches to a dense method once the result fills up.
- The 64-bit layout runs out early on real problems: loop closure needs about 636 bits, general arms 77 bits, lattice paths fit up to 31 steps and pass the limit by 40, and vector partitions stop at a 6 × 6 grid. A lab variant always finishes, taking 3–40× FLINT's time, but it is not in the library. Cause: the layout fixes coefficients at 64 bits and exponents at 127 by design.
- The overflow guard is conservative. It stops Fateman's benchmark at although that answer (56 bits) would fit. Cause: the guard errs on the safe side; a tighter check is a known, cheap fix.
- Eight variables at most, so real multivariate cryptography does not fit. Cause: one byte per variable in a 64-bit word.
Reproduction notes
- Software. The number types are a Raya prototype and are not published as a library; the definitions are on the number-types note. Evaluation builds are available through Request an evaluation.
- Records. 72 experiments with every row, time cap, exit status and peak memory, merged into one results file, plus the 3,616 PDB tripeptide windows used. Evaluation partners can have the raw files on request.
- Cost. About $3.50 of rented machine time (Fargate, about 16 task-hours, plus storage and logs).
References
- N. J. Wildberger, Math Foundations lecture series (Insights into Mathematics), on msets, polynumbers and multinumbers.
- W. Hart, F. Johansson, S. Pancratz et al., FLINT: Fast Library for Number Theory, version 3.0.
- W. Decker, G.-M. Greuel, G. Pfister and H. Schönemann, Singular 4.3.2 — A computer algebra system for polynomial computations.
- A. Meurer et al., SymPy: symbolic computing in Python, PeerJ Computer Science 2017.
- S. C. Johnson, Sparse polynomial arithmetic, ACM SIGSAM Bulletin 8(3), 1974, pp. 63–71.
- M. Monagan and R. Pearce, Parallel sparse polynomial multiplication using heaps, ISSAC 2009, pp. 263–270.
- R. Fateman, Comparing the speed of programs for sparse polynomial multiplication, ACM SIGSAM Bulletin 2003.
- E. A. Coutsias, C. Seok, M. P. Jacobson and K. A. Dill, A kinematic view of loop closure, Journal of Computational Chemistry 2004.
- D. Manocha and J. F. Canny, Efficient inverse kinematics for general 6R manipulators, IEEE Transactions on Robotics and Automation 1994.
- H. M. Berman et al., The Protein Data Bank, Nucleic Acids Research 2000.
Date and version
Version 1.2, 1 December 2026. Measurements from 1 December 2026. Updated 1 December 2026: added Method section. Updated 1 December 2026: limitations section retitled.
Working with Riptide
Riptide works with a small number of teams. Each engagement starts with 4 weeks inside your systems, learning how your models, data and infrastructure work. Only then does Riptide apply its software to them. Contact samario@riptidecompute.com or riptidecompute.com/evaluate.