Abstract

Recall the Multiply Problem: splitting two -bit numbers into halves and recursively multiplying the pieces. Cook-Toom- asks: what happens if we divide into subproblems, each of size , instead of just 2?

  • Category: Divide and Conquer / Integer Multiplication
  • Input: Two -bit numbers (represented as degree- polynomials once split into parts)
  • Output: The product
  • Paradigm: Divide and Conquer, generalizing Karatsuba’s 2-way split to a -way split
  • Typical use cases: fast big-integer / big-polynomial multiplication; a stepping stone toward understanding how multiplication can approach near-linear time

Core Logic (High-Level)

The Naive k-Way Split

Splitting each number into equal parts represents it as a degree- polynomial:

Multiplying these two polynomials the schoolbook way requires coefficient multiplications (every against every ). The recursion:

So a naive -way split, at any , is still — exactly as slow as the classic 2-way split. Splitting into more pieces doesn’t help unless the combine step also improves.

Key Idea

If you split a number into equally-sized parts, you can combine them with only multiplications instead of — by evaluating both degree- polynomials at distinct points, multiplying the resulting values pointwise, and interpolating to recover the product polynomial’s coefficients. (This evaluate → pointwise-multiply → interpolate structure is the general Toom-Cook technique; Karatsuba is the special case , needing only multiplications — matching the “Multiply KS” trick in Multiply Problem.)


Pseudocode (Mid-Level Implementation)

Algorithm 7 Cook-Toom-k Multiply

Input: Two nn-bit numbers x,yx, y; a chosen split factor kk

Output: the product xyxy

procedure CookToomK(x,y,kx, y, k)

if nn is small enough then

return xyxy directly

Split x,yx, y into kk parts each, forming coefficients a0,,ak1a_0,\dots,a_{k-1} and b0,,bk1b_0,\dots,b_{k-1}

Choose 2k12k-1 distinct evaluation points z1,,z2k1z_1, \dots, z_{2k-1}

for each point ziz_i do

Evaluate A(zi)=jajzijA(z_i) = \sum_j a_j z_i^j and B(zi)=jbjzijB(z_i) = \sum_j b_j z_i^j

RiR_i = CookToomK(A(zi)A(z_i), B(zi)B(z_i), kk)//recursive call, size n/kn/k

Interpolate the product polynomial's coefficients from the 2k12k-1 values R1,,R2k1R_1, \dots, R_{2k-1}

return the recombined product xyxy

Variables & Data Structures

NameTypePurpose
kInteger (fixed, chosen ahead of time)Number of equal parts each number is split into
a_0,...,a_{k-1} / b_0,...,b_{k-1}CoefficientsThe -part representation of and as degree- polynomials
z_1,...,z_{2k-1}Evaluation pointsChosen points used to reduce polynomial multiplication to pointwise scalar multiplications

Helper Functions / Operations Used

  • Evaluate — computing , for each point; per point, total across all points.
  • Interpolate — solving for the product polynomial’s coefficients given its values at points (e.g. via Lagrange interpolation); also -ish, contributing to the combine-step overhead below.

Proof of Correctness

The correctness argument is essentially interpolation theory rather than an algorithmic invariant: a polynomial of degree (the true product of two degree- polynomials) is uniquely determined by its values at any distinct points. So evaluating both inputs at points, multiplying pointwise (which correctly gives the product polynomial’s value at each of those points), and interpolating recovers the exact product — no approximation is involved, provided the evaluation points are distinct.


Time & Space Complexity Analysis

General Case

With the improved -multiplication combine step:

where is the coefficient of the linear combine-step term (evaluation + interpolation overhead) — note this is still linear in since is fixed, but the constant factor in front grows quadratically with .

Implementation-Dependent Variations

Choice of Exponent Combine overhead Notes
(Karatsuba)Small, constantThe classic special case — see Multiply Problem
Larger Approaches as Grows as — larger and largerBetter asymptotic exponent, but a rapidly growing constant factor ― practically not worth it cause the non-recursive part grows quadratically

Best / Worst / Average Case

  • Best / Worst / Average case: All the same order for a fixed — the algorithm always performs the same evaluate/recurse/interpolate structure regardless of the specific input values, so there’s no input-dependent variation, only -dependent variation.

Drawbacks / Constraints

  • The constant factor grows fast with . means choosing a larger to shrink the exponent isn’t free — the linear term’s coefficient grows quadratically, so there’s a real trade-off, not a free lunch.
  • Only approaches linear time, never reaches it. Since , for any you can choose large enough to get — but no fixed choice of actually reaches or even . Achieving that requires a fundamentally different approach (FFT-based multiplication, e.g. Schönhage–Strassen).
  • Numerical/implementation care needed: evaluation points must be chosen so interpolation is well-conditioned (e.g. small integers), since poorly chosen points can blow up coefficient sizes or cause numerical instability in the interpolation step.

References / Links