简体   繁体   English

对于所有自然数m,f(n)= log(n)^ m是O(n)吗?

[英]f(n) = log(n)^m is O(n) for all natural numbers m?

A TA told me that this is true today but I was unable to verify this by googling. 电讯局长告诉我今天是真的,但是我无法通过谷歌搜索来证实这一点。 This is saying functions like log(n)^2, log(n)^3, ... , log(n)^m are all O(n). 这就是说log(n)^ 2,log(n)^ 3,...,log(n)^ m之类的函数都是O(n)。

Is this true? 这是真的?

Claim 要求

The function f(n) = log(n)^m , for any natural number m > 2 ( m ∈ ℕ+ ) is in O(n) . 对于任何自然数m > 2m ∈ ℕ+ )的函数f(n) = log(n)^mO(n)

Ie there exists a set of positive constants c and n0 such that the following holds: 即,存在一组正常数cn0 ,使得以下内容成立:

 log(n)^m < c · n, for all n > n0, { m > 2 | m ∈ ℕ+ } (+) 

Proof 证明

  • Assume that (+) does not hold, and denote this assumption as (*) . 假设(+) 成立,并表示这个假设为(*)

Ie, given (*) , there exists no set of positive constants c and n0 such that (+) holds for any value of m > 2 . 即,给定(*) ,不存在一组正常数cn0 ,使得(+)对于m > 2任何值均成立。 Under this assumption, the following holds, that for all positive constants c and n0 , there exists a n > n0 such that (thanks @Oriol): 在此假设下, 对于所有正常数cn0 ,存在一个n > n0使得 (感谢@Oriol):

 log(n)^m ≥ c · n, { m > 2 | m ∈ ℕ+ }                       (++)

Now, if (++) holds, then the inequality in (++) will hold also after applying any monotonically increasing function to both sides of the inequality. 现在,如果(++)成立,则在将任何单调递增的函数应用于不等式的两边之后, (++)的不等式也将成立。 One such function is, conveniently, the log function itself 方便地, log功能本身就是其中一种功能

在此处输入图片说明

Hence, under the assumption that (++) holds, then, for all positive constants c and n0 , there exists a n > n0 such that the following holds 因此,假设(++)成立,那么对于所有正常数cn0 ,存在n > n0使得以下成立

 log(log(n)^m) ≥ log(c · n), { m > 2 | m ∈ ℕ+ }

 m · log(log(n)) ≥ log(c · n), { m > 2 | m ∈ ℕ+ }           (+++)

However, (+++) is obviously a contradiction: since log(n) dominates (wrt growth) over log(log(n)) , 但是, (+++)显然是一个矛盾:由于log(n) )在log(log(n))占主导(wrt增长log(log(n))

在此处输入图片说明

we can—for any given value of m > 2 —always find a set of constants c and n0 such that (+++) (and hence (++) ) is violated for all n > n0 . 我们可以-对于任何给定的m > 2值-总是找到一组常数cn0 ,使得对所有n > n0都违反(+++) (因此也违反了(++) )。

Hence, assumption (*) is proven false by contradiction, and hence, (+) holds. 因此,假设(*)被矛盾证明是错误的,因此(+)成立。

=> for f(n) = log(n)^m , for any finite integer m > 2 , it holds that f ∈ O(n) . 对于f(n) = log(n)^m =>,对于任何m > 2有限整数,它都保持f ∈ O(n)

Yes. 是。 If the function it's f(n) , it means m is a parameter and f does not depend on it. 如果函数为f(n) ,则表示m是参数,而f不依赖于此。 In fact, we have a different f_m function for each m . 实际上,对于每个m我们都有一个不同的f_m函数。

f_m(n) = log(n)^m

Then it's easy. 那很容易。 Given m ∈ ℕ , use L'Hôpital's rule repeatively 鉴于m ∈ ℕ ,用洛必达法则 repeatively

        f_m(n)            log(n)^m            m * log(n)^(m-1)
limsup ──────── = limsup ────────── = limsup ────────────────── =
 n→∞      n        n→∞       n         n→∞           n

          m*(m-1) * log(n)^(m-2)                m!
= limsup ──────────────────────── = … = limsup ──── = 0
                 n                       n→∞    n

Therefore, f_m ∈ O(n) . 因此, f_m ∈ O(n)

Of course, it would be different if we had f(m,n) = log(n)^m . 当然,如果我们有f(m,n) = log(n)^m会有所不同。 For example, taking m=n , 例如,取m=n

        f(n,n)            log(n)^n
limsup ──────── = limsup ────────── = ∞
 n→∞      n        n→∞       n

Then f ∉ O(n) 然后f ∉ O(n)

In many ways it is more intuitive that for any positive integer m we have: 从许多方面来看,更直观的是,对于任何正整数m我们都有:

x^m = O(e^x)

This says that exponential growth dominates polynomial growth (which is why exponential time algorithms are bad news in computer programming). 这表示指数增长主导多项式增长(这就是为什么指数时间算法在计算机编程中是个坏消息)。

Assuming that this is true, simply take x = log(n) and use the fact that then x tends to infinity if and only if n tends to infinity and that e^x and log(x) are inverses: 假设这是正确的,只需取x = log(n)并使用以下事实:当且仅当n趋于无穷大且e^xlog(x)为逆时, x趋于无穷大:

log(n)^m = O(e^log(n)) = O(n)

Finally, since for any natural number m , the root function n => n^(1/m) is increasing, we can rewrite the result as 最后,由于对于任何自然数m ,根函数n => n^(1/m)都在增加,我们可以将结果重写为

log(n) = O(n^(1/m))

This way of writing it says that log(n) grows slower than any root (square, cube, etc.) of n , which more obviously corresponds to e^n growing faster than any power of n . 写它的这样说log(n)的增长比任何根(平方,立方等)慢n ,这更为明显对应e^n增长速度比任何力量更快速n


On Edit: the above showed that log(n)^m = O(n) followed from the more familiar x^m = O(e^x) . 编辑时:上面显示log(n)^m = O(n)从更熟悉的x^m = O(e^x) To convert it to a more self-contained proof, we can show the later somewhat directly. 为了将其转换为更独立的证明,我们可以直接显示后者。

Start with the Taylor series for e^x : e^x的泰勒级数开始:

e^x = 1 + x/1! + x^2/2! + x^3/3! + ... + x^n/n! + ...

This is known to converge for all real numbers x . 已知它对所有实数x都收敛。 If a positive integer m is given, let K = (m+1)! 如果给出正整数m ,则令K = (m+1)! . Then, if x > K we have 1/x < 1/(m+1)! 然后,如果x > K ,则我们有1/x < 1/(m+1)! , hence ,因此

x^m = x^(m+1)/x < x^(m+1)/(m+1)! < e^x

which implies x^m = O(e^x) . 这意味着x^m = O(e^x) (The last inequality in the above is true since all terms in the expansion for e^x are strictly positive if x>0 and x^(m+1)/(m+1)! is just one of those terms.) (上面的最后一个不等式是正确的,因为如果x>0x^(m+1)/(m+1)!只是这些项之一,则e^x扩展中的所有项都严格为正。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM