Chapter 4: Matrix Multiplication and Strassen
Source files used: Matrix Multiplication (Recitation 1, Sections 2 and 3.2); textbook Chapter 4 (chap4, Sections 4.1 and 4.2) as support. No worked examples are included.
1. Big Picture
Strassen’s algorithm is the recitation’s showcase for divide and conquer: a constant saving per level (7 multiplications instead of 8) changes the exponent of the running time.
The Convex Hull guide asked: how do you make the merge step cheap? This guide asks: how do you make the recursion tree less bushy?
New ideas:
- standard multiplication is ,
- naive block divide and conquer is still ,
- Strassen’s seven products ,
- .
2. Core Ideas
2.1 Standard Multiplication
Entry of is row of times column of . For square matrices this takes : entries, each a sum of products.
2.2 Size Is the Dimension
Running time is measured in terms of the dimension , not the number of entries . Splitting into four blocks halves , so subproblems are , not .
This is a common exam trap when writing the recurrence.
2.3 Addition Is Cheap, Multiplication Is Expensive
Adding two matrices costs ; multiplying costs much more. So saving a multiplication at the cost of a constant number of extra additions pays off.
Textbook analogy: uses one multiplication instead of two, at the cost of an extra addition. For scalars this gains nothing; for large matrices it does.
2.4 Padding to a Power of 2
The recitation makes and each by filling the extra rows and columns with 0. This is allowed because:
- each dimension grows by less than a factor of 2,
- even with multiplication, that costs less than a factor of 8, a constant.
Strip the extra zero rows and columns from at the end. Powers of 2 are needed (not just even sizes) because the recursion halves the dimension at every level.
2.5 Strassen Is Not the Fastest Known
Strassen was a powerful early application of divide and conquer and was the fastest method when discovered. Later work by Coppersmith, Winograd, Stothers, and Vassilevska Williams gives faster methods.
3. Main Governing Equations and Formulas
3.1 Entry Formula
Three nested loops, .
3.2 Block Partition
Each block has dimension .
3.3 Block Product: 8 Multiplications
Recurrence (textbook, partitioning by index calculation in ):
No improvement over three loops. Eight children per node makes a very bushy recursion tree.
3.4 Strassen’s Seven Products (Recitation Form)
Each is computed recursively with Strassen.
3.5 Recombining into
Correctness follows from expanding the products. Memory aid: and are each a sum of two products; and each use plus three others.
The textbook writes the same algorithm with ten sums and products . The count is identical; use the recitation’s form.
3.6 Operation Count per Level
(10 additions inside the , 8 in the recombination.)
For small matrices this is worse than 8 multiplications: splitting a 2-element matrix into 1-element blocks is over triple the work. In practice, switch to the standard method below some size.
3.7 Strassen Recurrence
Watershed is polynomially larger than , so case 1:
The textbook writes this as .
3.8 Beating Strassen with a Different Split
For a D&C method with subproblems of dimension and combine work, the time is whenever . It beats Strassen if and only if
Example (textbook Exercise 4.5-2): splitting into blocks beats Strassen only if , so at most 48 subproblems.
Use for “could this design be faster than Strassen?” questions.
4. Problem-Solving Workflow
- Write the cost of the standard method: .
- If is not a power of 2, pad with zeros to (constant-factor cost).
- Partition into four blocks.
- Compute recursively (Section 3.4).
- Combine into with additions only (Section 3.5).
- Strip the padding.
- Write the recurrence in terms of the dimension: .
- Solve with case 1 of the master theorem: .
5. Decision Rules / Decision Trees
5.1 Which Recurrence?
Naive block method (8 products)? →
Strassen (7 products)? →
Subproblem written as because there are 4 blocks? → wrong: size is the dimension, use
5.2 Does the Combine Work Matter?
Combine work , watershed with ? → combine work does not affect the answer (case 1)
Watershed equals ? → case 2, extra factor
5.3 Strassen in Practice
Small matrices? → standard method; 18 additions dominate
Large matrices? → Strassen; the saved multiplication dominates
6. Important Tables / Correlations Needed
6.1 Methods Compared
| Method | Products per level | Recurrence | Time |
|---|---|---|---|
| Three nested loops | (not recursive) | none | |
| Block D&C | 8 | ||
| Strassen | 7 |
6.2 Strassen Cheat Sheet
| Product | Formula | Used in |
|---|---|---|
| , | ||
| , | ||
| , | ||
| , | ||
| , | ||
7. Key Takeaways
- Standard matrix multiplication is .
- Measure size by the dimension : four blocks means , not .
- Naive block D&C: , no gain.
- Strassen: 7 multiplications and 18 additions per level.
- by case 1.
- Pad to with zeros; the cost is a constant factor.
- Memorize to and the four recombination formulas.
- Strassen loses on small matrices because of the extra additions.
- A design beats Strassen exactly when .
- Strassen is not the fastest known method today.