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. GNU MP 6.3.0 manual, §15.1.2 Karatsuba Multiplication: sum-based middle product can exceed k limbs; absolute differences and their signs
Articles by others on the same topic
There are currently no matching articles.