JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Expression Swell: Why Exact Does Not Scale

Symbolic computation gives you the exact answer — and sometimes that exact answer is a page long, or a thousand pages, even when the question was small. This guide explains why intermediate expressions explode, why no amount of cleverness fully cures it, and how to tell when exact is worth the cost.

The bill comes due in the middle

By now this rung has sold you on exact computation: symbolic answers carry no round-off, arbitrary-precision arithmetic lets integers grow as long as memory allows, and a computer algebra system can hand you a closed form a numeric solver would only approximate. So here is the catch the whole rung has been building toward. Exactness is not free, and the price is rarely paid where you look for it. It is paid in the middle — in the intermediate expressions the system must hold while it works. That growth has a name: expression swell, and it is the central limitation of symbolic computation, the exact-arithmetic twin of round-off in floating point.

A tiny example makes it vivid. Multiply out (x + y + z)^4 and you get 15 terms — already more than you expected from three letters. Push to (x + y + z + w)^10 and the expanded polynomial has 286 terms; bump the exponent or add a variable and the count climbs like a hockey stick. The final answer might still be compact once simplified, but the system has to materialise that intermediate cloud of terms first. The question was three lines; the work in between was a wall of algebra.

Where the swelling comes from

Three sources drive almost all of it. The first is coefficient growth: when you add or subtract exact rationals, the denominators do not cancel by luck the way they do in floating point. Run Gaussian elimination on a matrix of small integers but keep everything exact, and the entries that appear mid-elimination can have numerators and denominators with hundreds of digits — even though the final reduced matrix has small entries again. The middle of the calculation is a swamp the endpoints never hint at.

The second source is term explosion: expanding products, as in the (x + y + z + w)^10 case, multiplies the number of monomials combinatorially. The third, and most painful, is structural growth in algorithms: many exact procedures generate intermediate results far larger than either their input or output. A Groebner basis computed by Buchberger's algorithm can have coefficients whose size grows doubly exponentially in the worst case — a tower of exponents — which is exactly why the polynomial-system guide warned you that an innocent-looking system can be effectively uncomputable. Symbolic integration via the Risch algorithm is similar: deciding whether an elementary antiderivative even exists is a genuine, deep computation, not a lookup.

(x + y + z)^2   ->  6 terms
(x + y + z)^4   ->  15 terms
(x + y + z)^8   ->  45 terms
(x+y+z+w)^10    ->  286 terms

Gaussian elimination on an integer matrix, kept EXACT:
  input entries:   1-digit integers
  mid-elimination: 100s-of-digit rationals   <- the swell
  final entries:   small again
# the cost lives in the middle, where you cannot see it from the ends
Small in, small out, enormous in between — the signature of expression swell.

Why simplification cannot just delete it

The obvious reflex is: just keep simplifying as you go, so nothing ever gets big. It is a good instinct and systems do exactly that — but it runs into a wall you already met two guides back. To shrink an expression you must recognise when two different-looking expressions are equal, and that is the zero-equivalence problem: deciding whether a given expression is identically zero. For broad enough classes of expressions — ones mixing exponentials, logarithms, and roots — this problem is provably undecidable; no algorithm can always answer it. So a system cannot guarantee it has found the smallest form, because it cannot always tell that two of its terms cancel.

The partial cure is canonical form: agree on one privileged way to write each value, so equal things become literally identical strings and a cancellation is visible at a glance. Where a true canonical form exists, the tool that keeps swell in check is the polynomial GCD from earlier this rung — every rational function is reduced to lowest terms by dividing numerator and denominator by their greatest common divisor, killing the spurious common factors that would otherwise pile up. But canonical forms exist only for restricted classes (polynomials, rational functions), they can be expensive to compute, and the canonical form itself may be the large object. Simplification fights expression swell; it does not abolish it.

Living with it: the honest playbook

You cannot defeat expression swell, but a seasoned user steers around it. The techniques are clever and worth knowing — they are how real systems push the wall back even if they cannot remove it.

  1. Modular and evaluation tricks: compute the answer modulo several primes, or at several numeric points, then reconstruct the exact result — the intermediate numbers stay small even though the symbolic answer is huge.
  2. Keep things factored: store an expression as a product of pieces rather than fully multiplied out, so the term explosion of expansion never happens unless you truly need it.
  3. Reduce at every step: take GCDs to keep rational functions in lowest terms, and reorder a Groebner-basis computation (the variable ordering changes the cost by orders of magnitude).
  4. Ask a smaller question: a definite integral as a single number, a numeric root, or a series to a few terms is often all you actually need — and is cheap where the full closed form is ruinous.

Closing the rung: two ways of being right

Step back and see the whole symbolic rung as one argument. You learned that exact and approximate computation are two different machines for two different jobs: numeric arithmetic is fast and fixed-size but always carries round-off, while exact arithmetic carries no error but lets data grow without bound. You met canonical forms and the hard wall of deciding equality; the Euclidean GCD and Groebner bases that solve polynomial problems exactly; and symbolic differentiation, which is mechanical, against the Risch machinery for integration, which is deep. Expression swell is the thread tying it together — the price tag stapled to every exact method.

Notice how cleanly the two halves of the subject mirror each other. Numerical computing is bounded in space but bleeds accuracy: every answer is an approximation, conditioning and stability decide how many digits survive, and you can never reach the real-arithmetic ideal. Symbolic computing is perfect in accuracy but unbounded in space: every answer is exact, yet the work can swell past any machine you own. Round-off and expression swell are the same lesson wearing different clothes — there is no method that is simultaneously fast, exact, and small. You always trade.

So the mature stance is not to crown one machine king. It is to know both, to read a problem and ask which kind of being-right it actually needs, and often to braid the two — a computer algebra system to find the structure, floating point to evaluate it at scale. Exact does not scale; approximate is never exact; and the craft of computational mathematics is choosing, honestly and on purpose, which limitation you would rather live with for the problem in front of you.