简体   繁体   English

比较指数函数的增长率?

[英]Comparing growth rate of exponential function?

Suppose we have two functions f(n) = 2 2 n+1 and g(n)=2 2 n . 假设我们有两个函数f(n)= 2 2 n + 1和g(n)= 2 2 n I want to compare their growth rates of these two functions using two different methods. 我想使用两种不同的方法比较这两个函数的增长率。

Method One: Take the Ratio 方法一:计算比率

Let's define t(n) = f(n) / g(n). 让我们定义t(n)= f(n)/ g(n)。 Then 然后

t(n) = f(n) / g(n) t(n)= f(n)/ g(n)

= 2 2 n+1 / 2 2 n = 2 2 n + 1/2 2 n

= 2 2 n + 1 - 2 n = 2 2 n + 1-2 n

= 2 2 n = 2 2 n

So we'll assume that f(n) grows much faster than g(n). 因此,我们假设f(n)的增长快于g(n)。

Method Two: Use Logarithms 方法二:使用对数

As before, let t(n) = f(n) / g(n). 如前所述,令t(n)= f(n)/ g(n)。 Now, let's take log base two of both sides: 现在,让我们以两边的两个日志为基础:

lg t(n) = lg (f(n) / g(n)) lg t(n)= lg(f(n)/ g(n))

= lg (2 2 n+1 / 2 2 n ) = lg(2 2 n + 1/2 2 n

= lg 2 2 n+1 - lg 2 2 n ) = lg 2 2 n + 1 -lg ​​2 2 n

= 2 n+1 - 2 n = 2 n + 1-2 n

Now, let's take the log base two of both sides: 现在,让我们以双方的两个日志为基础:

lg lg t(n) = (n + 1) lg 2 / n lg 2 lg lg t(n)=(n +1)lg 2 / n lg 2

= (n + 1) / n =(n + 1)/ n

Ignoring constant term, we get lg lg t(n) = 1, which is a constant, so f(n) and g(n) should have the same growth rate. 忽略常数项,我们得到lg lg t(n)= 1,这是一个常数,因此f(n)和g(n)应该具有相同的增长率。

Why am I getting the wrong answer using Method Two ? 为什么使用方法二会得到错误的答案?

Where you went wrong: "ignoring the constant term". 您出问题的地方:“忽略常数项”。

t(n) = (n+1)/n = n/n + 1/n = 1 + 1/n > 1 t(n)=(n + 1)/ n = n / n + 1 / n = 1 + 1 / n> 1

I think your error is assuming the following: 我认为您的错误是假设以下情况:

If log log f(x) / log log g(x) is a constant, then f(x) = Θ(g(x)). 如果对数log f(x)/对数log g(x)是常数,则f(x)=Θ(g(x))。

Here's an easy counterexample to this. 这是一个简单的反例。 Let f(x) = x 2 and g(x) = x. 设f(x)= x 2和g(x)= x。 Then 然后

log log f(x) = log log x 2 = log (2 log x) = log 2 + log log x 日志日志f(x)=日志日志x 2 =日志(2日志x)=日志2 +日志log x

and

log log g(x) = log log x 日志日志g(x)=日志日志x

Here, log log f(x) and log log g(x) differ just by a constant (namely, log 2), but clearly it's not true that f(x) and g(x) grow at the same rates. 在这里,日志log f(x)和日志log g(x)只是一个常数(即log 2)不同,但是显然f(x)和g(x)以相同的速率增长并非正确。 In other words, it's not safe to ignore constants after taking the logs of the growth rates of two functions. 换句话说,在取两个函数的增长率的对数后忽略常数是不安全的。

There's a second error in your logic. 您的逻辑中还有第二个错误。 If you compute f(n) / g(n), you get 如果计算f(n)/ g(n),则得到

2 2 n + 1 / 2 2 n 2 2 n +1 / 2 2 n

= 2 2 n+1 - 2 n = 2 2 n + 1-2 n

= 2 2 n = 2 2 n

If you take the log of this twice, you get 如果您两次记录此日志,则会得到

lg lg 2 2 n lg lg 2 2 n

= lg 2 n = lg 2 n

= n = n

So it's not even true that the log log of the ratio is (n + 1) / n; 因此,比率的对数对数甚至不是(n +1)/ n; instead, it's n, which still tends onward toward infinity. 取而代之的是n,它仍趋于无穷大。 This would also tell you that f(n) grows much more rapidly than g(n). 这也将告诉您f(n)的增长比g(n)快得多。

Hope this helps! 希望这可以帮助!

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

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