简体   繁体   English

寻找函数的上界

[英]Finding the upper bound of a function

Example-3 Find upper bound for f(n) = n^4 + 100n^2 + 50示例 3 找到 f(n) = n^4 + 100n^2 + 50 的上限

Solution: n^4 + 100n^2 + 50 ≤ 2n^4, for all n ≥ 11 ∴ n^4 + 100n^2 + 50 = O(n^4 ) with c = 2 and n0 = 11解:n^4 + 100n^2 + 50 ≤ 2n^4,对于所有 n ≥ 11 ∴ n^4 + 100n^2 + 50 = O(n^4 ) 且 c = 2 且 n0 = 11

In the above question the solution says n>11 and n-nought is 11. can anybody explain why is it 11?在上面的问题中,解决方案说 n>11 并且 n-nought 是 11。谁能解释为什么是 11? for reference - this is a problem from the Data Structures and Algorithms Made Easy by Narasimha Karumanchi供参考 - 这是 Narasimha Karumanchi 的 Data Structures and Algorithms Made Easy 中的一个问题

It doesn't say that n>11 it says that n4 + 100n2 + 50 ≤ 2n4 , for all n ≥ 11 .它不是说n>11而是说n4 + 100n2 + 50 ≤ 2n4 ,对于所有n ≥ 11

Is it true?这是真的吗? You can substitute n for 11 in the formula and check it yourself.您可以将公式中的n替换为11并自行检查。

How was 11 obtained? 11是怎么获得的? By solving the inequality.通过解决不等式。

It is not finding an upper bound for a function.它不是找到函数的上限。 It is an asymptotic analysis of a function with big-O notation.它是对具有大 O 符号的函数的渐近分析。 Hence, the constant c = 11 does not matter for the analysis, and if you can show the inequality is valid for all n greater than any constant, for instance c = 100 , that will be accepted.因此,常数c = 11对分析无关紧要,如果您能证明不等式对所有大于任何常数的n均有效,例如c = 100 ,则将被接受。 By the way, you can show that it is true for all n > 11 by the mathematical induction.顺便说一下,您可以通过数学归纳法证明对于所有n > 11都是正确的。

f(n) = n^4 + 100n^2 + 50

Intuitively, n^4 grows very fast;直观上, n^4增长非常快; n^2 grows less fast than n^4 ; n^2增长速度不如n^4 and 50 doesn't grow at all.50根本没有增长。

However, for small values of n , n^4 < 50 ;但是,对于较小的n值, n^4 < 50 additionally, the n^2 term has a factor 100 in front of it.此外, n^2项前面有一个因子 100。 Because of this factor, for small values of n , n^4 < 100 n^2.由于这个因素,对于较小的n值,n^4 < 100 n^2。

But because we have the intuition that n^4 grows much faster than n^2 , we expect that, for n big enough, 100 n^2 + 50 < n^4 .但是因为我们直觉n^4n^2增长得快得多,所以我们预计,对于足够大的 n, 100 n^2 + 50 < n^4

In order to assert and prove this claim, we need to be more precise on what "for n big enough" means.为了断言和证明这一说法,我们需要更精确地了解“for n enough”的含义。 Your textbook found an exact value;你的教科书找到了一个准确的值; and they claimed: for n ≥ 11, 100 n^2 + 50 < n^4 .他们声称:对于 n ≥ 11, 100 n^2 + 50 < n^4

How did they find that?他们是怎么发现的? Maybe they solved the inequality for n .也许他们解决了n的不等式。 Or maybe they just intuited it by noticing that:或者也许他们只是通过注意到以下几点来直觉它:

100 n^2 = 10 * 10 * n * n`
    n^4 =  n * n  * n * n

Thus n^4 is going to be the bigger of the two as soon as n is bigger than 10.因此,一旦 n 大于 10, n^4将是两者中较大的一个。

In conclusion: as soon as n ≥ 11, f(n) < 2 n^4 .总之:只要 n ≥ 11, f(n) < 2 n^4 Thus, f(n) satisfies the textbook definition for f(n) = O(n^4) .因此, f(n) 满足f(n) = O(n^4)的教科书定义。

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

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