Most of you have probably heard of $$$\omega$$$, the matrix multiplication exponent. Are you sure you fully understand its definition, though? I thought so too, until I started asking myself some uncomfortable questions and realized that I had some subtle misconceptions. To answer these questions, I read a bunch of papers and book chapters, and now I have some peace of mind. Let me try to scare you a bit first and then hopefully rebuild your understanding of fast matrix multiplication.
Let's start with four questions. Try to answer them before reading further.
Q1: Does there exist an $$$O(n^{\omega})$$$-time matrix multiplication algorithm?
Q2: Does there exist an $$$o(n^{\omega})$$$-time matrix multiplication algorithm?
Q3: Does there exist an $$$O(n^{\omega + 0.1})$$$-time algorithm for integer matrix multiplication?
Q4: Does there exist an $$$O(n^{\omega - 0.1})$$$-time algorithm for integer matrix multiplication?
If you had asked me a month ago, I would have been quite surprised by these answers. Now let's take a closer look at the matrix multiplication exponent and make sense of these answers.
But first: what is $$$\omega$$$? Intuitively, it should be something along the lines of "the smallest value $$$t$$$ such that $$$n \times n$$$ matrices can be multiplied in time $$$O(n^t)$$$". From this definition, the answer to the first question should clearly be "yes". However, the definition is not quite right because the relevant set of exponents may not have a minimum. The correct definition takes the infimum over all valid exponents.
There could be no single "best" matrix multiplication algorithm, but only a sequence of better and better ones. As a result, the definition only guarantees algorithms running in time $$$O(n^{\omega + \varepsilon})$$$ for every fixed $$$\varepsilon \gt 0$$$. It does not tell us whether the infimum is actually attained. So Q1 is not true by definition. It might be true, but we simply don't know.
This is why statements like "using fast matrix multiplication we solve the problem in $$$O(n^{\omega})$$$ time" are not very precise. Even though before this journey I knew that $$$\omega$$$ is an infimum and not a minimum, I never stopped to think through what that really implies. If you want a notation for an actual achievable running time, writing something like $$$\mathrm{MM}(n, n, n)$$$ is cleaner. Here we mean that we can plug in the time complexity of any specific matrix multiplication algorithm.
Time complexities of the form $$$O(n^{\omega} \cdot \log n)$$$ make even less sense. What people usually mean is that the algorithm performs $$$O(\log n)$$$ matrix multiplications, plus some lower-order work. But we are measuring small logarithmic factors while being imprecise about a much larger polynomial factor. Once you write the bound as $$$O(n^{\omega + \varepsilon} \log n)$$$, the extra $$$\log n$$$ can be absorbed into a slightly larger exponent, so this is still just $$$O(n^{\omega + \varepsilon'})$$$ for every $$$\varepsilon' \gt 0$$$.
This brings us to the second question. Even if there is a single "best" algorithm, its running time need not be exactly $$$\Theta(n^\omega)$$$. It could be $$$O(n^\omega \log n)$$$, or even $$$O(n^\omega / \log n)$$$, which is $$$o(n^\omega)$$$. Of course, the second possibility can only happen if $$$\omega \gt 2$$$, since reading the input already takes $$$\Theta(n^2)$$$ time. But until we prove that $$$\omega = 2$$$, an $$$o(n^\omega)$$$-time algorithm cannot be ruled out.
Surprisingly, we are not done yet. Given our current definition of $$$\omega$$$, the third question sounds trivial. If there is an algorithm working in time $$$O(n^{\omega + \varepsilon})$$$ for every $$$\varepsilon \gt 0$$$, we can in particular take $$$\varepsilon = 0.1$$$, right? In reality, our definition of $$$\omega$$$ is still not precise. What exact problem are we solving? What does "matrix multiplication" mean? Is it boolean matrix multiplication? Integer? Real? In what model of computation are we counting the time complexity? Turns out, $$$\omega$$$ only counts the shortest sequence of arithmetic operations computing the product of two $$$n \times n$$$ matrices. Note that the size of this sequence may depend on the set of values from which the matrix entries are taken. In other words, we need to fix the underlying field. It could be $$$\mathbb{R}$$$, $$$\mathbb{Q}$$$, $$$\mathbb{F}_p$$$, or any other one. Each specific field gives its own matrix multiplication exponent: $$$\omega(\mathbb{R})$$$, $$$\omega(\mathbb{Q})$$$, $$$\omega(\mathbb{F}_p)$$$. And when people just say $$$\omega$$$, they (most likely) mean the most general case that we normally care about: $$$\omega(\mathbb{R})$$$.
This poses two problems for us. First, there may exist a sequence of $$$O(n^{\omega + \varepsilon})$$$ arithmetic operations that computes the matrix product, but is there an actual algorithm that knows what operations to do in what order? Note that we need to know this sequence for each of the infinitely many values of $$$n$$$. Second, even if we know the list of operations, it may very well include arbitrary real numbers like $$$\sqrt{2}$$$ or $$$\pi$$$. It could be problematic for us to perform these computations exactly in our standard computational model (for example, word-RAM). Even if we use floating point numbers, we may have precision issues due to subtractions and divisions.
Let us now resolve these two issues. The first one is the easier one. Suppose we know how to multiply $$$k \times k$$$ matrices optimally for some constant $$$k$$$. Then we can use the idea behind Strassen's algorithm (the first and simplest algorithm that solves matrix multiplication in time $$$O(n^{3 - \varepsilon})$$$) to get a relatively good algorithm for arbitrarily large matrices. We split an $$$n \times n$$$ matrix into a $$$k \times k$$$ grid of blocks of size roughly $$$(n / k) \times (n / k)$$$ each and apply the scheme recursively on the blocks. It is not hard to show that by picking $$$k$$$ large enough, we can achieve time complexity $$$O(n^{\omega + \varepsilon})$$$ for any fixed $$$\varepsilon \gt 0$$$. This is pretty neat: we have no idea what the value of $$$\omega$$$ is, but we know that Strassen-like algorithms achieve almost-optimal time complexity regardless.
The harder issue is getting rid of arbitrary real coefficients. This takes a lot of work that goes beyond the scope of this blog post, but the gist is as follows. The matrix exponent is not too sensitive to the specific field at hand, and in particular $$$\omega(\mathbb{R}) = \omega(\mathbb{Q})$$$. (If you want a precise statement, one can prove that $$$\omega$$$ only depends on the field characteristic.) Therefore, in the algorithm described above, it is sufficient to consider only sequences of arithmetic operations for $$$k \times k$$$ matrices using rational coefficients. That's a big relief! Once the coefficients are rational, we can reduce the whole computation modulo some suitable prime $$$p$$$. The prime should just not divide any coefficient denominators and should be large enough that the exact integer answer can be recovered from the result modulo $$$p$$$. (Technically, this is still not enough if divisions are allowed as arithmetic operations, but once again, one can prove that we only need additions, subtractions, and multiplications.) This algorithm can now be easily implemented in $$$O(n^{\omega + \varepsilon})$$$ time on a word-RAM.
So the answer to the third question is indeed "yes". But not for a trivial definitional reason; it relies on several nontrivial facts connecting algebraic complexity over fields to actual algorithms over integers.
Finally, we move to the fourth question. The definition of $$$\omega$$$ lives in the algebraic world: it is about arithmetic complexity over $$$\mathbb{R}$$$. There is no obvious reason why the optimal word-RAM complexity of integer matrix multiplication has to match that exponent. In principle, it may be easier. So we cannot rule out an $$$O(n^{\omega - 0.1})$$$-time algorithm for integer matrix multiplication. (Of course, assuming that $$$\omega \ge 2.1$$$.)
If this blog post challenged your mental model of $$$\omega$$$, I am happy. Hopefully, you now have a more accurate one. As a final exercise, try to prove that there exists an $$$O(n^{\omega + o(1)})$$$-time algorithm for matrix multiplication. This is stronger than having an $$$O(n^{\omega + \varepsilon})$$$-time algorithm for every fixed $$$\varepsilon \gt 0$$$.








lgm peltorator orz
I didn't understand anything but would upvote because a lgm posted this
why so many downvotes to me.. just because i am a pupil? such a negative community
The Same Here friend DivineOP . just because we are a ( Newbie && pupil ) .
Fr
This is probably the workflow of the people who downvote:
see blog
see comment
made by low rated (newbie, pupil, specialist)
angy
downvote
just don't care about an internet number!
Edit: do you think I would care about downvotes? think again
i also don’t know why! i found your comment quite funny.
lol , now i have to grind to like cm/master so i get upvotes
But if you were a master you would understand everything in the blog, so you wouldn't make this comment in the first place. It's a catch 22.
Great ideas , i saved this blog in -> (favorites) for study later .
Guys ! , what's the problem here in my comment , must for me to be a -> (LGM) to write a comment ! i didn't know what is my fault , just love all people here in community ; I haven't bullied anyone here || insulted anyone , so what's the problem cause to this down vote ?
your comment adds nothing to the discussion
why do the good posts recieve downvotes and the nonsensical ones like the one above get upvotes????
For Real, I've been affected for two days about this thing; feel like your are a nothing or you're not suppose to talk here, so I've decided to not comment to anyone here, just keep on to improve my self & rate .
And I have decided I will maximize my time on studying more topics like( DP , Search Algorithms , Seg-tree .... A lot of more ) .
I hope anyone here not to discouraged anyone, Because if you do this; you can destroy his morale, and I'm sorry if you found my comment not good for you .
At Last, I would to thank peltorator, for this useful blog, about adding arbitrary ±0.1 to omega(ω) for The Time Complexity O(n^ω), and thanks for sharing DOCS about this topic for study, I'm actually look to this article(THEORY OF COMPUTING LIBRARY GRADUATE SURVEYS 5 (2013), pp. 1–60 (Fast Matrix Multiplication)) you share and try to understand the topics, so thank you, you're very useful man .
interesting!
Any recommended reading? Can you share the book chapters you said you read?
Also, is there any reason behind adding $$$\pm 0.1$$$ to $$$\omega$$$ in Q3 and Q4 instead of some other constant?
$$$0.1$$$ is arbitrary. But it should be a small enough constant so that the questions stay interesting. For example, we know that $$$\omega \lt 2.4$$$. Thus, taking constant to be $$$0.4$$$ would make both of these questions less interesting.
In terms of reading material, I would recommend this expositionary article. You could also try some chapters from this book.
Great read! You did a fantastic job breaking down the subtle differences between algebraic complexity, asymptotic limits, and actual implementations.
I wanted to add a few theoretical nuances that make the gap between pure algebra and word-RAM even crazier, especially regarding Q3 and Q4.
When scaling up the $$$k \times k$$$ algorithm, there's a huge catch with modern bounds for $$$\omega$$$ (like Coppersmith-Winograd). They don't actually compute the exact product directly; they use border rank. They compute the product plus an error term parameterized by $$$\lambda$$$, and take the limit as $$$\lambda \to 0$$$. Translating that algebraic limit into an exact sequence of rational arithmetic operations to get rid of $$$\lambda$$$ requires heavy machinery like polynomial interpolation or taking derivatives. This introduces massive overhead, making the leap to a tangible algorithm way messier than a standard Strassen block decomposition.
For Q3, computing modulo a large prime $$$p$$$ is a really neat trick to ditch arbitrary real coefficients, but we run into word-RAM bit-complexity issues. If we multiply two $$$n \times n$$$ matrices of $$$W$$$-bit integers, the max possible value in the result is $$$n \cdot 2^{2W}$$$. To avoid overflow and recover the exact integer, our prime $$$p$$$ needs $$$O(W + \log n)$$$ bits. If that blows past the machine word size, we lose our $$$O(1)$$$ arithmetic operations. We'd have to use multi-precision math or the Chinese Remainder Theorem, which adds polylog factors and complicates a strict $$$O(n^{\omega+\epsilon})$$$ time bound unless we strictly bound the integer sizes.
For Q4, the exact reason we can't rule out an integer or boolean algorithm running in $$$O(n^{\omega-0.1})$$$ is bit-packing (like the Method of Four Russians). Algebraic complexity strictly counts field arithmetic. But in the word-RAM model, we can pack multiple small integers or booleans into a single $$$w$$$-bit machine word and operate on them in parallel in one clock cycle. That hardware-level parallelism is exactly what could allow an integer algorithm to physically outpace the continuous $$$\mathbb{R}$$$ algebraic bound.
Finally, regarding the solution sketch: enumerating operation sequences to hit $$$O(n^{\omega+o(1)})$$$ is a really cool theoretical construction! But it's worth noting that checking if an arbitrary sequence of operations correctly computes a matrix product is essentially Polynomial Identity Testing (PIT). Doing PIT deterministically (which is required for a strict, non-randomized algorithm) is a notoriously hard open problem. Plus, the constant factor explosion makes it a true galactic algorithm.
Thanks again for the write-up—it's incredibly thought-provoking and definitely forces you to double-check your mental model of $$$\omega$$$!
future red coder right here
sounds ai
It is.
*banned
I guess, I should go back to 1000 math problems rn hh....
Nice blog! As a researcher one of whose main areas of study is matrix multiplication, it's nice to see people interested in this topic.
One additional remark on this post: Q2 asks whether there exists an $$$o(n^\omega)$$$ time algorithm. This question actually has a negative answer — with a technical caveat: it depends on the computation model. My answer assumes we are working in a model that restricts "computation" to arithmetic operations, but it is consistent with current knowledge that, over some Boolean models, one can go beyond $$$n^\omega$$$, for example via table lookup.
The main reason is the nice self-similarity structure of the matrix multiplication problem, as already mentioned in the post — a fixed "algorithm" for a finite matrix multiplication can bootstrap itself into a genuine algorithm working for all $$$n$$$. Indeed, Strassen's algorithm shows that the fact "$$$2 \times 2$$$ matrix multiplication can be done with 7 multiplications" already yields the estimate $$$\omega \leq \log_2 7$$$.
In hindsight, the academic community rephrased this idea through the notion of tensor rank. Glossing over some rigor, the tensor rank of $$$n \times n$$$ matrix multiplication is essentially the minimal number of "multiplications" required to multiply two such matrices. We then have two fundamental facts:
Tensor rank to algorithm (generalization of Strassen's divide-and-conquer): If $$$n \times n$$$ matrix multiplication has tensor rank at most $$$r$$$, then there is an algorithm achieving exponent $$$\log_n r$$$.
Algorithm to tensor rank: If an algorithm performs $$$T$$$ arithmetic operations to compute $$$n \times n$$$ matrix multiplication, then $$$n \times n$$$ matrix multiplication has tensor rank at most $$$O(T)$$$.
So what happens if we combine the two? Suppose there is an $$$o(n^c)$$$ time algorithm for matrix multiplication (and, as noted, we assume it only performs arithmetic operations). Then $$$N \times N$$$ matrix multiplication can be done in $$$o(N^c)$$$ operations; for sufficiently large $$$N$$$, this means $$$T \lt N^c$$$, so there is an algorithm achieving exponent $$$\log_N T \lt c$$$.
I deliberately avoided using the notation $$$\omega$$$ in the argument above, because the modern definition of $$$\omega$$$ is itself given through tensor rank: $$$\omega = \inf_{n \gt 1} \log_n r_n$$$, where $$$r_n$$$ is the tensor rank of $$$n \times n$$$ matrix multiplication. Under this definition, $$$\omega \leq \log_n r$$$ is essentially a tautology. This definition is also less ambiguous, since its value is independent of the computational model and only depends on the characteristic of the field. And you should believe it genuinely captures the complexity of matrix multiplication — unless you think there is some completely mind-blowing way to do arithmetic without actually doing it!
Hi Baitian!
Thank you for your insight. I wanted to make the blog accessible to the general CP audience so I had to do some tradeoff between understandability and rigor. In particular, I am being a bit hand-wavy with what the "number of arithmetic operations needed to multiply matrices" means. I also decided against including tensor ranks to not scare people off :)
Indeed, if we only use arithetic operations, we cannot get $$$o(n^{\omega})$$$ in full generality. If I understand correctly, this paper implies that even $$$T = N^c$$$ is not possible.
What I meant by Q2 is slightly different though. At that point we did not yet give a precise definition of matrix multiplication, so we are treating it in an elementary sense where we either multiply integer matrices or matrices modulo some prime as we normally do in CP. So Q2 is supposed to be just a simplified version of Q4.
If I understand correctly, the reference you provided says that the answer to this question is yes if $$$\omega \gt 2$$$. (But if I understand correctly, it works only for constant-sized fields? In particular, we don't know that for boolean matrix multiplication, right?) Thank you for this link. I did not know about that!
You're right! The point is that the paper I referred to also doesn't use the definition of $$$\omega$$$ — it just talks about a specific exponent $$$\log_n r$$$ achieved by a tensor of rank $$$r$$$. People sometimes do this for convenience.
I'm also a big fan of this "speedup theorem" of Coppersmith–Winograd. It's quite a "philosophical" result and produces very interesting consequences, but it's probably not strong enough to imply what you mentioned. If one day we could prove a strengthened statement like "if $$$n \times n$$$ matrix multiplication has tensor rank $$$r$$$, then $$$\omega$$$ can be improved to $$$n^\omega \leq o(r)$$$," then it could be used to rule out the possibility $$$T = O(n^\omega)$$$ you described. As far as I know, however, the current speedup theorem only yields bounds of the form $$$n^\omega \leq (1 - o(1))\, r$$$.
hmm… I did not say $$$T=O(n^{\omega})$$$. That is probably indeed not enough. I said $$$T=n^{\omega}$$$ is not possible. or am I also wrong here?
Hmm, this is subtle. The first point is, what do you mean by $$$T = n^\omega$$$ when $$$n$$$ is small.
The second point is that an algorithm using $$$T$$$ multiplications generally only yields a tensor rank upper bound of $$$2T$$$. For instance, I recall a method for performing $$$n$$$ independent $$$2 \times 2$$$ matrix multiplications in $$$(4 + o(1))n$$$ multiplications. If this translated directly into a tensor rank bound, we would already have $$$\omega = 2$$$ — but it doesn't, because the algorithm is not a "bilinear algorithm," so the tensor rank picks up an extra factor of two.
That said, one could perhaps argue that $$$T$$$ is meant to count additions as well, with multiplications turning out to be only a small fraction of the total — in which case your statement might be defensible. But in general, this kind of ambiguity is exactly why I don't think it's a good idea to drop the big-O notation.
i see! what i meant is a specific constant value of $$$n$$$ for which exactly $$$n^{\omega}$$$ multiplications is sufficient. i now see that it is probably more subtle than i thought.
Better specify how many additions and how many multiplications separately.
No, I do not :(
Sure. SIMD operations and cache efficiency = fast, right? ʕ•ᴥ•ʔ