129

In big-O notation the complexity class $O(2^n)$ is named "exponential". The complexity class $O(n!)$ is named "factorial".

I believe that $f(n) = O(2^n)$ and $g(n) = O(n!)$ means that $\dfrac{f(n)}{g(n)}$ goes to zero in the limit as $n$ goes to infinity.

Is there any known function between the factorial and exponential complexity classes?

In other words is there any known function $j(n)$ that dominates every function in $O(2^n)$, such that: $$ (j(n) \neq O(2^n)) \wedge (j(n) = O(n!)) \wedge (n! \neq O(j(n))) $$ or, informally, $j(n)$ grows asymptotically strictly faster than $2^n$ but not as fast as $n!$?

Or perhaps it has been proven that no such function can exist?

Note: this may seem like a Computer Science question, but in fact I am attempting to prove that any periodic, convergent power series must have coefficients whose inverses grow asymptotically as fast as $n!$ but not faster. I think I can show they most grow faster than $O(2^n)$, but that does not prove they are in $\Theta(n!)$ unless there is no complexity class between $O(2^n)$ and $O(n!)$.

Key Flex
  • 9,605
  • 57
    Like $\sqrt{n!}$? – Antonio Vargas Jan 08 '18 at 02:09
  • 13
    How about $O(n2^n)$? – JMoravitz Jan 08 '18 at 02:09
  • 6
    Well, $j(n)=a^n$ for $a>2$ works, but maybe you're actually interested in a function between $a^n$ and $n!$ for every $a \in \mathbb R$. – Alejandro Nasif Salum Jan 08 '18 at 02:12
  • 1
    If that is the case, @AntonioVargas 's proposal does the job. – Alejandro Nasif Salum Jan 08 '18 at 02:14
  • 38
    A standard result says that $n!$ is asymptotically equivalent to $$\sqrt{2\pi n}\left(\frac{n}{e}\right)^n$$

    With this in mind, it's rather easy to come up with examples.

    – MathematicsStudent1122 Jan 08 '18 at 02:15
  • 16
    $2.00001^n$ is in $O(n!)$ but not in $O(2^n)$. – Paul Jan 08 '18 at 08:40
  • 1
    $O({(2+\epsilon)}^n)$ is not the same complexity class as $O(2^n)$ -- $O$ only ignores linear differences. There are other complexity measures that treat $O(x^n)$ for fixed $x$ as the "same", but big-$O$ is not one of them. $lim_{n->\infty} {\frac{2}{2+\epsilon}}^n = 0$. – Yakk Jan 08 '18 at 15:15
  • Well, I believe you shall be looking for functions that grow faster than any $a^n$ for constant $a>1$. Basically, you have that $n! \sim \sqrt{n} n^n / e^n$, which can give you a nice starting point. – yo' Jan 08 '18 at 16:47
  • Obviously there are infinitely many. What is not obvious (not too difficult however) is an analytical expression of one. – Ataulfo Jan 09 '18 at 18:32
  • 3
    Please note that "$O(f)$" is not a complexity class. It is an order of growth of functions. A complexity class is a set of languages decidable under some resource bound. – David Richerby Jan 10 '18 at 14:31
  • I think $ (j(n) \neq O(2^n)) \wedge (j(n) = O(n!)) \wedge (n! \neq O(j(n))) $ was actually the wrong expression. The sentence with that expression actually asks a different question than was asked in words in an earlier part of this question. – Timothy Jan 11 '18 at 20:19

7 Answers7

208

Hint For exponential you have the growth $$\frac{a_{n+1}}{a_n}=\mbox{constant}$$

For the factorial you have the growth $$\frac{b_{n+1}}{b_n}=n$$

Take any function $g(n)$ which grows to infinity slower than $n$ and set $$\frac{c_{n+1}}{c_n}=g(n)$$

For example, $g(n)=\sqrt{n}$ gives the example $\sqrt{n!}$ given by AntonioVargas.

Another interesting example is $g(n)=\ln(n)$ which gives $$d_n =\prod_{k=2}^n \ln(k)$$

ShreevatsaR
  • 42,279
N. S.
  • 134,609
  • Interesting example! Would you know how its continuous analog is defined? Might be cool to include that if so. – user541686 Jan 09 '18 at 16:11
  • 2
    @Mehrdad $\ln(d_n) = \sum_{k=2}^n \ln ( \ln (k))$. So the "natural" continuous analog should be $$\ln(f(x)) =\int_2^x \ln( \ln(t)) dt$$ or$$f(x)=e^{\int_2^x \ln( \ln(t)) dt}$$ – N. S. Jan 09 '18 at 20:09
  • That... doesn't make sense? For $n = 2$ you have $d_n = \ln 2$ but $f(2) = e$... – user541686 Jan 09 '18 at 20:22
  • 1
    @Mehrdad Note that i am looking at the rate of growth, not at the value at some point, so when I say $f(x)=e^{\int_2^x \ln( \ln(t)) dt}$, if you want to start at a certain value, you should look at $f(x)=C e^{\int_2^x \ln( \ln(t)) dt}$ instead. – N. S. Jan 09 '18 at 23:04
  • Does it even maintain the rate of growth? I get $\frac{f(x + 1)}{f(x)} = e^{\int_x^{x+1} \ln \ln t, dt} \neq \ln(x + 1) = \frac{d_{n+1}}{d_n}$... or is there a simplification I'm missing? If it's wrong, it shouldn't be surprising, because it seems like something you would want to use multiplicative calculus for (or the equivalent operations in ordinary calculus). – user541686 Jan 10 '18 at 04:02
  • @Mehrdad If $h(x)$ is a decreasing function and $\lim_{x \to \infty} h(x)=0$ then $\int_2^n h(t) dt - \left( h(2)+h(3)+...+h(n) \right)$ is convergent. This is why the integral test works. So yes, up to multiplication by constant, they have the same growth rate. – N. S. Jan 10 '18 at 04:06
  • I'm not sure you're doing this correctly. To be crystal clear, are you saying that I am wrong to claim $\frac{f(x + 1)}{f(x)} = e^{\int_x^{x+1} \ln \ln t, dt}$, or are you saying that I am wrong to claim $e^{\int_x^{x+1} \ln \ln t, dt} \neq \ln(x + 1)$? Could you pin down exactly which of my above steps is wrong, and provide me the correct expression for it? – user541686 Jan 10 '18 at 04:09
  • @Mehrdad No, I am saying that for a continuous version of the function, I would not think about the growth rate as "$\frac{f(x+1)}{f(x)}$". What the integral test tells me is that $\ln(f(n))-\ln(d_n)$ is convergent. If you denote the limit by $C$, this gives $$\lim_{n \to infty} \frac{f(n)}{d_n}=e^C$$ Or equivalently, and this is what I understand by "up to multiplication by a constant", setting $g(x)=e^{-c}f(x)$ you have $g$ is a continuous function and $$\lim_{n \to \infty} \frac{g(n)}{d_n}=1 $$ – N. S. Jan 10 '18 at 04:18
  • 1
    @Mehrdad If you want a continuous function such that $f(n+1)/f(n)=\frac{d_{n+1}}{d_n}$ that can be achieved in uncountably many ways (since you are just asking for continuous function which takes certain values on the integers), but IMO those are artificial. – N. S. Jan 10 '18 at 04:22
  • 1
    Ohh, I see, okay thanks. That's definitely not what I meant by continuous though haha. :-) (I haven't even seen people view it that way at all, so this is my first time.) I meant in the same sense that the gamma function is the continuous analog of a factorial -- i.e., giving the same results, but being defined over the reals rather than the integers, and satisfying some desirable regularity conditions (to make it unique as you just mentioned). – user541686 Jan 10 '18 at 04:22
  • 1
    @Mehrdad In that sense I don't know any. But it is interesting that if we replace $\prod$ in the definition of $d_n$ with $\sum$ you actually get $\ln(n!)$ :) – N. S. Jan 10 '18 at 04:27
  • 1
    Oh haha, yeah. :) – user541686 Jan 10 '18 at 04:34
87

Given any two positive functions $f$ and $g$ such that $\frac{f(x)}{g(x)}$ tends to zero, let $j(x) = \sqrt{f(x)g(x)}$ (this is the geometric mean of $f$ and $g$).

Then $\frac{f}{ j} = \frac{j}{ g} = \sqrt{\frac{f}{g}}$ which must also tend to zero, so $j$ is an intermediate complexity class.

G_B
  • 1,401
  • 8
  • 11
  • 8
    Best answer. It follows that the number of different growth rates between two different growth rates is not bounded. – miracle173 Jan 08 '18 at 12:40
  • 5
    Nice, but why don't you mention that this is just the geometric mean? – leftaroundabout Jan 08 '18 at 16:53
  • 3
    @leftaroundabout Because any $j(x) = f^p(x) g^q(x)$ with $p, q \in \mathbb{R}^+, ; p+q=1$ and $f, g$ as stated by OP would satisfy his request of growing faster than exponential but slower than factorial, and so there are uncountably many examples. The geomean is just the special case $p=q=0.5$. – Iwillnotexist Idonotexist Jan 08 '18 at 20:55
  • 1
    @leftaroundabout You're welcome to mention it! I just didn't think the name added much to the answer, but YMMV. – G_B Jan 08 '18 at 23:01
  • 1
    I agree that it doesn't seem particularly important to mention that this is the geometric mean (although it certainly wouldn't hurt if you chose to do so). – David Z Jan 08 '18 at 23:35
  • @DavidZ Have added it; like you say, it doesn't hurt. – G_B Jan 08 '18 at 23:49
  • Nice, but what if I wonder if any complexity class growing faster than any polynomial and slower than any exponential exists? – Ahmet Bilal Apr 01 '19 at 13:09
  • @AhmedBilâl I think f(x)=exp(x/ln(x)) works? – G_B Apr 02 '19 at 03:30
  • yep. i think any class in between 2^{theta(logx)} and 2^{theta(x)} also works, however geometric mean tecnique does not help. – Ahmet Bilal Apr 02 '19 at 03:42
  • @AhmedBilâl Sure it does, you just have to take the GM of the fastest polynomial and the slowest exponential ;-) – G_B Apr 02 '19 at 03:47
27

For variety, here are two striking examples of such a $j$ that demonstrate just how narrow the big-theta complexity classes are when applied to such rapidly growing functions:

  • $j(n) = 3^n$
  • $j(n) = (n-1)!$

The first demonstrates something you may have misunderstood: exponential growth is a much wider complexity class than merely $O(2^n)$.

17

A lot of the answers given are actually "like" factorial: if you lump all the exponential-growth functions into a single class, it would make sense to lump things like $n!$ and $\sqrt{n!}$ in a single class too. But there are still classes in between.

What do I mean by this? Functions like $2^n$ and $3^n$ are really not very similar if you compare them directly - $3^n$ grows much much faster and isn't close to being $O(2^n)$. But what makes them similar is that their logarithms have the same growth - $\log(2^n)=\Theta(\log(3^n))=\Theta(n)$.

Now $\log(n!)=\Theta(n\log n)$, and so it would make sense to put all functions with this property - such as $\sqrt{n!}$ or $(n/2)!$ or $n^n$ - into a general "factorial" class in the same way as we define the exponential class.

With this way of thinking, it's clear that there is still something in between, which grows faster than anything exponential-like but slower than anything factorial-like. You just need to pick some function $f(n)$ which grows faster than $\Theta(n)$, but slower than $\Theta(n\log n)$, such as $f(n)=n\sqrt{\log n}$ or $f(n)=n\log\log n$, and then $\exp(f(n))$ is in an intermediate class.

The second choice I suggested for $f(n)$ gives you something quite natural: $\exp(n\log\log n)=(\log n)^n$. (This is the same type of function as N.S.'s second example above.)

  • 2
    Logarithms having the same growth is sufficient to put exponentials all into a single complexity class, because logarithm is the anti-function of an exponent. Logarithm is not the anti-function of factorial, so it does not follow that the family you've defined as "factorial-like" fall into a single complexity class. – Ben Voigt Jan 11 '18 at 00:54
  • 1
    @BenVoigt I think the fact that logarithms happen to be inverses of exponentials is a red herring here. I am simply defining my complexity classes based on $f(n)$ being in the same class as $g(n)$ if $\log(f(n))=\Theta(\log(g(n))$. This notion is the natural one to use to define not only the exponential class $\log(f(n))=\Theta(n)$ but also the polynomial class $\log(f(n))=\Theta(\log n)$. – Especially Lime Jan 11 '18 at 10:41
  • But we normally don't put all polynomials in the same class -- at least constant time and linear time receive separate classes. – Ben Voigt Jan 11 '18 at 15:26
  • Constant time is not in the polynomial class I defined above. – Especially Lime Jan 11 '18 at 15:50
10

For any functions $f$ and $g$, $\sqrt{fg}$ has a growth that's between $f$ and $g$.

Rchn
  • 540
1

To add to Especially Lime's answer, there are a couple of common kinds of classes of asymptotic behaviour relative to any given class. As $n \overset{\in\mathbb{N}}\to \infty$, we often naturally encounter not just $O(f(n))$ but also $f(n)^{O(1)}$ and $f(n)^{o(1)}$. (For definition of $o(1)$ see Landau notation.) And there are still asymptotic growth rates between $\log\log(n)^{Θ(1)}$ and $\log(n)^{Θ(1)}$, such as $(\log\log(n))^{\log\log\log(n)}$.

user21820
  • 60,745
1

I know of many exponential functions but only one factorial function. The title means "is there a function that grows asymptotically faster than all exponential functions and slower than the factorial function" but the body asks whether there is a function that grows faster than the function $f(x) = 2^x$ and slower than $f(x) = x!$ so I will give an answer that answers both questions. It's obvious that if the answer to the first question is yes then so is the answer to the second question so I will just prove that the answer to the first question is yes. I will show that $f(x) = \sqrt(x!)$ grows asymptotically faster than all exponential functions and slower than $x!$. Every real exponential function with domain $R$ is of the form $a \times b^x$ where $b$ is a positive real number but when $b$ is 0 or negative, the domain is not all of $R$. Suppose for some real numbers $a$ and $b$, $g(x) = a \times b^x$ for all "$x$ where $a \times b^x$ is defined. For integers more than the floor function of $b^2$ the factorial function grows more rapidly than $g(x) = a \times b^x$. Therefore, the factorial function grows asymptotically faster than all exponential functions.

Timothy
  • 860