{
  "id": "strassen-algorithm",
  "title": "Strassen Algorithm",
  "lang": "en",
  "source_lang": "en",
  "summary": "Strassen’s algorithm multiplies matrices using seven recursive block products instead of eight, reducing arithmetic complexity below cubic time.",
  "category": "computer-science",
  "subcategory": "algorithms-theory",
  "type": "concept",
  "aliases": [
    "Strassen’s algorithm",
    "Strassen matrix multiplication"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/strassen-algorithm/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/strassen-algorithm/",
      "json": "https://aiwiki.page/zh/strassen-algorithm.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The Strassen algorithm is an algorithm for multiplying two matrices that uses fewer arithmetic operations than the conventional method for sufficiently large inputs. Introduced by Volker Strassen in 1969, it replaces the eight multiplications in a standard two-by-two block product with seven multiplications, together with additional additions and subtractions. Applied recursively, this gives an arithmetic operation count of \\(O(n^{\\log_2 7})\\), approximately \\(O(n^{2.8074})\\), for multiplying two \\(n\\times n\\) matrices, rather than the conventional \\(O(n^3)\\)."
    },
    {
      "heading": "Background and significance",
      "text": "For matrices \\(A\\) and \\(B\\), the conventional matrix multiplication rule computes each entry of their product \\(C\\) as\n\n\\[C_{ij}=\\sum_{k=1}^{n}A_{ik}B_{kj}.\\]\n\nFor two square matrices of order \\(n\\), this requires \\(n^3\\) scalar multiplications and \\(n^2(n-1)\\) scalar additions. Blocking the computation can improve memory locality, but ordinary blocking does not change this arithmetic count.\n\nStrassen’s method demonstrated that cubic arithmetic complexity is not an unavoidable property of matrix multiplication. Its central insight is that intermediate products can combine information needed for several output entries, provided that extra additions and subtractions remove unwanted terms afterward.\n\nThe result became a landmark in computational complexity and initiated extensive research into faster matrix multiplication. It also has practical uses, although a lower asymptotic operation count does not guarantee a shorter execution time for every matrix size or computing platform."
    },
    {
      "heading": "The seven-product construction",
      "text": "Partition the input matrices into equally sized square blocks:\n\n\\[A= \\begin{pmatrix} A_{11}&A_{12}\\\\ A_{21}&A_{22} \\end{pmatrix}, \\qquad B= \\begin{pmatrix} B_{11}&B_{12}\\\\ B_{21}&B_{22} \\end{pmatrix}.\\]\n\nOrdinary block multiplication would compute\n\n\\[\\begin{aligned} C_{11}&=A_{11}B_{11}+A_{12}B_{21},\\\\ C_{12}&=A_{11}B_{12}+A_{12}B_{22},\\\\ C_{21}&=A_{21}B_{11}+A_{22}B_{21},\\\\ C_{22}&=A_{21}B_{12}+A_{22}B_{22}. \\end{aligned}\\]\n\nThis requires eight block multiplications. Strassen instead computes seven intermediate products:\n\n\\[\\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}\\]\n\nThe output blocks are then reconstructed as\n\n\\[\\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}\\]\n\nExpanding these expressions using distributivity recovers the ordinary block multiplication formulas. The construction works for scalar entries as well as for matrix blocks, which makes recursive application possible.\n\nThis version uses seven block multiplications and eighteen block additions or subtractions: ten to form the multiplicands and eight to reconstruct the result. It exchanges one expensive multiplication for additional, comparatively inexpensive additions.\n\nAlgebraic requirements\n\nThe identities require associative multiplication, distributivity, and additive inverses. They therefore work over a ring, including familiar settings such as integers, real numbers, complex numbers, and arithmetic modulo an integer.\n\nMultiplication need not be commutative: the formulas preserve the order of factors. This is essential because matrix multiplication itself is generally noncommutative.\n\nThe use of subtraction means that the formulas do not apply directly to every algebraic system supporting a notion of matrix multiplication. In particular, a system without additive inverses cannot automatically use this construction."
    },
    {
      "heading": "Recursive structure and complexity",
      "text": "Strassen’s method is a divide-and-conquer algorithm. Each multiplication of two \\(n\\times n\\) matrices is reduced to seven multiplications of matrices of order \\(n/2\\), plus quadratic work for block additions and subtractions.\n\nFor power-of-two dimensions, its arithmetic time complexity satisfies\n\n\\[T(n)=7T(n/2)+\\Theta(n^2).\\]\n\nSolving the recurrence gives\n\n\\[T(n)=\\Theta(n^{\\log_2 7}), \\qquad \\log_2 7\\approx 2.807354922.\\]\n\nIf recursion continues down to individual entries, the number of scalar multiplications is exactly\n\n\\[7^{\\log_2 n}=n^{\\log_2 7}.\\]\n\nThe additions and subtractions also contribute \\(O(n^{\\log_2 7})\\) operations over the complete recursion tree, so they do not change the exponent.\n\nThis analysis counts arithmetic operations under a unit-cost model. For exact integers of growing magnitude, the cost of each arithmetic operation depends on operand bit length; arithmetic complexity is therefore distinct from full bit complexity.\n\nDimensions that are not powers of two\n\nA simple implementation pads both matrices with zeros to the next power-of-two dimension, performs the multiplication, and extracts the required output. Padding increases the dimension by less than a factor of two, so it preserves the asymptotic bound.\n\nIts practical cost can nevertheless be substantial. Implementations may instead handle odd-sized boundaries separately or use more flexible partitions. Rectangular products can also use Strassen-style techniques, but indiscriminate padding to a large square may introduce enough unnecessary work to eliminate the advantage."
    },
    {
      "heading": "Practical implementation",
      "text": "Hybrid recursion\n\nPractical implementations generally stop recursion at a chosen block size and use an optimized conventional multiplication routine for the remaining products.\n\nThis hybrid approach avoids the overhead of recursively manipulating very small blocks. The crossover depends on several factors:\n\n- processor arithmetic throughput;\n- the efficiency of the conventional multiplication kernel;\n- matrix dimensions and data type;\n- memory bandwidth and cache capacity;\n- temporary storage and data layout;\n- the number of recursive levels.\n\nThere is no universal matrix size above which Strassen’s method is always faster.\n\nMemory management\n\nThe intermediate sums and products require storage unless their computation is carefully scheduled. Allocating fresh arrays at every recursive call can produce substantial allocation overhead and memory traffic.\n\nA depth-first implementation can reuse workspace between recursive products and keep auxiliary storage within \\(O(n^2)\\) matrix entries. Other schedules may use more storage to expose additional concurrency. Consequently, the space complexity and practical memory footprint depend on execution order and buffer reuse, not just on the seven algebraic identities.\n\nImplementations may also combine the formation of block sums with packing data for the multiplication kernel, reducing separate passes through memory.\n\nParallel execution\n\nThe seven recursive products are independent after their input combinations are available, making them candidates for parallel execution. However, producing intermediate matrices and assembling the result introduce dependencies and memory traffic.\n\nOn multicore processors, graphics processing units, and distributed systems, performance depends on balancing arithmetic savings against communication, synchronization, and storage costs. Launching all recursive tasks simultaneously can create excessive memory demand, so practical implementations often limit parallel recursion."
    },
    {
      "heading": "Numerical behavior",
      "text": "Over exact arithmetic, Strassen’s formulas produce exactly the same mathematical product as conventional multiplication. With floating-point arithmetic, intermediate additions, subtractions, and products are rounded.\n\nThe additional combinations can magnify intermediate values or cause cancellation. As a result, Strassen multiplication can have less favorable error bounds than conventional multiplication, and its observed error depends on the input values, scaling, precision, and recursion depth.\n\nIt is nevertheless inaccurate to describe the algorithm simply as unusable or invariably numerically unstable. Normwise forward-error analyses establish bounds for Strassen-type methods. Such bounds do not imply that every individual output entry has small relative error, especially when an exact entry is close to zero.\n\nNumerical implementations may limit recursive depth or incorporate scaling. Performance comparisons are therefore incomplete unless they also specify precision and acceptable numerical error."
    },
    {
      "heading": "Variants and later developments",
      "text": "A commonly used Strassen–Winograd variant, associated with Shmuel Winograd, retains seven block multiplications while reducing the number of block additions and subtractions from eighteen to fifteen. Its different intermediate expressions affect storage scheduling and numerical behavior. It is distinct from the Coppersmith–Winograd algorithm.\n\nLater matrix multiplication algorithms achieved asymptotic exponents below \\(\\log_2 7\\). Strassen’s algorithm is therefore not the asymptotically fastest known method. Its continuing importance lies in the combination of a relatively simple recursive construction, a clear subcubic bound, and practical applicability in suitable regimes.\n\nThe broader theoretical problem is often expressed using the matrix multiplication exponent \\(\\omega\\): the infimum of exponents for which square matrix multiplication can be performed with the corresponding asymptotic arithmetic complexity. Strassen’s construction establishes the upper bound\n\n\\[\\omega\\leq \\log_2 7.\\]\n\nIt does not establish a matching lower bound."
    },
    {
      "heading": "Applications and limitations",
      "text": "Strassen multiplication can accelerate large dense matrix products and algorithms that spend substantial time performing them. Fast matrix multiplication also informs complexity bounds for matrix inversion, determinant computation, and other problems that can be reduced to matrix multiplication.\n\nIts usefulness is more limited when:\n\n- Matrices are small: recursion and additional additions can outweigh the saved multiplications.\n- Matrices are highly rectangular: unsuitable partitioning or padding can introduce excessive work.\n- Matrices are sparse: block sums can create additional nonzero entries and undermine sparse storage advantages.\n- Memory movement dominates: fewer multiplications may not compensate for extra data transfers.\n- Numerical requirements are restrictive: intermediate growth and rounding error may require fewer recursive levels or a different method.\n\nFor these reasons, Strassen’s method is typically an optional component of a tuned dense linear algebra implementation rather than a universal replacement for conventional multiplication."
    }
  ],
  "links": [
    "algorithm",
    "matrix",
    "matrix-multiplication",
    "computational-complexity",
    "recursion",
    "ring-mathematics",
    "divide-and-conquer",
    "time-complexity",
    "cpu-cache",
    "space-complexity",
    "parallel-computing",
    "graphics-processing-unit",
    "floating-point-arithmetic"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}