r/AskComputerScience • u/Woah_Mad_Frollick • Jul 09 '26
Why don’t we see high exponent polynomial algorithms?
Most polynomial time algorithms I’ve seen have, in practice, small exponents (like 2 to maybe 10). Is there some theoretical reason why this is? Or is it principally selection bias? And is there any rigorous way we could distinguish between those two possible explanations?
16
Upvotes
23
u/ElectrSheep Jul 09 '26 edited Jul 09 '26
Most of the comments here seem to be answering why we don't intentionally create inefficient polynomial time algorithms. However, I interpreted the question to be more along the lines of "If it's possible to find exact solutions to a problem in less than exponential time, why do we rarely see best-known algorithms in polynomial time with exponents greater than three or four?" That is a much more interesting question.
That being said, there are classes of metaheuristic algorithms that run in polynomial time with large exponents for finding approximate solutions to problems that would otherwise require exponential time for exact solutions. This can be intuited as the ability to construct variants of higher accuracy at the cost of larger exponents.
23
u/iOSCaleb Jul 09 '26
An algorithm with O( n35 ) complexity is one that we’d like to avoid.
5
u/ghjm MSCS, CS Pro (20+) Jul 09 '26
I take your question to be: why do we so rarely see higher power polynomial time complexity in computer science research? This is a completely different and more interesting question than why we don't use higher power polynomial algorithms in actual software development (simply: because they're incredibly inefficient), which is what most people are answering.
I think we can approach this intuitively by thinking of O(nx) as meaning the algorithm has x nested loops, where x is a constant. Obviously there are lots of algorithms that involve things other than nested loops, but this gives us a framework for talking about the problem.
We can easily see that searching for a value in an unsorted list requires one loop, so it is O(n1). A naive sorting algorithm, which searches the full list for the smallest item, then the reduced list for the next-smallest, and so on, has two nested loops, so it is O(n2). Matrix multiplication has three nested loops and is O(n3).
However, as soon as the depth of recursion depends on n, we've lost the ballgame: we can no longer take x to be constant, so our time complexity is O(2n) or some such. So to find a higher-order polynomial time complexity, we need an operation that needs a large but constant number of nested loops, that does not depend on the input data.
One obvious example is tensor (also known as hypermatrix) multiplication. If you're multiplying an nxnxn order-3 tensor by an nxn matrix, this operation is O(n4). And you can get any polynomial exponent by just changing the sizes of the tensors (and the various other complexities of tensor math, like that there are many different kinds of multiplication, etc). (And also note that the n in big-O notation is supposed to be the input size in bits, not the dimensionality, so my example should really be O(n4/3).)
So I think the answer to your question is simply that our desire for generality pushes these algorithms into exponential complexity. A computer science researcher looking at the problem of multiplying two 100th-order tensors will naturally start thinking about it as a problem of nth-order tensors. There aren't that many interesting research problems that correspond to specifically 100th-order tensors. I think these problems do exist - I recently saw a mention of some kind of map coloring algorithm that was O(n120) - but they just don't come up that often.
8
u/a_cloud_moving_by Jul 09 '26
I was intrigued by this question and I don't really agree with everyone else here saying that the reason for not discussing higher polynomials is their inefficiency. To state the obvious, even for small inputs, factorial/exponential are so much worse and...those are discussed frequently. The point is not what is or is not efficient, it's what complexity is 'unbeatable' for some problems. Some problems, in the general case, can't beat exponential, no matter what you do.
So the question is, are there problems where you can't beat "high" polynomial bounds, like, 2^12 or 2^35. If so, what are those problems?
I think that is a very interesting question. I suspect there's a deeper math reason why we don't see that, but I have nowhere near enough background to be sure
4
u/Fosdran Jul 09 '26
It would be hilarious, if someone managed to prove p = np, but the polynomial solvers for the problems now known as np complete, can be proven to at least have an exponent of 1024 or something like this.
All textbooks would change from "lets assume p != np", to "lets pretend p != np, because fuck the counter-evidence"
3
u/ParsingError Jul 09 '26 edited Jul 09 '26
I might be wrong about this but I think it's partly a definition thing, like an O(n2) algorithm is pretty easy to happen by just having an algorithm that has to do a full scan of a set of data for each element in the set. It's nesting a linear function (scanning the data set) inside of a linear function (producing an output) where the cost of both scales off of the same value.
In practice it's fairly easy to imagine an algorithm that descends into multiple linear functions and scales horribly, like multi-table SQL joins where the keys aren't indexed, but because those tables are all different sizes, they don't scale off of the same value and so aren't high-exponent functions. I guess you could MAYBE classify them as that if you take for granted that some of the table sizes will increase proportionally to each other (which could easily be true but isn't strictly-required by the algorithm definition the way that say a selection sort is).
So, it's not just "high-exponent algorithms are bad" but also that something like O(n3) algorithm just requires much more specific circumstances than O(n2), more specific than exponential or factorial scaling for that matter, which both scale much worse.
3
u/jeffgerickson Jul 11 '26
Oh, they’re out there. Some examples mined from StackExchanges:
But as a general rule, people like simple results that they can actually use (so these results don’t get much attention). And finding algorithms like this is usually harder than finding a faster algorithm for a different problem (so they aren’t discovered often).
1
u/DTux5249 Jul 09 '26 edited Jul 09 '26
If you have an algorithm that's O(n10), that's the point at which you give the fuck up and start your solution over again from scratch.
Like, modern processors can only do 108 to 109 operations per second. If you have an O(n10) function run on an input size of 30 (which is miniscule), your app is gonna be frozen for 6 days MINIMUM. Quite possibly more.
Any such algorithms are frankly worthless. You literally can't use them in practice, and you don't really learn anything from them.
4
u/pgetreuer Jul 09 '26
For an algorithm runtime proportional to n11, consider how aggressively this grows for n = 10, 11, 12... Supposing whatever proportionality constant, we'll pass a century-long runtime at a modest value of n.
On the other hand, if an application has n < 10, then the algorithm's asymptomatic complexity isn't relevant. =)
1
u/green_meklar Jul 10 '26
From what I understand, the exponent can be sensitive to the model of computation. Constant-time-access memory machines (which is more-or-less what we consider most real-world computers) can achieve polynomial speedups over Turing machines. Meanwhile, some algorithms are analyzed as if integer arithmetic is constant-time for any size of integer, whereas real-world computers have hardware limitations on integer size and must incur polynomial slowdowns to compute arbitrarily large integers (and if you actually treated large integers as arbitrary bitwise data stores instead of numbers, you might be able to come up with some tricks for additional polynomial-time speedups by doing massively parallel bit operations, etc). Likewise, if I understand correctly, the gap between polynomial time and superpolynomial time tends to survive swapping out these assumptions about computation models.
Moreover, we sometimes massage the input size to make the exponent on the polynomial small. For instance, you can analyze the same matrix manipulation algorithm based on the length N of each side of the matrix, or the number M of elements in the matrix (where M = N2), and your algorithm would look 'faster' in terms of the second measurement, not because it's faster in practice, but because you expressed the input size differently.
It seems straightforward to construct algorithms that take high polynomial time, but I guess those just tend not to be useful...? They'd be pretty slow to run, anyway.
1
u/PvtRoom Jul 10 '26
Monte Carlo does it.
It's a simulation method, where 1 simulation is run for every valid combo of inputs (and subject to rules)
Monte Carlo crash tests?
speed, collision type, dummy type (each seat, so 5x that), car type, car variant, child seat type (4x). that's effectively O(x13 ).
1
u/gabha22 Jul 10 '26
In what world is 10 a small exponent
1
u/navetzz Jul 10 '26
There are some. They just have no practical use.
A n10 algorithm would be absolutely attrocious since n =10 you are already at 10s of billions of operations...
This is also why if P=NP where to be true it wouldn t have any of the consequences people think it would.
1
u/ThrowAway24Okt Jul 10 '26
for n^k you would have k nested for-loops where you iterate over n.
So you would need a problem where you actually have to look at k elements of the data set and do some operation with them. That doen't happen very often or it's a very artificial example.
If you actually have to do something with many elements of the data set, you quickly have to do that operation on every subset and not subsets of k elements and you get something like O(m^n) or O(n^n)
1
u/Esseratecades Jul 09 '26
We're purposely trying to optimize algorithms so that the exponent gets smaller. The larger the exponent is, the less useful the algorithm is.
1
u/cgarret3 Jul 09 '26
The entire point of computer science is to reduce complexity below the square as often as possible
0
u/mxldevs Jul 09 '26
There's no award for creating inefficient algorithms
2
u/[deleted] Jul 09 '26
[removed] — view removed comment