Karatsuba carry handling 2026-10-13
The blocks in the Karatsuba three-product identity are integers, not single digits: can need positions and can exceed . Concatenating the displayed blocks therefore fails. Accumulate their shifted values with ordinary addition, normalizing each digit position by Euclidean division: a coefficient becomes the digit , with carry passed to the next position. Subtraction likewise propagates borrows. Although for these nonnegative integers, intermediate digitwise subtraction can still borrow.
In the four-digit Karatsuba worked multiplication, grouping by base gives unnormalized coefficients , written from high to low. Normalize from the right: ; ; . The final groups are , yielding . The zero group must retain its two positions.
Since , their sums are less than and can need digits. Allocate that extra digit before the third recursive product; discarding it can change the answer. The GMP manual describes this sum growth and uses a difference-based form to avoid it.[ref]
Karatsuba multiplication Created 2026-09-28 Updated 2026-10-13
Karatsuba multiplication is a divide-and-conquer algorithm for multiplication of integers. Splitting each operand into two blocks seems to require four smaller products; the Karatsuba three-product identity recovers the two cross terms together from just three products. Repeating that saving through recursion changes the time complexity from quadratic to , where counts digits in a fixed positional notation. The exponent is about : the benefit comes from the algorithm, even though each splitting step needs more addition and subtraction.
The Karatsuba worked multiplication below computes using , , and . The last operand already shows why “half-size” needs care: Karatsuba carry handling and Karatsuba recursion termination account for the extra digit. Karatsuba digit-operation cost states the operation model; Karatsuba practical crossover explains why the asymptotic saving alone does not select a useful threshold.
The original 1962 paper presents a binary numeral system automaton construction: its Theorem 2 and proof reduce multiplication to taking squares of numbers, then reduce a larger square of a number to three smaller squares of numbers. Its footnote explicitly addresses the extra digit in a sum of halves. The sequential time complexity analysis below uses a different operation model from that paper's automaton size and depth bounds, including its Boolean circuit realization without feedback.[ref]
Compute exactly three smaller products,
The distributive property gives , so the cross coefficient is . Recombine by
The saving is that and are never separately multiplied. Multiplying a digit block by or shifts its position in positional notation; it does not require another general integer multiplication. Addition of the shifted results still requires Karatsuba carry handling.
Figure 1.
Three products recover the Karatsuba cross coefficient
. The arrows carry exact integer values for the Karatsuba worked multiplication. Only the three coloured product boxes require recursive multiplication; the lower boxes use subtraction, digit shifts and addition. Details.