Subquadratic 3SUM
3SUM is a simple puzzle. You have a list of whole numbers, some positive and some negative. The puzzle asks if three of them add up to exactly 0. In the list , the answer is yes, because .
The plain method tries every group of three. With 1,000 numbers, that is about 166 million groups. A better method sorts the list first. Then, for each number, it looks for a matching pair by moving in from both ends of the list.
Here is that method for . We need two numbers from the rest of the list that add up to 7. Start with the two ends of the list. If the sum is too big, drop the largest number. If it is too small, drop the smallest number.
| Pair | Sum | Next step |
|---|---|---|
| and 11 | 8 | Too big, so drop 11 |
| and 8 | 5 | Too small, so drop |
| 2 and 8 | 10 | Too big, so drop 8 |
| 2 and 5 | 7 | This is the match |
Each number takes one pass through the list, so the work is about steps. With 1,000 numbers, that is about one million steps. For decades, the only improvements saved small factors, far less than any fixed power of .
| Problem | Older | New |
|---|---|---|
| 3SUM | ||
| All-pairs shortest paths |
The 3SUM hypothesis says that is essentially the limit. It says that no method takes steps, or for any fixed small number , the Greek letter epsilon. A power does not have to be a whole number, and is a little less than . A similar hypothesis says the same about for all-pairs shortest paths, the problem of finding the cheapest route between every pair of towns.
Researchers used these hypotheses as working assumptions. They showed that if some other problem had a fast method, then 3SUM would have one too. Many problems in geometry were explained in this way, such as checking if three out of many points lie on one straight line.
Josh Alman and Virginia Vassilevska Williams report that both hypotheses are false. Their method takes about steps, for whole numbers no larger than a fixed power of . Claude discovered the method, and the authors then simplified and extended it.
The saving is very small. With a billion numbers, is only about 1.6% less than . A count like this also leaves out a fixed multiplier, and the authors say that this multiplier is enormous. So the method is potentially impractical. What changes is the theory: is not the limit for 3SUM.
The method uses matrices. A matrix is a table of numbers. An operation called the matrix product combines two matrices into a third. The new method computes selected entries of that third matrix faster than computing them one by one. Researchers had already built conversions from 3SUM to tasks of this kind, to show that those tasks are hard. The same conversions now run as a fast method for 3SUM.