[英]Compare growth rate of two functions. (Tricky)
I need to compare the growth rate of the following functions: 我需要比较以下功能的增长率:
f(n)=2^n and g(n)=n^log(n) (when n approaches positive infinity). f(n)= 2 ^ n且g(n)= n ^ log(n)(当n接近正无穷大时)。
Is this even possible? 这甚至可能吗?
Let n = 2^k
. 设n = 2^k
。 We have: 我们有:
2^n = 2^(2^k)
n^log(n) = (2^k)^log(2^k) = (2^k)^(k log 2)
= 2^(k^2 log 2)
Now compare 2^k
to k^2 log 2
. 现在比较2^k
到k^2 log 2
。 This is a basic comparison: 2^k
is bigger for all large enough k
. 这是一个基本比较:对于所有足够大的k
2^k
更大。
Taking log
(base 2) for both the functions, we get log(f(n)) = n
where log(g(n)) = (log(n))^2
. 对两个函数取log
(基数2),得到log(f(n)) = n
,其中log(g(n)) = (log(n))^2
。
Now, (log(n))^2 = o(n)
and log
being a monotonically increasing function, we have 现在, (log(n))^2 = o(n)
和log
是单调递增函数,我们有
g(n) = o(f(n))
, ie, f(n)
grows much faster for large values of n
. g(n) = o(f(n))
,即对于大的n
值, f(n)
增长得快得多。
Here is another way to prove it more rigorously: 这是另一种更严格证明它的方法:
Let L = lim{n->inf} g(n) / f(n) = lim{n->inf} n^(log(n))/2^n
. 令L = lim{n->inf} g(n) / f(n) = lim{n->inf} n^(log(n))/2^n
。
Hence log (L) = lim{n->inf} log^2(n) - n
因此log (L) = lim{n->inf} log^2(n) - n
` = lim{n->inf} n*(log^2(n)/n) - 1)`
` = lim{n->inf} (n) * lim{n->inf} (log^2(n)/n) - 1)`
` = lim{n->inf} (n) * (0-1)`
` = lim{n->inf} (-n) = -inf`
=> L = 2^(-inf) = 0
According to the alternative definition of o(n)
(small o
, see here: https://en.wikipedia.org/wiki/Big_O_notation ), 根据o(n)
的替代定义(小o
,见这里: https : //en.wikipedia.org/wiki/Big_O_notation ),
L = lim{n->inf} g(n) / f(n) = 0
=> g(n) = o(f(n))
. => g(n) = o(f(n))
。
Here are the figures comparing f(n)
and g(n)
growth in original and in log scale: 以下是比较原始和对数尺度的f(n)
和g(n)
增长的数字:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.