Simple Algorithm
Algorithms & Data Structures · Optimal · 28 min

Fast Multiplication: Karatsuba to Strassen

Fewer multiplications by clever splitting, and the race for ω.

In 1960 Andrey Kolmogorov conjectured that multiplying two nn-digit numbers needs on the order of n2n^2 digit operations, as in the schoolbook method. Within about a week, Anatoly Karatsuba, a student in his seminar, found a way with about n1.585n^{1.585}. The same trick, one fewer product per split, gave Strassen's matrix algorithm in 1969 and started a race that is still running.

What you’ll learn

  • Derive Karatsuba's three-product identity and solve its recurrence to Θ(nlog⁡23)\Theta(n^{\log_2 3}).
  • Explain Toom–Cook multiplication as evaluation and interpolation, and place Schönhage–Strassen, Fürer and Harvey–van der Hoeven on the timeline to O(nlog⁡n)O(n \log n).
  • Verify Strassen's seven products and solve T(n)=7T(n/2)+Θ(n2)T(n) = 7T(n/2) + \Theta(n^2).
  • Define the matrix multiplication exponent ω\omega, state the bounds known as of 2025, and explain why the record algorithms are not used in practice.

Karatsuba: three products instead of four

Split two nn-digit numbers in base BB into halves of m=n/2m = n/2 digits: x=x1Bm+x0x = x_1 B^m + x_0 and y=y1Bm+y0y = y_1 B^m + y_0. Then xy=x1y1B2m+(x1y0+x0y1)Bm+x0y0xy = x_1 y_1 B^{2m} + (x_1 y_0 + x_0 y_1) B^m + x_0 y_0: four half-size products plus additions and shifts, so T(n)=4T(n/2)+O(n)=Θ(n2)T(n) = 4T(n/2) + O(n) = \Theta(n^2), no better than schoolbook. Karatsuba saves one product.

DerivationKaratsuba's identity
  1. xy=z2B2m+z1Bm+z0,z2=x1y1,z0=x0y0,z1=x1y0+x0y1xy = z_2 B^{2m} + z_1 B^m + z_0,\qquad z_2 = x_1 y_1,\quad z_0 = x_0 y_0,\quad z_1 = x_1 y_0 + x_0 y_1

    Name the three coefficients of the product:

  2. (x1+x0)(y1+y0)=z2+z1+z0⟹z1=(x1+x0)(y1+y0)−z2−z0(x_1 + x_0)(y_1 + y_0) = z_2 + z_1 + z_0\quad\Longrightarrow\quad z_1 = (x_1 + x_0)(y_1 + y_0) - z_2 - z_0

    The middle coefficient needs no product of its own:

  3. T(n)=3 T(n/2)+O(n)⟹T(n)=Θ(nlog⁡23)≈Θ(n1.585)T(n) = 3\,T(n/2) + O(n)\quad\Longrightarrow\quad T(n) = \Theta\big(n^{\log_2 3}\big) \approx \Theta(n^{1.585})

    Three products of (about) half size, plus O(n)O(n) additions and shifts. Since log⁡23>1\log_2 3 > 1, the leaves dominate:

Step1234×56781234 \times 5678 with B=10B = 10, m=2m = 2
Splitx1=12x_1 = 12, x0=34x_0 = 34, y1=56y_1 = 56, y0=78y_0 = 78
z2=x1y1z_2 = x_1 y_1, z0=x0y0z_0 = x_0 y_0672672 and 26522652
(x1+x0)(y1+y0)(x_1 + x_0)(y_1 + y_0)46×134=616446 \times 134 = 6164
z1z_16164−672−2652=28406164 - 672 - 2652 = 2840
Result672⋅104+2840⋅102+2652=7,006,652672 \cdot 10^4 + 2840 \cdot 10^2 + 2652 = 7{,}006{,}652
python
def karatsuba(x, y):                    # non-negative integers
    if x < 10 or y < 10:
        return x * y                    # base case: a single digit
    m = max(len(str(x)), len(str(y))) // 2
    x1, x0 = divmod(x, 10 ** m)         # x = x1 * 10^m + x0
    y1, y0 = divmod(y, 10 ** m)
    z2 = karatsuba(x1, y1)
    z0 = karatsuba(x0, y0)
    z1 = karatsuba(x1 + x0, y1 + y0) - z2 - z0   # one product instead of two
    return z2 * 10 ** (2 * m) + z1 * 10 ** m + z0

A teaching version in base 10 (real libraries work in base 2322^{32} or 2642^{64} and stop recursing at a few machine words). The sums x1+x0x_1 + x_0 may carry one extra digit; that changes only constants.

From Toom–Cook to O(n log n)

Karatsuba is evaluation and interpolation in disguise. Read x=x1B+x0x = x_1 B + x_0 as the polynomial X(t)=x1t+x0X(t) = x_1 t + x_0 evaluated at t=Bt = B, and likewise Y(t)Y(t). Their product X(t)Y(t)X(t)Y(t) has degree 2, so three values determine it: t=0t = 0 gives x0y0x_0 y_0, t=1t = 1 gives (x1+x0)(y1+y0)(x_1 + x_0)(y_1 + y_0), and "t=∞t = \infty" (the leading coefficient) gives x1y1x_1 y_1.

Toom–Cook (Toom, 1963; Cook, 1966) splits into kk parts: the product has degree 2k−22k - 2, so 2k−12k - 1 evaluations, each a product of numbers of n/kn/k digits, suffice. That gives T(n)=(2k−1) T(n/k)+O(n)T(n) = (2k - 1)\,T(n/k) + O(n), so Θ(nlog⁡k(2k−1))\Theta(n^{\log_k (2k-1)}): n1.465n^{1.465} for k=3k = 3 and n1.404n^{1.404} for k=4k = 4. For every ε>0\varepsilon > 0 some kk achieves O(n1+ε)O(n^{1 + \varepsilon}), but the interpolation constants grow quickly with kk.

Check your understanding

Toom-3 splits each number into 3 parts. How many products of one-third size does it need, and what running time does that give?

  1. 9 products: Θ(n2)\Theta(n^2)
  2. 5 products: Θ(nlog⁡35)≈Θ(n1.465)\Theta(n^{\log_3 5}) \approx \Theta(n^{1.465})
  3. 6 products: Θ(nlog⁡36)≈Θ(n1.631)\Theta(n^{\log_3 6}) \approx \Theta(n^{1.631})
  4. 3 products: Θ(nlog⁡n)\Theta(n \log n)
Show the answer

B. 5 products: Θ(nlog⁡35)≈Θ(n1.465)\Theta(n^{\log_3 5}) \approx \Theta(n^{1.465})

Two degree-2 polynomials have a degree-4 product, fixed by its values at 5 points, so 5 products of one-third size suffice: T(n)=5T(n/3)+O(n)T(n) = 5T(n/3) + O(n), and log⁡35≈1.465<1.585\log_3 5 \approx 1.465 < 1.585.

Evaluating at 2k−12k - 1 ordinary points cannot go further. The breakthrough was to evaluate at roots of unity, where the fast Fourier transform does all evaluations at once (see The Fast Fourier Transform):

YearAlgorithmBit operations for nn-bit integers
—schoolbookΘ(n2)\Theta(n^2)
1962Karatsuba & OfmanΘ(nlog⁡23)≈n1.585\Theta(n^{\log_2 3}) \approx n^{1.585}
1963, 1966Toom; CookO(n1+ε)O(n^{1 + \varepsilon}) for every fixed ε>0\varepsilon > 0
1971Schönhage & Strassen, an FFT over a ring of integers modulo 2k+12^k + 1O(nlog⁡nlog⁡log⁡n)O(n \log n \log \log n)
2007Fürernlog⁡n⋅2O(log⁡∗n)n \log n \cdot 2^{O(\log^* n)}
2019 (published 2021)Harvey & van der HoevenO(nlog⁡n)O(n \log n)
Times are for a multitape Turing machine (or Boolean circuits); in a word-RAM the bounds shift by logarithmic factors.

Strassen: seven products for 2 × 2 blocks

Split n×nn \times n matrices into four n2×n2\tfrac n2 \times \tfrac n2 blocks. The block formula Cij=Ai1B1j+Ai2B2jC_{ij} = A_{i1}B_{1j} + A_{i2}B_{2j} uses 8 block products and Θ(n2)\Theta(n^2) additions, so T(n)=8T(n/2)+Θ(n2)=Θ(n3)T(n) = 8T(n/2) + \Theta(n^2) = \Theta(n^3). Strassen (1969) found seven products that suffice:

DerivationStrassen's identities
  1. M1=(A11+A22)(B11+B22)M2=(A21+A22) B11M3=A11 (B12−B22)M4=A22 (B21−B11)M5=(A11+A12) B22M6=(A21−A11)(B11+B12)M7=(A12−A22)(B21+B22)\begin{aligned} M_1 &= (A_{11} + A_{22})(B_{11} + B_{22}) & M_2 &= (A_{21} + A_{22})\,B_{11} \\ M_3 &= A_{11}\,(B_{12} - B_{22}) & M_4 &= A_{22}\,(B_{21} - B_{11}) \\ M_5 &= (A_{11} + A_{12})\,B_{22} & M_6 &= (A_{21} - A_{11})(B_{11} + B_{12}) \\ M_7 &= (A_{12} - A_{22})(B_{21} + B_{22}) \end{aligned}

    Seven products of sums of blocks:

  2. C11=M1+M4−M5+M7C12=M3+M5C21=M2+M4C22=M1−M2+M3+M6\begin{aligned} C_{11} &= M_1 + M_4 - M_5 + M_7 & C_{12} &= M_3 + M_5 \\ C_{21} &= M_2 + M_4 & C_{22} &= M_1 - M_2 + M_3 + M_6 \end{aligned}

    The four blocks of CC are sums of them:

  3. M3+M5=A11B12−A11B22+A11B22+A12B22=C12M_3 + M_5 = A_{11}B_{12} - A_{11}B_{22} + A_{11}B_{22} + A_{12}B_{22} = C_{12}

    Check one: the A11B22A_{11}B_{22} terms cancel. The identities never swap the order of a product, so they hold for blocks, which do not commute, and the scheme can recurse:

  4. T(n)=7 T(n/2)+Θ(n2)⟹T(n)=Θ(nlog⁡27)≈Θ(n2.807)T(n) = 7\,T(n/2) + \Theta(n^2)\quad\Longrightarrow\quad T(n) = \Theta\big(n^{\log_2 7}\big) \approx \Theta(n^{2.807})

    Seven half-size products and 18 block additions or subtractions:

Seven is optimal for 2×22 \times 2: no bilinear algorithm uses six multiplications (Winograd, 1971; Hopcroft & Kerr, 1971). Winograd's variant of Strassen's scheme keeps the seven products and needs only 15 additions instead of 18.

Larger base cases are where searches continue. Two levels of Strassen multiply 4×44 \times 4 matrices with 72=497^2 = 49 products. Using reinforcement learning, AlphaTensor (Fawzi et al., 2022) found a scheme with 47 for arithmetic modulo 2, and in 2025 AlphaEvolve reported 48 for complex 4×44 \times 4 matrices.

The exponent ω

YearAuthorsUpper bound on ω\omega
1969Strassen2.808
1990Coppersmith & Winograd2.376
2014Le Gall2.3728639
2023Duan, Wu & Zhou2.371866
2024Vassilevska Williams, Xu, Xu & Zhou2.371552
2025Alman, Duan, Vassilevska Williams, Xu, Xu & Zhou2.371339
A selection. Every bound since the late 1980s comes from Strassen's laser method applied to powers of the Coppersmith–Winograd tensor; Ambainis, Filmus and Le Gall (2015) showed that this family of analyses cannot go below about 2.3078.
Check your understanding

Suppose someone proves ω=2\omega = 2. What exactly would that mean?

  1. Matrices can be multiplied with O(n2)O(n^2) operations
  2. For every ε>0\varepsilon > 0, matrices can be multiplied with O(n2+ε)O(n^{2 + \varepsilon}) operations
  3. Strassen's algorithm is optimal
  4. In practice, matrix multiplication is as fast as matrix addition
Show the answer

B. For every ε>0\varepsilon > 0, matrices can be multiplied with O(n2+ε)O(n^{2 + \varepsilon}) operations

ω\omega is an infimum: ω=2\omega = 2 means every exponent above 2 is achievable, not that exponent 2 itself is. The constants could grow without bound as ε→0\varepsilon \to 0, so even then practice might not change.

Key takeaways

  • Karatsuba computes three half-size products, recovering the middle coefficient as (x1+x0)(y1+y0)−z2−z0(x_1 + x_0)(y_1 + y_0) - z_2 - z_0: Θ(nlog⁡23)≈Θ(n1.585)\Theta(n^{\log_2 3}) \approx \Theta(n^{1.585}).
  • Toom–Cook evaluates at 2k−12k - 1 points and interpolates, for Θ(nlog⁡k(2k−1))\Theta(n^{\log_k(2k-1)}); FFT-based methods reached O(nlog⁡nlog⁡log⁡n)O(n \log n \log \log n) in 1971 and O(nlog⁡n)O(n \log n) with Harvey and van der Hoeven (2021).
  • Strassen's seven products for 2×22 \times 2 blocks never use commutativity, so they recurse: Θ(nlog⁡27)≈Θ(n2.807)\Theta(n^{\log_2 7}) \approx \Theta(n^{2.807}); no bilinear scheme does 2×22 \times 2 with six.
  • The exponent ω\omega satisfies 2≤ω<2.3713392 \le \omega < 2.371339 (as of 2025); whether ω=2\omega = 2 is open, and the record algorithms are far too large to use.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

How does Karatsuba obtain the middle coefficient x1y0+x0y1x_1 y_0 + x_0 y_1 with only one extra multiplication?

  1. (x1+y1)(x0+y0)−x1x0−y1y0(x_1 + y_1)(x_0 + y_0) - x_1 x_0 - y_1 y_0
  2. (x1−x0)(y1−y0)(x_1 - x_0)(y_1 - y_0)
  3. (x1+x0)(y1+y0)−x1y1−x0y0(x_1 + x_0)(y_1 + y_0) - x_1 y_1 - x_0 y_0
  4. x1y1+x0y0x_1 y_1 + x_0 y_0
Show the answer

C. (x1+x0)(y1+y0)−x1y1−x0y0(x_1 + x_0)(y_1 + y_0) - x_1 y_1 - x_0 y_0

Expanding (x1+x0)(y1+y0)(x_1 + x_0)(y_1 + y_0) gives all four cross products; subtracting the two products x1y1x_1 y_1 and x0y0x_0 y_0, which are needed anyway, leaves the middle coefficient.

Question 2

A Strassen-like algorithm for 3×33 \times 3 blocks needs 23 block multiplications (Laderman, 1976). Applied recursively, does it beat Strassen's nlog⁡27≈n2.807n^{\log_2 7} \approx n^{2.807}?

  1. Yes: 23 is far fewer than the 27 of the naive 3×33 \times 3 method
  2. No: it gives nlog⁡323≈n2.854n^{\log_3 23} \approx n^{2.854}; a 3×33 \times 3 scheme needs at most 21 products to win
  3. Yes: any exponent below 3 beats Strassen
  4. It is impossible to multiply 3×33 \times 3 blocks with fewer than 27 products
Show the answer

B. No: it gives nlog⁡323≈n2.854n^{\log_3 23} \approx n^{2.854}; a 3×33 \times 3 scheme needs at most 21 products to win

T(n)=23T(n/3)+Θ(n2)T(n) = 23T(n/3) + \Theta(n^2) gives exponent log⁡323≈2.854>2.807\log_3 23 \approx 2.854 > 2.807. To beat Strassen, log⁡3m<log⁡27\log_3 m < \log_2 7 requires m≤21m \le 21 (log⁡321≈2.771\log_3 21 \approx 2.771, while log⁡322≈2.814\log_3 22 \approx 2.814). Whether 21 or fewer products suffice for 3×33 \times 3 is unknown.

Question 3

Why do numerical linear algebra libraries mostly multiply matrices with the cubic algorithm?

  1. At practical sizes, the cubic algorithm with cache blocking runs near peak speed, while fast algorithms add memory traffic, extra additions and weaker error bounds
  2. Fast algorithms give wrong answers in floating point
  3. Fast algorithms are slower for every matrix size
  4. Strassen's algorithm only works when nn is prime
Show the answer

A. At practical sizes, the cubic algorithm with cache blocking runs near peak speed, while fast algorithms add memory traffic, extra additions and weaker error bounds

The cubic algorithm's regular access pattern maps well onto caches and vector units, and its error bounds hold entry by entry. Strassen can pay off for large matrices and appears in some implementations, but its error bounds are only normwise, and the asymptotically fastest algorithms win only for astronomically large nn.

Further reading

  • A. Karatsuba & Yu. Ofman, "Multiplication of multidigit numbers on automata," Soviet Physics Doklady 7 (1963), 595–596; Russian original 1962.
  • V. Strassen, "Gaussian elimination is not optimal," Numerische Mathematik 13 (1969), 354–356.
  • A. Schönhage & V. Strassen, "Schnelle Multiplikation großer Zahlen," Computing 7 (1971), 281–292.
  • D. Harvey & J. van der Hoeven, "Integer multiplication in time O(nlog⁡n)O(n \log n)," Annals of Mathematics 193(2) (2021).
  • J. Alman, R. Duan, V. Vassilevska Williams, Y. Xu, Z. Xu & R. Zhou, "More asymmetry yields faster matrix multiplication," SODA (2025).