Computer Algebra & Arbitrary-Precision Arithmetic
Symbolic Computation & Arbitrary-Precision Arithmetic
By Topic
-
Symbolic Computation (Computer Algebra)
Internal representation of expressions, polynomial operations/interpolation/GCD/resultants, factorization, p-adic, Gröbner bases, rewriting systems, symbolic differentiation/integration/limits/summation, exact linear algebra, algebraic numbers, differential algebra, CAD, computational algebraic geometry, formal power series (27 chapters)
-
Multiprecision Integer Arithmetic
Integer representation and basic operations, fast multiplication (Karatsuba / Toom-Cook / NTT) and fast division (BZ / Newton), modular arithmetic (Montgomery / Barrett / CRT), GCD, primality testing, factorization, Block Lanczos, number-theoretic functions (13 chapters)
-
Multiprecision Float Arithmetic
Float representation and operations, square root and N-th root, high-precision elementary functions ($\exp$ / $\log$ / $\sin$ / $\cos$), mathematical constants ($\pi$ / $e$ / $\gamma$), Binary Splitting and hypergeometric series (10 chapters)
Overview
Computer algebra (also called symbolic computation) is the branch of computation that manipulates mathematical expressions symbolically rather than numerically. Factoring $x^2 + 2x + 1$ into $(x+1)^2$, finding $\int e^x \sin x \, dx$ in closed form, analyzing the solution structure of a polynomial system — these are all routine tasks for Computer Algebra Systems (CAS).
Systems such as Mathematica, Maple, SymPy, and SageMath have become indispensable tools of modern mathematics and science, yet the algorithms running inside them are surprisingly little known. This series systematically explains the algorithms and data structures that power a CAS.
Part I (Symbolic Computation, 27 chapters) covers the full theory and algorithms of a CAS, from polynomial representation through rewriting systems, symbolic integration, CAD, and computational algebraic geometry. Part II (Multiprecision Integers, 13 chapters) and Part III (Multiprecision Float, 10 chapters) cover the arbitrary-precision arithmetic that underpins a CAS: fast multiplication and division, modular arithmetic, primality testing, factorization, high-precision elementary functions, and Binary Splitting for mathematical constants.
Learning goals
- Understand internal representations of expressions (trees, DAGs, hash consing) and the distinction between canonical and normal forms
- Know how polynomials are represented and the complexity of their basic operations, interpolation, GCD, and resultants
- Learn factorization algorithms over finite fields, integers, and algebraic number fields, and the principles of p-adic lifting
- Master Gröbner basis theory and the Buchberger, F4, and F5 algorithms, along with their applications
- Understand the role of term rewriting systems (Knuth-Bendix), expression simplification, and the zero-equivalence problem
- Learn the principles of symbolic differentiation, integration (Risch), limits (Gruntz), and summation (Gosper-Zeilberger)
- Get an overview of advanced topics: differential algebra, quantifier elimination (CAD), computational algebraic geometry
- Master fast integer multiplication (Karatsuba / Toom-Cook / NTT) and fast division (Burnikel-Ziegler / Newton)
- Understand the principles of modular arithmetic (Barrett / Montgomery / CRT) and their cryptographic applications
- Learn primality testing (Miller-Rabin / APRCL) and factorization (Pollard ρ / ECM / GNFS)
- Master multiprecision floating-point arithmetic, high-precision elementary functions, and Newton-based root extraction
- Learn fast algorithms for computing mathematical constants ($\pi$, $e$, $\gamma$, etc.) via Binary Splitting
Contents
Part I — Symbolic Computation (27 chapters)
- Chapter 1Introduction to Computer Algebra
What computer algebra is, history of CAS (MACSYMA to SymPy), tree representation of expressions, canonical vs normal forms, complexity notions
- Chapter 2Internal Representation — Trees, DAGs, Hash Consing
Detailed tree implementation, flattening of n-ary operations, DAG sharing of common subexpressions, hash consing, comparison of major CAS representations
- Chapter 3Polynomial Representation
Dense vs sparse, recursive vs distributive, choice of term order, structure of multivariate polynomials
- Chapter 4Basic Polynomial Operations
Add/sub/mul/div, Horner evaluation, long division, pseudo-division, symbolic differentiation, Newton and Bernstein bases
- Chapter 5Polynomial Interpolation
Lagrange interpolation, Newton's divided differences, Neville's algorithm, FFT-based fast interpolation, Chinese Remainder interpolation
- Chapter 6Polynomial GCD
Expression swell, subresultant algorithm, modular GCD, sparse modular GCD, multivariate GCD
- Chapter 7Resultants and Subresultants
Sylvester determinant, common-root test, Euclidean algorithm and resultants, subresultant PRS, Collins-Brown-Traub, implicit elimination
- Chapter 8Partial Fraction Decomposition
Undetermined coefficients, Heaviside cover-up, Hermite reduction, Horowitz's algorithm, preprocessing for symbolic integration
- Chapter 9Factorization over Finite Fields
Square-free decomposition, distinct-degree factorization, Cantor-Zassenhaus, Berlekamp, Kaltofen-Shoup
- Chapter 10Factorization over Integers and Rationals
Hensel lifting, Zassenhaus, factor combination problem, LLL lattice reduction, van Hoeij's algorithm
- Chapter 11Factorization over Algebraic Number Fields
Factorization over $\mathbb{Q}(\alpha)$, use of the norm, Trager's algorithm, Tschirnhaus transformation
- Chapter 12p-adic Computation and Hensel Lifting
p-adic numbers, p-adic absolute value, Hensel's lemma, single- and multi-factor lifting, Dixon's p-adic linear algebra
- Chapter 13Gröbner Bases
Polynomial ideals, S-polynomials, Buchberger's algorithm, sugar strategy, F4 and F5 algorithms
- Chapter 14Applications of Gröbner Bases
Solving systems of equations, variable elimination, ideal operations, automatic proof of geometric theorems, robotics
- Chapter 15Expression Rewriting Systems
Term rewriting systems, confluence and termination, Knuth-Bendix completion, pattern matching, AC matching
- Chapter 16Simplification and Normal Forms
Term rewriting systems, trigonometric simplification, zero-equivalence problem, Richardson's theorem
- Chapter 17Symbolic Differentiation
Formalizing the chain rule, recursive tree transformation, higher-order derivatives, multivariate partial derivatives, Faà di Bruno's formula, comparison with automatic differentiation
- Chapter 18Symbolic Integration
Liouville's theorem, Hermite reduction, Risch algorithm (logarithmic and exponential parts), heuristic methods
- Chapter 19Symbolic Limit Computation
Limitations of L'Hôpital's rule, Hardy fields, Gruntz algorithm, MrvSet and levels, extension to special functions
- Chapter 20Symbolic Summation and Hypergeometric Series
Gosper's algorithm, Zeilberger's algorithm, WZ theory, holonomic systems
- Chapter 21Difference Equations and q-Hypergeometric
Linear difference equations, Petkovšek algorithm, q-differences, q-hypergeometric series, q-version of summation algorithms
- Chapter 22Exact Linear Algebra
Bareiss's algorithm, Hermite normal form, Smith normal form, Dixon's p-adic method, LLL lattice reduction
- Chapter 23Algebraic Numbers and Field Extensions
Minimal polynomial, root separation, arithmetic of algebraic numbers, algebraic extensions, Trager factorization, Galois groups
- Chapter 24Differential Algebra and Symbolic ODE Solving
Differential fields, Picard-Vessiot theory, differential Galois groups, Kovacic's algorithm, Liouvillian solutions
- Chapter 25Quantifier Elimination and CAD
Tarski-Seidenberg theorem, Collins's CAD, projection and lifting, partial CAD, QEPCAD and Redlog
- Chapter 26Computational Algebraic Geometry
Radicals of ideals, primary decomposition, Hilbert function, singularity detection, dimension computation
- Chapter 27Formal Power Series and D-finite Functions
Truncated power series arithmetic, Brent-Kung composition, power series solutions of differential equations, D-finite functions
Part II — Multiprecision Integer Arithmetic (13 chapters)
- Chapter 1Introduction to Multiprecision Integers
The 64-bit wall, use cases, representation choices, memory management, overview of major libraries
- Chapter 2Multiprecision Integer Representation
Limb arrays, sign-magnitude vs two's complement, endianness, SBO, calx design choices
- Chapter 3Basic Integer Operations
Schoolbook add/sub/mul/div, carry propagation, comparison, string conversion
- Chapter 4Fast Multiplication Algorithms
Karatsuba, Toom-Cook 3/4/6/8, NTT, 5-smooth NTT, squaring optimization, threshold design
- Chapter 5Fast Division Algorithms
Knuth's Algorithm D, Burnikel-Ziegler, Newton reciprocal iteration, Exact Division, calx implementation
- Chapter 6Modular Arithmetic
Barrett reduction, Montgomery multiplication, CRT, fast modular exponentiation, constant-time implementations
- Chapter 7Integer GCD Algorithms
Classical Euclid, Binary GCD (Stein), Lehmer, HGCD, Extended GCD, modular inverse
- Chapter 8Unbalanced Toom-Cook Multiplication
Toom-4,2 / Toom-8, pre-pad + addmul_1, application to unbalanced invert_approx
- Chapter 9NTT Implementation Comparison
Prime NTT, Small Prime NTT, Goldilocks NTT, Double FFT, 5-smooth NTT, AVX2 butterflies
- Chapter 10Primality Testing
Miller-Rabin, Fermat, Baillie-PSW, APRCL, AKS, practical combined strategies
- Chapter 11Integer Factorization
Trial division, Pollard rho/Brent, Pollard p-1, Fermat, ECM, SIQS, GNFS
- Chapter 12Block Lanczos
GF(2) sparse matrix solver, Coppersmith blocking, CSR format, final stage of GNFS
- Chapter 13Number-Theoretic Functions
Möbius $\mu$, Euler totient $\phi$, divisor functions $\sigma_k$, Jacobi symbol, Dirichlet convolution, Möbius inversion
Part III — Multiprecision Float Arithmetic (10 chapters)
- Chapter 1Introduction to Multiprecision Float
Limits of IEEE 754, error analysis, condition number, use cases for multiprecision float, major libraries (MPFR, calx, mpmath)
- Chapter 2Multiprecision Float Representation
Mantissa, exponent, sign, normalization, special values (inf, nan), effective_bits, rounding modes
- Chapter 3Multiprecision Float Arithmetic
Add/sub/mul/div, correct rounding, Kahan summation, three-arg FloatOps API, buffer reuse
- Chapter 4Float Square Root and Reciprocal Square Root
Newton's method for square roots, reciprocal square root tables, precision doubling, construction of initial approximations
- Chapter 5High-Precision Elementary Functions
$\exp$, $\log$, $\sin$, $\cos$, $\tan$, $\arctan$; argument reduction, Taylor series, AGM, guaranteed correct rounding
- Chapter 6Computation of Mathematical Constants
$\pi$ (Chudnovsky, Gauss-Legendre, BBP), $e$, $\gamma$ (Brent-McMillan), $\ln 2$, Catalan's constant, caching
- Chapter 7Zimmermann's Recursive Square Root
Recursive divide-and-conquer sqrtrem, dc_sqrtrem, three-layer isSquare filters
- Chapter 8N-th Root via Precision-Doubling Newton
Newton iteration for $x^n = a$, precision doubling, order of convergence, multiprecision implementation
- Chapter 9Initial Approximations for N-th Roots
Ensuring precision of double-based initial values, pre-stage of root extraction, exponent normalization
- Chapter 10Binary Splitting and Hypergeometric Series
$O(M(n) \log^2 n)$ BS, Chudnovsky $\pi$, Brent-McMillan $\gamma$, 4-way parallelism, limitations of NTT integration
Prerequisites
- Basic algebra: definitions of groups, rings, fields; polynomial rings $R[x]$; ideals; quotient rings
- Linear algebra: matrix operations, determinants, eigenvalues
- Algorithmic fundamentals: $O$-notation of complexity, divide-and-conquer, Euclidean algorithm
- Programming experience: Python (for experimenting with SymPy) is desirable
- Basic C++ (if you want to read Part II / III at the implementation level): for reference to the calx library source
Related Libraries and Software
| Name | Type | Notes |
|---|---|---|
| Mathematica | Commercial CAS | The most widely used CAS; integrates symbolic, numeric, and visualization |
| Maple | Commercial CAS | Particularly strong in symbolic integration and Gröbner bases |
| SymPy | OSS (Python) | Python library; ideal for education and research |
| SageMath | OSS (Python) | A platform that integrates many CAS components |
| Singular / Macaulay2 | OSS | Specialized for commutative algebra and algebraic geometry; fast Gröbner / primary decomposition |
| GMP | OSS (C) | A classic multiprecision integer / rational / floating-point library |
| MPFR | OSS (C) | Multiprecision float library with guaranteed correct rounding (GMP-based) |
| calx | OSS (C++23) | Allisone's C++-native multiprecision library; used as the reference implementation in this series |
| FLINT / NTL | OSS (C/C++) | Fast polynomial arithmetic and factorization libraries |
| PARI/GP | OSS (C) | Number-theory-focused CAS; strong on elliptic curves and algebraic number fields |
Last updated: 2026-04-20