Loading...
How 7 cleverly chosen block products replace 8 naive multiplications to break the O(n^3) barrier.
Multiply two n x n matrices faster than classical triple-loop O(n^3). Use algebraic decomposition on 2 x 2 block matrices to reduce multiplication count.
Partition A and B into 4 submatrices each (quadrants):
Classical approach requires 8 sub-matrix multiplies (Aij * Bij combos). Strassen derives 7 products M1..M7 using sums/differences which still span all necessary combinations.
Recombine into result quadrants:
1function strassen(A, B):2 if n == 1: return A*B3 partition A,B into 4 submatrices4 compute 7 products P1..P75 combine into result matrix C6 return C
T(n) = 7T(n/2) + O(n^2)
Master Theorem => O(n^(log2 7)) ~ O(n^2.807).
Benefit emerges for sufficiently large n due to added overhead in additions.