
O(n³) naive matrix multiplication
Image: Michaelbetancourt, CC BY-SA 3.0, via Wikimedia Commons
O(n³) naive matrix multiplication
The naive approach to matrix multiplication requires n³ field operations for multiplying two n × n matrices, which is represented as Θ(n³) in big O notation. This straightforward method is often taught in schools but is not the most efficient for large matrices.
The discovery of Strassen's algorithm in 1969 marked a significant improvement over the naive method. Strassen's algorithm reduces the number of required field operations, demonstrating that faster algorithms can exist beyond the basic schoolbook approach.
As of January 2024, the best known asymptotic complexity for matrix multiplication algorithms is O(n².371339), surpassing Strassen's original algorithm. This improvement highlights the ongoing quest for more efficient algorithms in theoretical computer science.
Example
Multiplying two 2 × 2 matrices using naive method: [[1, 2], [3, 4]] and [[5, 6], [7, 8]] requires 4 field operations (1*5 + 2*7, 1*6 + 2*8, 3*5 + 4*7, 3*6 + 4*8).
Understanding the time complexity of matrix multiplication is crucial for optimizing numerical algorithms and improving computational efficiency in various applications.
Matrix multiplication algorithm
Tiling divides matrices into smaller blocks, loading them into shared memory for efficient matrix multiplication
Graph (abstract data type)
Time complexity of BFS and DFS: O(V + E)
Binary search
Time complexity of binary search: O(log n) — halves search space each step
Kolmogorov complexity
Kolmogorov complexity is uncomputable
merge sort: O(n log n) always
Merge sort consistently performs at O(n log n) time complexity for any input size
Ordinary least squares
OLS minimizes squared differences
One email a day: 5 concepts + the 5 stories that matter →
Swipe through 100 ML concepts daily
Open TickerNews