Splitting two integers in positional notation gives and , where shifts a block by numeral digits in fixed radix . The distributive property givesComputing separately needs four block multiplications. Merely halving the operands therefore gives an ideal recurrence relation , still with quadratic time complexity. The Karatsuba three-product identity instead computes , and , recovering the middle coefficient by two subtractions. The MIT notes present precisely this four-product versus three-product distinction.[ref]
Lecture 11: Numerics I. 6.006 Introduction to Algorithms, Fall 2011, Lecture 11: Numerics I, printed pp. 4–5, High Precision Multiplication and Karatsuba's Method
For an original small example, multiply by . Set , , , , . Four separate block products would give , , , . The three-product calculation isThe crucial reuse is that and supply the outer coefficients and also remove the unwanted terms from . There is no need to compute and separately. Expanding proves the identity. Induction extends it to Karatsuba multiplication once each smaller block product is correct and Karatsuba recursion termination supplies decreasing sizes and complete base cases.
Four block products or three: the exact ledger for
. The left ledger computes both cross products separately. The right ledger reuses and to recover their sum as . Both reconstructions yield . Counts refer to block multiplication calls at this split; the extra numeral digit in prevents interpreting all three as single-digit products. Details.The operation model matters. Let count numeral digits in fixed radix , and count single-digit multiplication, addition, subtraction and copying as constant-cost operations. The nonrecursive work on size- operands is : it includes forming sums, positional shifts and Karatsuba carry handling. Treating an arbitrarily large integer multiplication as one operation would hide the very saving being studied. The coefficients above must be shifted and added; concatenating them does not give .
In the ideal equal-half model, Karatsuba multiplication has . At depth its additional work is at most a constant times , and its leaf count is for . A geometric series gives , where . Four recursive products would instead give leaves. Saving one block product repeatedly changes the exponent, even though the combination requires extra addition and subtraction.
For the literal sum-based version, each operand sum can occupy one extra numeral digit. Its worst-case upper recurrence relation is for a nondecreasing cost envelope, above a fixed base case threshold of at least three digits. Karatsuba digit-operation cost proves that this extra digit preserves the exponent; Karatsuba operand splitting handles odd lengths and leading zero padding. For signed integers, apply the nonnegative procedure to their absolute values and restore the sign. The small ledger establishes an exact identity, while Karatsuba practical crossover explains why it alone cannot predict a speedup for two-digit operands.
Articles by others on the same topic
There are currently no matching articles.
