Algorithms · Strassen, Karatsuba and Closest Pair of Points
Strassen's Matrix Multiplication
This chapter is about divide-and-conquer tricks that beat the "obvious" algorithm by reducing the number of recursive multiplications. Three classic results:
- Strassen's matrix multiplication — multiply two matrices in instead of .
- Karatsuba's integer multiplication — multiply two -digit numbers in instead of .
- Closest pair of points — find the closest pair among points in the plane in instead of .
All three share one idea: split the problem in half, and make fewer recursive calls than the naive divide-and-conquer would need. The Master Theorem then converts "fewer calls" into "smaller exponent."
1.1 The naive (schoolbook) method
To multiply two matrices and to get :
Each entry needs multiplications and additions. There are entries, so:
- Scalar multiplications:
- Scalar additions:
So the schoolbook method is .
Divide-and-conquer the obvious way. Split each matrix into four blocks:
Then
That is 8 block multiplications and 4 block additions. Recurrence:
By the Master Theorem: , , . Since and , this is Case 1, giving . No gain — as expected.
1.2 Strassen's idea: 7 multiplications instead of 8
Strassen found a way to compute the same four blocks using only 7 block multiplications, at the cost of more additions. Define:
Then the four blocks of are formed by additions/subtractions only:
Verify one of them (this is the kind of check a good exam answer includes). Expand :
Sum: the terms cancel (), the terms cancel (), the terms cancel (), the terms cancel (), and the terms cancel (). What remains is exactly . ✓
1.3 Recurrence and complexity
Master Theorem: , , . Compute . Since , this is Case 1:
Why the term? The 7 products are computed recursively; the additions/subtractions of blocks cost at each level (a constant number of block additions, each ). So the non-recursive work is .
1.4 Counting scalar multiplications
The whole point of Strassen is that the number of scalar multiplications drops. If = number of scalar multiplications to multiply two matrices:
Solving: .
| Matrix size | Strassen multiplications | Schoolbook |
|---|---|---|
So for : 7 multiplications; : 49; : 343. (These are the numbers GATE asks for.)
Additions count. At each level Strassen forms the 10 sums/differences that feed and then assembles with more: 18 block additions, each of scalar additions, i.e. per level (the 8-product divide-and-conquer needs only 4 block additions per level). The addition count therefore satisfies , , which solves to . Check : additions (versus for the schoolbook product). So for one step Strassen trades more additions (18 vs 4) for fewer multiplications (7 vs 8); asymptotically both counts are , below the schoolbook . The heavy additions and memory traffic are why it only wins for large in practice (the crossover is machine-dependent and not something to quote as a fixed exam fact).
1.5 Comparison table
| Method | Recurrence | Multiplications for | Time complexity |
|---|---|---|---|
| Schoolbook (8-product D&C) | |||
| Strassen (7-product D&C) |
Convention note. Some texts write the Strassen recurrence with the additive term as (block additions), others as ; both give the same answer. Some write . The exponent is convention-independent. GATE uses .