Karatsuba Multiplication
Suppose you need to multiply two 1,000-digit numbers β like the RSA keys used in your browser right now. The grade-school long multiplication approach requires about 1,000,000 single-digit multiplications. That's already slow, and for 10,000-digit numbers it becomes 100,000,000.
In 1960, a 23-year-old mathematician named Anatoly Karatsuba found a trick that cuts this dramatically. The idea: split each number in half and use 3 multiplications instead of 4. At first that sounds like a rounding error. But recursively applied β splitting again and again β 3 vs 4 compounds into O(n1.585) vs \(O(n^2)\). For large enough numbers, the gap is enormous.
The setup
Take two n-digit numbers x and y. Split each at the midpoint:
x = a Β· 10n/2 + b, and y = c Β· 10n/2 + d, where a and c are the high halves, b and d are the low halves.
Then: x Β· y = ac Β· 10n + (ad + bc) Β· 10n/2 + bd
The naive approach computes four products: ac, ad, bc, bd.
The trick: save one multiplication
Observe that (a+b)(c+d) = ac + ad + bc + bd.
So: ad + bc = (a+b)(c+d) β ac β bd
We only need three products: \(P_1\) = ac, \(P_2\) = bd, \(P_3\) = (a+b)(c+d). Then ad + bc = \(P_3\) β \(P_1\) β \(P_2\) for free. The final result: \(P_1\) Β· 10n + (\(P_3\) β \(P_1\) β \(P_2\)) Β· 10n/2 + \(P_2\).
The additions and shifts cost \(O(n)\). Only the three recursive multiplications drive the recurrence.
Why does saving one multiplication help so much?
Recurrence: T(n) = 3Β·T(n/2) + \(O(n)\). By the Master Theorem with a=3, b=2: n\(\log_2\)3 β n1.585 dominates \(O(n)\), so Case 1 applies. T(n) = O(n1.585).
With four multiplications it'd be T(n) = 4Β·T(n/2) + \(O(n)\) β O(n2). That one extra multiplication per level compounds across \(O(\log n)\) levels into a fundamentally different complexity class.
Modern fast multiplication algorithms (SchΓΆnhage-Strassen, Harvey-Hoeven) use FFT to push further toward \(O(n \log n)\), but Karatsuba was the first crack in the belief that \(O(n^2)\) was optimal β a classic divide and conquer breakthrough β and it's still the go-to for moderately large numbers.