Strassen's algorithm for matrix multiplication
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
Strassen's algorithm is a groundbreaking method for matrix multiplication that significantly reduces the complexity of multiplying two matrices, as compared to the conventional approach. Introduced by Volker Strassen in 1969, this algorithm marked a paradigm shift in computational mathematics, providing vital insights and inspiring future developments in efficient computation.
Understanding Matrix Multiplication
Before delving into Strassen's algorithm, it's pivotal to understand the standard matrix multiplication method. For two matrices and of dimensions , their product is calculated using the formula:
For each of the entries in the resultant matrix , this traditional method requires multiplications and additions, resulting in an overall time complexity of .
The Essence of Strassen's Algorithm
Strassen's algorithm reduces the number of necessary matrix multiplication operations. The key idea is to partition each of the input matrices into four sub-matrices. For simplicity, assume and are square matrices where is a power of two. The matrices are split as follows:
The product matrix is then composed of four blocks:
The blocks are computed through:
With these products, the sub-matrices of are derived as:
• • • •
Instead of eight multiplications, Strassen's algorithm performs only seven, thereby improving efficiency.
Complexity Analysis
The advantage of Strassen's approach lies in its reduced multiplicative operations. The theoretical time complexity is:
Using the Master Theorem, it can be deduced that:
This is a significant improvement over the classical complexity, particularly for large matrices.
Example
Let's demonstrate Strassen's method for two matrices:
Following Strassen's steps:
• • • • • • •
The resulting matrix :
• • • •
Thus, .
Limitations and Extensions
- Divide-and-Conquer Approach: Strassen’s method inherently suits matrices where is a power of 2. Padding with zeros is often used for arbitrary dimensions, which may complicate implementation.
- Numerical Stability: Compared to conventional methods, Strassen's algorithm may be less stable numerically due to subtractions that may amplify errors, especially for floating-point operations.
- Practical Performance: Despite its reduced theoretical complexity, the constant factors in Strassen’s algorithm often make it less efficient for smaller matrices. Thresholding is used in practice, where classical methods are used for matrices below a certain size to optimize performance.
- Extensions: Numerous algorithms building upon Strassen's foundations, such as the Coppersmith-Winograd algorithm, have emerged, further pushing down the time complexity for matrix multiplication.
Key Points Summary
| Feature | Standard Method | Strassen's Algorithm |
| Multiplications | ||
| Additions/Subtractions | More (due to decomposition and combination) | |
| Complexity | ||
| Numerical Stability | High | Potentially lower |
| Use Case | Best for small matrices | Efficient for large matrices, especially where is a power of 2 |
Strassen's algorithm opened avenues in algorithmic optimizations and remains instrumental in computing disciplines where large-scale linear algebraic operations are performed.
Related reading
- Strategy to find duplicate entries in a binary search tree
- Strategy with regard to how to approach this algorithm?
- string comparison with the most similar string
- String Distance Matrix in Python
- Strategy to find your best route via Public Transportation only?
- String interning in .NET Framework - What are the benefits and when to use interning
- string of integers puzzle
- String permutations rank data structure

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.