2
$\begingroup$

Does there exist an algorithm for which an exact complexity provably cannot be expressed in closed-form?

Here closed-form means a finite composition of addition, subtraction, product, division, factorial, power with any exponent, logarithm, trigonometric function, inverse trigonometric function, hyperbolic function, and inverse hyperbolic function. You may choose a subset of the above functions to allow in a closed-form expression; this makes the problem easier. However, the larger the set of allowed functions, the better, since this also answers the problem for the subsets.

Exact complexity is a function from the input-set to a real number. You may group the input by some property, and then study exact worst-case complexity instead (or exact best-case complexity).

Any computational model will do, as well as counting any resource (e.g. number of comparisons). To close off a trivial solution, a function without a closed-form expression cannot be a primitive operation of the computational model.

If yes, is there a simple example of such an algorithm?

$\endgroup$
6
  • $\begingroup$ In which sense do you want to understand "cannot"? I don't that there are any functions that provably have no closed form, but there are many for which we don't know them. Cost functions only known in implicit form often arise in algorithm analysis, they are nothing special. In fact, they are rather the norm once you leave textbook-land. $\endgroup$
    – Raphael
    Commented Jul 17, 2016 at 12:09
  • $\begingroup$ @Raphael Suppose you have analyzed an algorithm to have a complexity expressed by a simple geometric series. This is not closed-form, because it uses an infinite number of operations. However, you can use the formula for geometric series to bring it into a finite combination of subtraction and division, which is closed-form. There are many expressions for a function; it is sufficient for one of them to be closed-form. I want provably no closed-form. $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 12:39
  • $\begingroup$ I see. Then you should probably say "can be computed using $O(1)$ arithmetic operations" and not "commonly named functions"; the latter does not preclude me calling anything by a fancy name that looks short but only hides "infinitely many operations". Arguably, "$n!$" is such a shorthand, and even $\log$ and $\sqrt{}$. $\endgroup$
    – Raphael
    Commented Jul 17, 2016 at 12:41
  • $\begingroup$ @Raphael Factorial, square root, and logarithm are fine too. The point is to use functions which are of general use, and not tailored to a very narrow use. A good test could be whether Matlab, or any other programming language, provides an implementation to approximate it in its standard library. $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 12:46
  • $\begingroup$ Which would include many functions that are only "closed" by being aliases of other stuff. I maintain that you have only a vague idea of what you want, and thus your question is essentially not answerable. $\endgroup$
    – Raphael
    Commented Jul 17, 2016 at 14:35

4 Answers 4

4
$\begingroup$

The runtime of an algorithm that computes the Ackermann function can't be expressed using primitive recursive functions. All commonly known named functions (well, besides the Ackermann function) are primitive recursive as far as I know.

$\endgroup$
1
  • $\begingroup$ This seems like a good direction.Especially if we make the restriction that the complexity function and the functions in the closed-form expression are both non-negative-integer-valued. $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 1:12
4
$\begingroup$

Here's a trivial example of an algorithm whose running time has no closed form:

let x = f(n)
while x >= 0: x := x - 1

where n is the parameter and f is a function with no closed form and with a running time that has a closed form.

It's always possible to construct an algorithm with any (computable) running time. There are as many ways as you like to do nothing. Sure, this isn't the optimal way to do nothing, but we don't limit the study of algorithms to optimal algorithms. In fact, we need to evaluate the complexity of an algorithm before we can say whether it's optimal.

$\endgroup$
7
  • $\begingroup$ This example is indeed valid if the computational model allows, as a primitive operation, to evaluate in unit time at least some function f without a closed-form expression; I did say any computational model in the initial post. However, I would like to close off this possibility as a trivial solution, forcing the algorithm f to be further specified. Is that ok? $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 0:19
  • $\begingroup$ @Kaba What do you mean by “forcing the algorithm f to be further specified”? f isn't an algorithm, it's a function, and I don't understand what you mean by “further specified”. $\endgroup$ Commented Jul 17, 2016 at 0:26
  • $\begingroup$ The f is either an algorithm, or a primitive operation of the computational model. If I reject f being a primitive operation, then f has to be computed by an algorithm using simpler primitive operations. That algorithm f would then have to be specified. $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 0:31
  • $\begingroup$ @Kaba The answer is generic; pick any computable $f$ which does not have a "closed form". It's easy to adapt the algorithm to dominate the cost of computing $f$, whatever that may be. $\endgroup$
    – Raphael
    Commented Jul 17, 2016 at 10:38
  • $\begingroup$ @Raphael I understand. However, I want the algorithm to be specified as a sequence of primitive operations of the computational model. Sub-algorithms can be used provided they are specified. For example, an executable Python program would do. $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 11:22
0
$\begingroup$

There are plenty of simple algorithms whose running-time is unknown in any form. Therefore, their "complexity" can not be expressed in closed-form either, for suitable notions of "closed-form".

Note that, ironically, some unknown running-time functions may have closed forms in the rather vague sense of "using commonly used names for things" since some famous unknown quantities have been given names.

$\endgroup$
5
  • $\begingroup$ Not knowing the complexity of an algorithm now (say, the Collatz example in the link) does not exclude it from having a closed-form expression (in terms of functions often used in mathematics). The complexity exists as a function, and that either has a closed-form or not. I hope I did not misunderstood! $\endgroup$
    – kaba
    Commented Jul 16, 2016 at 23:52
  • $\begingroup$ @Kaba Personally, I think "unknown" precludes "closed form", but that may be a matter of perspective. (Goes to show the vagueness of the question...) $\endgroup$
    – Raphael
    Commented Jul 17, 2016 at 10:35
  • $\begingroup$ The complexity of every new algorithm begins in the "unknown" state. If I later sit down to analyze the exact complexity as n^2 + 3, then I have shown it to have a closed-form expression. However, the algorithm had this property even before I analyzed it. Again, I hope I have understood your sense of "unknown" correctly:) $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 11:10
  • $\begingroup$ @Kaba I mean "unknown" in the sense of "nobody knows, and we do not expect anyone to find out soon, and not for a lack of trying"; much like it is unknown whether P=NP even though it certainly either is or not. In the sense of the other question I link, that is. $\endgroup$
    – Raphael
    Commented Jul 17, 2016 at 12:06
  • $\begingroup$ Ok, then I understood you correctly:) $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 12:33
0
$\begingroup$

You can always find the exact number of operations by simulating the algorithm and counting all operations. If you accept that as "closed form" then obviously you can give the exact number of operations for any algorithm.

If not, then I assume that you would want to know if it is possible, after careful human analysis of the algorithm, write a program that looks at any input for the algorithm, and within reasonable time and without simulating the algorithm calculates a reasonable approximation for the running time of the algorithm for that input.

Take a simple algorithm like Quicksort. You choose a pivot, and the choice of the pivot, good or bad, massively affects the runtime. It is possible that some input data always produces a really bad choice of the pivot, and excessive runtime. Even if you introduce a pseudo-random generator to pick the pivot, there's still the possibility of excessive runtime. To give a decent approximation for the runtime for some input, you don't really have any choice but simulating the algorithm.

Well, there's probably someone more clever than me, and maybe it is possible to analyse Quicksort, but then Quicksort is a very simple algorithm.

PS. The OP has now stated that he wants the running time of an algorithm based on some simple parameter. That's nonsense. He's not going to get that. Again the example Quicksort: The runtime depends on the exact ordering of the values in the array in a highly complex way. For any implementation, I can produce an array that maximises the running time, and a single change of one item in that array total changes it.

$\endgroup$
9
  • 1
    $\begingroup$ "You can always find the exact number of operations by simulating the algorithm and counting all operations" -- Only for finitely many inputs, which prevents you from learning much about cost functions. $\endgroup$
    – Raphael
    Commented Jul 16, 2016 at 21:14
  • $\begingroup$ The complexity function exists as a function; I take it as given, as a mathematician would:) Then the problem is to develop a sufficiently tricky algorithm for the complexity to avoid closed-form expressions. $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 0:02
  • $\begingroup$ @Raphael: So what? You can only evaluate a function for finitely many arguments. $\endgroup$
    – gnasher729
    Commented Jul 17, 2016 at 11:58
  • $\begingroup$ @gnasher729 The OP clearly wants a formula in $n$ (or some other parameter), otherwise the question is rather meaningless. $\endgroup$
    – Raphael
    Commented Jul 17, 2016 at 12:08
  • $\begingroup$ @Raphael That's correct. $\endgroup$
    – kaba
    Commented Jul 17, 2016 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.