|
|
(675 intermediate revisions by more than 100 users not shown) |
Line 1: |
Line 1: |
| [[File:Big-O-notation.png|400px|thumb|Example of Big O notation: ''f''(''x'') ∈ O(''g''(''x'')) as there exists ''c'' > 0 (e.g., ''c'' = 1) and ''x''<sub>0</sub> (e.g., ''x''<sub>0</sub> = 5) such that ''f''(''x'') < ''cg''(''x'') whenever ''x'' > ''x''<sub>0</sub>.]]
| | This is a preview for the new '''MathML rendering mode''' (with SVG fallback), which is availble in production for registered users. |
|
| |
|
| In [[mathematics]], '''big O notation''' describes the [[asymptotic analysis|limiting behavior]] of a [[function (mathematics)|function]] when the argument tends towards a particular value or infinity, usually in terms of simpler functions. It is a member of a larger family of notations that is called '''Landau notation''', '''Bachmann–Landau notation''' (after [[Edmund Landau]] and [[Paul Gustav Heinrich Bachmann|Paul Bachmann]]),<ref name="Beigi2011">{{cite book|author=Homayoon Beigi|title=Fundamentals of Speaker Recognition|url=http://books.google.com/books?id=qIMDvu3gJCQC&pg=PA777|date=9 December 2011|publisher=Springer|isbn=978-0-387-77592-0|pages=777}}</ref><ref name="Holmes2012">{{cite book|author=Mark H. Holmes|title=Introduction to Perturbation Methods|url=http://books.google.com/books?id=EX5iNglbqB4C&pg=PA4|date=5 December 2012|publisher=Springer|isbn=978-1-4614-5477-9|pages=4–}}</ref> or '''asymptotic notation'''. In [[computer science]], big O notation is used to [[Computational complexity theory|classify algorithms]]<ref name="mitlecture">{{cite web|title=Big O Notation (MIT Lecture)|url=http://web.mit.edu/16.070/www/lecture/big_o.pdf|accessdate=7 June 2014|format=Lecture|quote=Big O notation (with a capital letter O, not a zero), also called Landau's symbol, is a symbolism used in complexity theory}}</ref><ref name=quantumcomplexity>{{cite web|last1=Mohr|first1=Austin|title=Quantum Computing in Complexity Theory and Theory of Computation|url=http://www.austinmohr.com/Work_files/complexity.pdf|accessdate=7 June 2014|page=2}}</ref> by how they respond (''e.g.,'' in their processing time or working space requirements) to changes in input size. In [[analytic number theory]], it is used to estimate the "error committed" while replacing the asymptotic size, or asymptotic mean size, of an [[arithmetic function|arithmetical function]], by the value, or mean value, it takes at a large finite argument. A famous example is the problem of estimating the remainder term in the [[prime number theorem]].
| | If you would like use the '''MathML''' rendering mode, you need a wikipedia user account that can be registered here [[https://en.wikipedia.org/wiki/Special:UserLogin/signup]] |
| | * Only registered users will be able to execute this rendering mode. |
| | * Note: you need not enter a email address (nor any other private information). Please do not use a password that you use elsewhere. |
|
| |
|
| Big O notation characterizes functions according to their growth rates: different functions with the same growth rate may be represented using the same O notation. The letter O is used because the growth rate of a function is also referred to as order of the function. A description of a function in terms of big O notation usually only provides an [[upper bound]] on the growth rate of the function. Associated with big O notation are several related notations, using the symbols [[#Related asymptotic notations|''o'', Ω, ω, and Θ]], to describe other kinds of bounds on asymptotic growth rates.
| | Registered users will be able to choose between the following three rendering modes: |
|
| |
|
| Big O notation is also used in many other fields to provide similar estimates.
| | '''MathML''' |
| | :<math forcemathmode="mathml">E=mc^2</math> |
|
| |
|
| ==Formal definition==
| | <!--'''PNG''' (currently default in production) |
| Let ''f'' and ''g'' be two functions defined on some subset of the [[real number]]s. One writes
| | :<math forcemathmode="png">E=mc^2</math> |
|
| |
|
| :<math>f(x)=O(g(x))\text{ as }x\to\infty\,</math> | | '''source''' |
| | :<math forcemathmode="source">E=mc^2</math> --> |
|
| |
|
| [[if and only if]] there is a positive constant M such that for all sufficiently large values of ''x'', the absolute value of ''f''(''x'') is at most M multiplied by the absolute value of ''g''(''x''). That is, ''f''(''x'') = ''O''(''g''(''x'')) if and only if there exists a positive real number ''M'' and a real number ''x''<sub>0</sub> such that | | <span style="color: red">Follow this [https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-rendering link] to change your Math rendering settings.</span> You can also add a [https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-rendering-skin Custom CSS] to force the MathML/SVG rendering or select different font families. See [https://www.mediawiki.org/wiki/Extension:Math#CSS_for_the_MathML_with_SVG_fallback_mode these examples]. |
|
| |
|
| :<math>|f(x)| \le \; M |g(x)|\text{ for all }x \ge x_0.</math>
| | ==Demos== |
|
| |
|
| In many contexts, the assumption that we are interested in the growth rate as the variable ''x'' goes to infinity is left unstated, and one writes more simply that ''f''(''x'') = ''O''(''g''(''x'')).
| | Here are some [https://commons.wikimedia.org/w/index.php?title=Special:ListFiles/Frederic.wang demos]: |
| The notation can also be used to describe the behavior of ''f'' near some real number ''a'' (often, ''a'' = 0): we say
| |
|
| |
|
| :<math>f(x)=O(g(x))\text{ as }x\to a\,</math>
| |
|
| |
|
| if and only if there exist positive numbers ''δ'' and ''M'' such that
| | * accessibility: |
| | ** Safari + VoiceOver: [https://commons.wikimedia.org/wiki/File:VoiceOver-Mac-Safari.ogv video only], [[File:Voiceover-mathml-example-1.wav|thumb|Voiceover-mathml-example-1]], [[File:Voiceover-mathml-example-2.wav|thumb|Voiceover-mathml-example-2]], [[File:Voiceover-mathml-example-3.wav|thumb|Voiceover-mathml-example-3]], [[File:Voiceover-mathml-example-4.wav|thumb|Voiceover-mathml-example-4]], [[File:Voiceover-mathml-example-5.wav|thumb|Voiceover-mathml-example-5]], [[File:Voiceover-mathml-example-6.wav|thumb|Voiceover-mathml-example-6]], [[File:Voiceover-mathml-example-7.wav|thumb|Voiceover-mathml-example-7]] |
| | ** [https://commons.wikimedia.org/wiki/File:MathPlayer-Audio-Windows7-InternetExplorer.ogg Internet Explorer + MathPlayer (audio)] |
| | ** [https://commons.wikimedia.org/wiki/File:MathPlayer-SynchronizedHighlighting-WIndows7-InternetExplorer.png Internet Explorer + MathPlayer (synchronized highlighting)] |
| | ** [https://commons.wikimedia.org/wiki/File:MathPlayer-Braille-Windows7-InternetExplorer.png Internet Explorer + MathPlayer (braille)] |
| | ** NVDA+MathPlayer: [[File:Nvda-mathml-example-1.wav|thumb|Nvda-mathml-example-1]], [[File:Nvda-mathml-example-2.wav|thumb|Nvda-mathml-example-2]], [[File:Nvda-mathml-example-3.wav|thumb|Nvda-mathml-example-3]], [[File:Nvda-mathml-example-4.wav|thumb|Nvda-mathml-example-4]], [[File:Nvda-mathml-example-5.wav|thumb|Nvda-mathml-example-5]], [[File:Nvda-mathml-example-6.wav|thumb|Nvda-mathml-example-6]], [[File:Nvda-mathml-example-7.wav|thumb|Nvda-mathml-example-7]]. |
| | ** Orca: There is ongoing work, but no support at all at the moment [[File:Orca-mathml-example-1.wav|thumb|Orca-mathml-example-1]], [[File:Orca-mathml-example-2.wav|thumb|Orca-mathml-example-2]], [[File:Orca-mathml-example-3.wav|thumb|Orca-mathml-example-3]], [[File:Orca-mathml-example-4.wav|thumb|Orca-mathml-example-4]], [[File:Orca-mathml-example-5.wav|thumb|Orca-mathml-example-5]], [[File:Orca-mathml-example-6.wav|thumb|Orca-mathml-example-6]], [[File:Orca-mathml-example-7.wav|thumb|Orca-mathml-example-7]]. |
| | ** From our testing, ChromeVox and JAWS are not able to read the formulas generated by the MathML mode. |
|
| |
|
| :<math>|f(x)| \le \; M |g(x)|\text{ for }|x - a| < \delta.</math>
| | ==Test pages == |
|
| |
|
| If ''g''(''x'') is non-zero for values of ''x'' [[Mathematical jargon#sufficiently large|sufficiently close]] to ''a'', both of these definitions can be unified using the [[limit superior]]:
| | To test the '''MathML''', '''PNG''', and '''source''' rendering modes, please go to one of the following test pages: |
| | *[[Displaystyle]] |
| | *[[MathAxisAlignment]] |
| | *[[Styling]] |
| | *[[Linebreaking]] |
| | *[[Unique Ids]] |
| | *[[Help:Formula]] |
|
| |
|
| :<math>f(x)=O(g(x))\text{ as }x \to a\,</math>
| | *[[Inputtypes|Inputtypes (private Wikis only)]] |
| | | *[[Url2Image|Url2Image (private Wikis only)]] |
| if and only if
| | ==Bug reporting== |
| | | If you find any bugs, please report them at [https://bugzilla.wikimedia.org/enter_bug.cgi?product=MediaWiki%20extensions&component=Math&version=master&short_desc=Math-preview%20rendering%20problem Bugzilla], or write an email to math_bugs (at) ckurs (dot) de . |
| :<math>\limsup_{x\to a} \left|\frac{f(x)}{g(x)}\right| < \infty.</math><!-- These absolute value bars may be left out. -->
| |
| | |
| ==Example==
| |
| In typical usage, the formal definition of ''O'' notation is not used directly; rather, the ''O'' notation for a function ''f'' is derived by the following simplification rules:
| |
| *If ''f''(''x'') is a sum of several terms, the one with the largest growth rate is kept, and all others omitted. | |
| *If ''f''(''x'') is a product of several factors, any constants (terms in the product that do not depend on ''x'') are omitted.
| |
| For example, let <math>f(x) = 6x^4 - 2x^3 +5</math>, and suppose we wish to simplify this function, using ''O'' notation, to describe its growth rate as ''x'' approaches infinity. This function is the sum of three terms: 6''x''<sup>4</sup>, −2''x''<sup>3</sup>, and 5. Of these three terms, the one with the highest growth rate is the one with the largest exponent as a function of ''x'', namely 6''x''<sup>4</sup>. Now one may apply the second rule: 6''x''<sup>4</sup> is a product of 6 and ''x''<sup>4</sup> in which the first factor does not depend on ''x''. Omitting this factor results in the simplified form ''x''<sup>4</sup>. Thus, we say that ''f''(''x'') is a "big-oh" of (''x''<sup>4</sup>). Mathematically, we can write ''f''(''x'') = ''O''(''x''<sup>4</sup>).
| |
| One may confirm this calculation using the formal definition: let ''f''(''x'') = 6''x''<sup>4</sup> − 2''x''<sup>3</sup> + 5 and ''g''(''x'') = ''x''<sup>4</sup>. Applying the [[#Formal definition|formal definition]] from above, the statement that ''f''(''x'') = ''O''(''x''<sup>4</sup>) is equivalent to its expansion,
| |
| :<math>|f(x)| \le \; M |g(x)|</math>
| |
| for some suitable choice of ''x''<sub>0</sub> and ''M'' and for all ''x'' > ''x''<sub>0</sub>. To prove this, let ''x''<sub>0</sub> = 1 and ''M'' = 13. Then, for all ''x'' > ''x''<sub>0</sub>:
| |
| :<math>\begin{align}|6x^4 - 2x^3 + 5| &\le 6x^4 + |2x^3| + 5\\
| |
| &\le 6x^4 + 2x^4 + 5x^4\\
| |
| &= 13x^4\end{align}</math>
| |
| so
| |
| :<math> |6x^4 - 2x^3 + 5| \le 13 \,x^4 .</math>
| |
| | |
| ==Usage==
| |
| Big O notation has two main areas of application. In [[mathematics]], it is commonly used to describe how closely a finite series approximates a given function, especially in the case of a truncated [[Taylor series]] or [[asymptotic expansion]]. In [[computer science]], it is useful in the [[analysis of algorithms]]. In both applications, the function ''g''(''x'') appearing within the ''O''(...) is typically chosen to be as simple as possible, omitting constant factors and lower order terms.
| |
| There are two formally close, but noticeably different, usages of this notation: [[Infinity|infinite]] asymptotics and [[infinitesimal]] asymptotics. This distinction is only in application and not in principle, however—the formal definition for the "big O" is the same for both cases, only with different limits for the function argument.
| |
| | |
| ===Infinite asymptotics===
| |
| Big O notation is useful when [[analysis of algorithms|analyzing algorithms]] for efficiency. For example, the time (or the number of steps) it takes to complete a problem of size ''n'' might be found to be ''T''(''n'') = 4''n''<sup>2</sup> − 2''n'' + 2.
| |
| As ''n'' grows large, the ''n''<sup>2</sup> [[term (mathematics)|term]] will come to dominate, so that all other terms can be neglected—for instance when ''n'' = 500, the term 4''n''<sup>2</sup> is 1000 times as large as the 2''n'' term. Ignoring the latter would have negligible effect on the expression's value for most purposes.
| |
| Further, the [[coefficient]]s become irrelevant if we compare to any other [[Orders of approximation|order]] of expression, such as an expression containing a term n<sup>3</sup> or n<sup>4</sup>. Even if ''T''(''n'') = 1,000,000''n''<sup>2</sup>, if ''U''(''n'') = ''n''<sup>3</sup>, the latter will always exceed the former once ''n'' grows larger than 1,000,000 (''T''(1,000,000) = 1,000,000<sup>3</sup>= ''U''(1,000,000)). Additionally, the number of steps depends on the details of the machine model on which the algorithm runs, but different types of machines typically vary by only a constant factor in the number of steps needed to execute an algorithm.
| |
| So the big O notation captures what remains: we write either
| |
| :<math>\ T(n)= O(n^2) \, </math>
| |
| or
| |
| :<math>T(n)\in O(n^2) \, </math>
| |
| and say that the algorithm has ''order of n<sup>2</sup>'' time complexity.
| |
| Note that "=" is not meant to express "is equal to" in its normal mathematical sense, but rather a more colloquial "is", so the second expression is technically accurate (see the "[[#Equals sign|Equals sign]]" discussion below) while the first is a common [[Abuse of notation#Big O notation|abuse of notation]].<ref name="Introduction to Algorithms">Thomas H. Cormen et al., 2001, [http://highered.mcgraw-hill.com/sites/0070131511/ Introduction to Algorithms, Second Edition]</ref>
| |
| | |
| ===Infinitesimal asymptotics===
| |
| Big O can also be used to describe the [[error bound|error term]] in an approximation to a mathematical function. The most significant terms are written explicitly, and then the least-significant terms are summarized in a single big O term. For example, in the exponential series,
| |
| :<math>e^x=1+x+\frac{x^2}{2}+O(x^3) \,, \qquad\text{as } x\to 0 \,, </math>
| |
| expresses the fact that the error, the difference <math>\ e^x - (1 + x + x^2/2)</math>, is smaller in [[absolute value]] than some constant times <math>|x^3|</math> when <math>x</math> is close enough to 0.
| |
| | |
| ==Properties== | |
| If the function ''f'' can be written as a finite sum of other functions, then the fastest growing one determines the order of | |
| ''f''(''n''). For example
| |
| :<math>f(n) = 9 \log n + 5 (\log n)^3 + 3n^2 + 2n^3 = O(n^3) \,, \qquad\text{as } n\to\infty \,\!.</math> <!-- note: "\,\!" forces TeX rendering -->
| |
| In particular, if a function may be bounded by a polynomial in ''n'', then as ''n'' tends to ''infinity'', one may disregard ''lower-order'' terms of the polynomial.
| |
| ''O''(''n''<sup>''c''</sup>) and ''O''(''c''<sup>''n''</sup>) are very different. If ''c'' is greater than one, then the latter grows much faster. A function that grows faster than ''n''<sup>''c''</sup> for any ''c'' is called ''superpolynomial''. One that grows more slowly than any exponential function of the form <math>c^n</math> is called ''subexponential''. An algorithm can require time that is both superpolynomial and subexponential; examples of this include the fastest known algorithms for [[integer factorization]].
| |
| ''O''(log ''n'') is exactly the same as ''O''(log(''n''<sup>''c''</sup>)). The logarithms differ only by a constant factor (since
| |
| <math>\log(n^c)=c \log n</math>) and thus the big O notation ignores that. Similarly, logs with different constant bases are equivalent.
| |
| | |
| Exponentials with different bases, on the other hand, are not of the same order. For example, <math>2^n</math> and <math>3^n</math> are not of the same order.
| |
| Changing units may or may not affect the order of the resulting algorithm. Changing units is equivalent to multiplying the appropriate variable by a constant wherever it appears. For example, if an algorithm runs in the order of ''n''<sup>2</sup>, replacing ''n'' by ''cn'' means the algorithm runs in the order of <math>c^2n^2</math>, and the big O notation ignores the constant <math>c^2</math>. This can be written as <math> c^2n^2 \in O(n^2) </math>. If, however, an algorithm runs in the order of <math>2^n</math>, replacing n with cn gives <math>2^{cn} = (2^c)^n</math>. This is not equivalent to <math>2^n</math> in general.
| |
| Changing of variable may affect the order of the resulting algorithm. For example, if an algorithm's running time is ''O''(''n'') when measured in terms of the number ''n'' of ''digits'' of an input number ''x'', then its running time is ''O''(log ''x'') when measured as a function of the input number ''x'' itself, because ''n'' = Θ(log ''x'').
| |
| | |
| ===Product===
| |
| :<math> f_1 \in O(g_1) \text{ and } f_2\in O(g_2)\, \Rightarrow f_1 f_2\in O(g_1 g_2)\,</math>
| |
| :<math>f\cdot O(g) \subset O(f g)</math>
| |
| | |
| ===Sum===
| |
| :<math> f_1 \in O(g_1) \text{ and }
| |
| f_2\in O(g_2)\, \Rightarrow f_1 + f_2\in O(|g_1| + |g_2|)\,</math>
| |
| ::This implies <math> f_1 \in O(g) \text{ and } f_2 \in O(g) \Rightarrow f_1+f_2 \in O(g) </math>, which means that <math>O(g)</math> is a [[convex cone]].
| |
| :If ''f'' and ''g'' are positive functions, <math>f + O(g) \in O(f + g)</math> | |
| | |
| ===Multiplication by a constant===
| |
| :Let ''k'' be a constant. Then:
| |
| :<math>\ O(k g) = O(g)</math> if ''k'' is nonzero.
| |
| :<math>f\in O(g) \Rightarrow kf\in O(g). </math>
| |
| | |
| ==Multiple variables==
| |
| Big ''O'' (and little o, and Ω...) can also be used with multiple variables.
| |
| To define Big ''O'' formally for multiple variables, suppose <math>f(\vec{x})</math> and <math>g(\vec{x})</math> are two functions defined on some subset of <math>\mathbb{R}^n</math>. We say
| |
| :<math>f(\vec{x})\text{ is }O(g(\vec{x}))\text{ as }\vec{x}\to\infty</math>
| |
| if and only if
| |
| :<math>\exists M\,\exists C>0\text{ such that } |f(\vec{x})| \le C |g(\vec{x})|\text{ for all }\vec{x} \text{ with } x_i \ge M \text{ for all }i.</math>
| |
| For example, the statement
| |
| :<math>f(n,m) = n^2 + m^3 + O(n+m) \text{ as } n,m\to\infty\,</math>
| |
| asserts that there exist constants ''C'' and ''M'' such that
| |
| :<math>\forall n, m \ge M\colon |g(n,m)| \le C(n+m),</math>
| |
| where ''g''(''n'',''m'') is defined by
| |
| :<math>f(n,m) = n^2 + m^3 + g(n,m).\,</math>
| |
| Note that this definition allows all of the coordinates of <math>\vec{x}</math> to increase to infinity. In particular, the statement
| |
| :<math>f(n,m) = O(n^m) \text{ as } n,m\to\infty\,</math>
| |
| (i.e., <math>\exists C\,\exists M\,\forall n\,\forall m\dots</math>) is quite different from
| |
| :<math>\forall m\colon f(n,m) = O(n^m) \text{ as } n\to\infty</math>
| |
| (i.e., <math>\forall m\,\exists C\,\exists M\,\forall n\dots</math>).
| |
| | |
| ==Matters of notation==
| |
| | |
| ===Equals sign===
| |
| The statement "''f''(''x'') is ''O''(''g''(''x''))" as defined above is usually written as ''f''(''x'') = ''O''(''g''(''x'')). Some consider this to be an [[abuse of notation]], since the use of the equals sign could be misleading as it suggests a symmetry that this statement does not have. As [[Nicolaas Govert de Bruijn|de Bruijn]] says, ''O''(''x'') = ''O''(''x''<sup>2</sup>) is true but ''O''(''x''<sup>2</sup>) = ''O''(''x'') is not.<ref>{{Cite book| author = [[N. G. de Bruijn]] | title=Asymptotic Methods in Analysis | place=Amsterdam |publisher=North-Holland | year=1958 | pages=5–7 | url=http://books.google.com/?id=_tnwmvHmVwMC&pg=PA5&vq=%22The+trouble+is%22 | isbn=978-0-486-64221-5}}</ref> [[Donald Knuth|Knuth]] describes such statements as "one-way equalities", since if the sides could be reversed, "we could deduce ridiculous things like ''n'' = ''n''<sup>2</sup> from the identities ''n'' = ''O''(''n''<sup>2</sup>) and ''n''<sup>2</sup> = ''O''(''n''<sup>2</sup>)."<ref name="Concrete Mathematics">
| |
| {{Cite book|
| |
| author=[[Ronald Graham]], Donald Knuth, and [[Oren Patashnik]]|
| |
| title=Concrete Mathematics|
| |
| place=Reading, Massachusetts| publisher=Addison–Wesley|
| |
| edition=2| year=1994 | page=446 |
| |
| url=http://books.google.com/?id=pntQAAAAMAAJ&dq=editions:ISBN 0-201-55802-5 | isbn=978-0-201-55802-9}}
| |
| </ref>
| |
| For these reasons, it would be more precise to use [[set notation]] and write ''f''(''x'') ∈ ''O''(''g''(''x'')), thinking of ''O''(''g''(''x'')) as the class of all functions ''h''(''x'') such that |''h''(''x'')| ≤ ''C''|''g''(''x'')| for some constant ''C''.<ref name="Concrete Mathematics"/> However, the use of the equals sign is customary. Knuth pointed out that "mathematicians customarily use the = sign as they use the word 'is' in English: Aristotle is a man, but a man isn't necessarily Aristotle."<ref>{{Cite journal| author=Donald Knuth | title=Teach Calculus with Big O | date=June–July 1998 | journal=[[Notices of the American Mathematical Society]] | volume=45 | issue=6 | page=687 | url=http://www.ams.org/notices/199806/commentary.pdf}} ([http://www-cs-staff.stanford.edu/~knuth/ocalc.tex Unabridged version])</ref>
| |
| | |
| ===Other arithmetic operators===
| |
| Big O notation can also be used in conjunction with other arithmetic operators in more complicated equations. For example, ''h''(''x'') + ''O''(''f''(''x'')) denotes the collection of functions having the growth of ''h''(''x'') plus a part whose growth is limited to that of ''f''(''x''). Thus,
| |
| :<math>g(x) = h(x) + O(f(x))\,</math>
| |
| expresses the same as
| |
| :<math>g(x) - h(x) \in O(f(x))\,.</math>
| |
| | |
| ====Example {{anchor|Example (Matters of notation)}}====
| |
| Suppose an [[algorithm]] is being developed to operate on a set of ''n'' elements. Its developers are interested in finding a function ''T''(''n'') that will express how long the algorithm will take to run (in some arbitrary measurement of time) in terms of the number of elements in the input set. The algorithm works by first calling a subroutine to sort the elements in the set and then perform its own operations. The sort has a known time complexity of ''O''(''n''<sup>2</sup>), and after the subroutine runs the algorithm must take an additional <math> 55n^3+2n+10</math> time before it terminates. Thus the overall time complexity of the algorithm can be expressed as
| |
| :<math>T(n)=55n^3+O(n^2).\ </math>
| |
| Here the terms 2''n''+10 are subsumed within the faster-growing ''O''(''n''<sup>2</sup>). Again, this usage disregards some of the formal meaning of the "=" symbol, but it does allow one to use the big O notation as a kind of convenient placeholder.
| |
| | |
| ===Declaration of variables===
| |
| Another feature of the notation, although less exceptional, is that function arguments may need to be inferred from the context when several variables are involved. The following two right-hand side big O notations have dramatically different meanings:
| |
| :<math>f(m) = O(m^n)\,,</math>
| |
| :<math>g(n)\,\, = O(m^n)\,.</math>
| |
| The first case states that ''f''(''m'') exhibits polynomial growth, while the second, assuming ''m'' > 1, states that ''g''(''n'') exhibits exponential growth.
| |
| To avoid confusion, some authors{{who|date=January 2015}} use the notation
| |
| :<math>g(x) \in O(f(x))\,.</math>
| |
| rather than the less explicit
| |
| :<math>g \in O(f)\,,</math>
| |
| | |
| ===Multiple usages===
| |
| In more complicated usage, ''O''(...) can appear in different places in an equation, even several times on each side. For example, the following are true for <math>n\to\infty</math>
| |
| :<math>(n+1)^2 = n^2 + O(n)\ </math>
| |
| :<math>(n+O(n^{1/2}))(n + O(\log n))^2 = n^3 + O(n^{5/2})\ </math>
| |
| :<math>n^{O(1)} = O(e^n).\ </math>
| |
| The meaning of such statements is as follows: for ''any'' functions which satisfy each ''O''(...) on the left side, there are ''some'' functions satisfying each ''O''(...) on the right side, such that substituting all these functions into the equation makes the two sides equal. For example, the third equation above means: "For any function <math>f(n)=O(1)\,</math>, there is some function <math>g(n)=O(e^n)\,</math> such that <math>n^{f(n)}=g(n)</math>." In terms of the "set notation" above, the meaning is that the class of functions represented by the left side is a subset of the class of functions represented by the right side. In this use the "=" is a formal symbol that unlike the usual use of "=" is not a [[symmetric relation]]. Thus for example <math>n^{O(1)} = O(e^n)\, </math> does not imply the false statement <math>O(e^n) = n^{O(1)}\, </math>.
| |
| | |
| ==Orders of common functions==
| |
| {{Further|Time complexity#Table of common time complexities}}
| |
| | |
| Here is a list of classes of functions that are commonly encountered when analyzing the running time of an algorithm. In each case, ''c'' is a constant and ''n'' increases without bound. The slower-growing functions are generally listed first.
| |
| | |
| {| class="wikitable"
| |
| |-
| |
| !Notation !! Name !! Example
| |
| |-
| |
| |<math>O(1)\,</math> || [[Constant time|constant]] || Determining if a binary number is even or odd; Calculating <math>(-1)^n</math>; Using a constant-size [[lookup table]]
| |
| |-
| |
| |<math>O(\log \log n)\,</math> || double logarithmic || Number of comparisons spent finding an item using [[interpolation search]] in a sorted array of uniformly distributed values
| |
| |-
| |
| |<math>O(\log n)\,</math> || [[Logarithmic time|logarithmic]] || Finding an item in a sorted array with a [[Binary search algorithm|binary search]] or a balanced search [[Tree data structure|tree]] as well as all operations in a [[Binomial heap]]
| |
| |-
| |
| |<math>O(\log^c n),\;c>1\,</math> || [[Polylogarithmic time|polylogarithmic]] || Matrix chain ordering can be solved in polylogarithmic time on a [[Parallel Random Access Machine]].
| |
| |-
| |
| |<math>O(n^c),\;0<c<1\,</math> || fractional power || Searching in a [[kd-tree]]
| |
| |-
| |
| |<math>O(n)\,</math> || [[linear time|linear]] || Finding an item in an unsorted list or a malformed tree (worst case) or in an unsorted array; adding two ''n''-bit integers by [[Ripple carry adder|ripple carry]]
| |
| |-
| |
| |<math>O(n\log^* n)\,</math> || n [[log-star]] n || Performing [[Polygon triangulation|triangulation]] of a simple polygon using Seidel's algorithm, or the [[Proof of O(log*n) time complexity of union–find|union–find algorithm]]. Note that <math>\log^*(n) =
| |
| \begin{cases}
| |
| 0, & \text{if }n \leq 1 \\
| |
| 1 + \log^*(\log n), & \text{if }n>1
| |
| \end{cases}</math>
| |
| |-
| |
| |<math>O(n\log n)=O(\log n!)\,</math> || [[Linearithmic time|linearithmic]], loglinear, or quasilinear || Performing a [[fast Fourier transform]]; [[heapsort]], [[quicksort]] (best and average case), or [[merge sort]]
| |
| |-
| |
| |<math>O(n^2)\,</math> || [[quadratic time|quadratic]] || Multiplying two ''n''-digit numbers by a simple algorithm; [[bubble sort]] (worst case or naive implementation), [[Shell sort]], quicksort (worst case), [[selection sort]] or [[insertion sort]]
| |
| |-
| |
| |<math>O(n^c),\;c>1</math> || [[polynomial time|polynomial]] or algebraic || [[Tree-adjoining grammar]] parsing; maximum [[Matching (graph theory)|matching]] for [[bipartite graph]]s
| |
| |-
| |
| |<math>L_n[\alpha,c],\;0 < \alpha < 1=\,</math><br><math>e^{(c+o(1)) (\ln n)^\alpha (\ln \ln n)^{1-\alpha}}</math> || [[L-notation]] or [[sub-exponential time|sub-exponential]] || Factoring a number using the [[quadratic sieve]] or [[number field sieve]]
| |
| |-
| |
| |<math>O(c^n),\;c>1</math> || [[exponential time|exponential]] || Finding the (exact) solution to the [[travelling salesman problem]] using [[dynamic programming]]; determining if two logical statements are equivalent using [[brute-force search]]
| |
| |-
| |
| |<math>O(n!)\,</math> || [[factorial]] || Solving the traveling salesman problem via brute-force search; generating all unrestricted permutations of a [[Partially ordered set|poset]]; finding the [[determinant]] with [[expansion by minors]]; enumerating [[Bell number|all partitions of a set]]
| |
| |-
| |
| |<math>O(n * n!)\,</math> || n × n factorial || Attempting to sort a list of elements using the incredibly inefficient [[bogosort]] algorithm.
| |
| |}
| |
| The statement <math>f(n)=O(n!)\,</math> is sometimes weakened to <math>f(n)=O\left(n^n\right)</math> to derive simpler formulas for asymptotic complexity.
| |
| For any <math>k>0</math> and <math>c>0</math>, <math>O(n^c(\log n)^k)</math> is a subset of <math>O(n^{c+\varepsilon })</math> for any <math> \varepsilon >0</math>, so may be considered as a polynomial with some bigger order.
| |
| | |
| ==Related asymptotic notations==
| |
| Big ''O'' is the most commonly used asymptotic notation for comparing functions, although in many cases Big ''O'' may be replaced with Big Theta Θ for asymptotically tighter bounds. Here, we define some related notations in terms of Big ''O'', progressing up to the family of Bachmann–Landau notations to which Big ''O'' notation belongs.
| |
| ===Little-o notation=== <!-- [[Little-o notation]] redirects here -->
| |
| {{redirect|Little o|the baseball player|Omar Vizquel}}
| |
| The relation <math>f(x) \in o(g(x))</math> is read as "<math>f(x)</math> is little-o of <math>g(x)</math>". Intuitively, it means that <math>g(x)</math> grows much faster than <math>f(x)</math>, or similarly, the growth of <math>f(x)</math> is nothing compared to that of <math>g(x)</math>. It assumes that ''f'' and ''g'' are both functions of one variable. Formally, ''f''(''n'') = ''o''(''g''(''n'')) as {{math|''n'' → ∞}} means that for every positive constant <math>\epsilon</math> there exists a constant ''N'' such that
| |
| :<math>|f(n)|\leq\epsilon|g(n)|\qquad\text{for all }n\geq N~.</math><ref name="Concrete Mathematics"/>
| |
| | |
| Note the difference between the earlier [[#Formal definition|formal definition]] for the big-O notation, and the present definition of little-o: while the former has to be true for ''at least one'' constant ''M'' the latter must hold for ''every'' positive constant <math>\epsilon</math>, however small.<ref name="Introduction to Algorithms"/> In this way little-o notation makes a stronger statement than the corresponding big-O notation: every function that is little-o of ''g'' is also big-O of ''g'', but not every function that is big-O ''g'' is also little-o of ''g'' (for instance ''g'' itself is not, unless it is identically zero near ∞).
| |
| | |
| If ''g''(''x'') is nonzero, or at least becomes nonzero beyond a certain point, the relation ''f''(''x'') = ''o''(''g''(''x'')) is equivalent to
| |
| :<math>\lim_{x \to \infty}\frac{f(x)}{g(x)}=0.</math>
| |
| For example,
| |
| * <math>2x \in o(x^2) \,\!</math>
| |
| * <math>2x^2 \not \in o(x^2)</math>
| |
| * <math>1/x \in o(1)</math>
| |
| Little-o notation is common in mathematics but rarer in computer science. In computer science the variable (and function value) is most often a natural number. In mathematics, the variable and function values are often real numbers. The following properties can be useful:
| |
| * <math>o(f) + o(f) \subseteq o(f)</math>
| |
| * <math>o(f)o(g) \subseteq o(fg)</math>
| |
| * <math>o(o(f)) \subseteq o(f)</math>
| |
| * <math>o(f) \subset O(f)</math> (and thus the above properties apply with most combinations of o and O).
| |
| As with big O notation, the statement "<math>f(x)</math> is <math>o(g(x))</math>" is usually written as <math> f(x) = o(g(x))</math>, which is a slight [[abuse of notation]].
| |
| | |
| === Big Omega notation ===
| |
| | |
| There are two very widespread and incompatible definitions of the statement
| |
| | |
| :<math>f(x)=\Omega(g(x))\ (x\rightarrow a),</math>
| |
| | |
| where <math>a</math> is some real number, <math>\infty</math>, or <math>-\infty</math>, where <math>f</math> and <math>g</math> are real functions defined in a neighbourhood of <math>a</math>, and where <math>g</math> is positive in this neighbourhood.
| |
| | |
| The first one (chronologically) is used in [[analytic number theory]], and the other one in [[computational complexity theory]]. When the two subjects meet, this situation is bound to generate confusion.
| |
| | |
| ==== The Hardy–Littlewood definition ====
| |
| | |
| In 1914 [[Godfrey Harold Hardy|G.H. Hardy]] and [[John Edensor Littlewood|J.E. Littlewood]] introduced the new symbol <math>\Omega</math>,<ref name="HL">G. H. Hardy and J. E. Littlewood, "Some problems of Diophantine approximation", Acta Mathematica 37 (1914), p. 225</ref> which is defined as follows:
| |
| | |
| :<math>f(x)=\Omega(g(x))\ (x\rightarrow\infty)\;\Leftrightarrow\;\limsup_{x \to \infty} \left|\frac{f(x)}{g(x)}\right|> 0</math>.
| |
| | |
| Thus <math>f(x)=\Omega(g(x))</math> is the negation of <math>f(x)=o(g(x))</math>.
| |
| | |
| In 1918 the same authors introduced the two new symbols <math>\Omega_R</math> and <math>\Omega_L</math>,<ref name="HL2">G. H. Hardy and J. E. Littlewood, « Contribution to the theory of the Riemann zeta-function and the theory of the distribution of primes », ''[[Acta Mathematica]]'', vol. 41, 1918.</ref> thus defined:
| |
| | |
| :<math>f(x)=\Omega_R(g(x))\ (x\rightarrow\infty)\;\Leftrightarrow\;\limsup_{x \to \infty} \frac{f(x)}{g(x)}> 0</math>;
| |
| | |
| :<math>f(x)=\Omega_L(g(x))\ (x\rightarrow\infty)\;\Leftrightarrow\;\liminf_{x \to \infty} \frac{f(x)}{g(x)}< 0</math>.
| |
| | |
| Hence <math>f(x)=\Omega_R(g(x))</math> is the negation of <math>f(x)<o(g(x))</math>, and <math>f(x)=\Omega_L(g(x))</math> the negation of <math>f(x)>o(g(x))</math>.
| |
| | |
| Contrary to a later assertion of [[Donald Knuth|D.E. Knuth]],<ref name="knuth">Donald Knuth. "Big Omicron and big Omega and big Theta", SIGACT News, Apr.-June 1976, 18-24. [http://www.phil.uu.nl/datastructuren/10-11/knuth_big_omicron.pdf]</ref> [[Edmund Landau]] did use these three symbols, with the same meanings, in 1924.<ref name="landau">E. Landau, "Über die Anzahl der Gitterpunkte in gewissen Bereichen. IV." Nachr. Gesell. Wiss. Gött. Math-phys. Kl. 1924, 137–150.</ref>
| |
| | |
| These Hardy-Littlewood symbols are prototypes, which after Landau were never used again exactly thus.
| |
| | |
| :<math>\Omega_R</math> became <math>\Omega_+</math>, and <math>\Omega_L</math> became <math>\Omega_-</math>.
| |
| | |
| These three symbols <math>\Omega, \Omega_+, \Omega_-</math>, as well as <math>f(x)=\Omega_\pm(g(x))</math> (meaning that <math>f(x)=\Omega_+(g(x))</math> and <math>f(x)=\Omega_-(g(x))</math> are both satisfied), are now currently used in [[analytic number theory]].
| |
| | |
| ==== Simple examples ====
| |
| | |
| We have
| |
| | |
| :<math>\sin x=\Omega(1)\ (x\rightarrow\infty),</math>
| |
| | |
| and more precisely
| |
| | |
| :<math>\sin x=\Omega_\pm(1)\ (x\rightarrow\infty).</math>
| |
| | |
| We have
| |
| | |
| :<math>\sin x+1=\Omega(1)\ (x\rightarrow\infty),</math>
| |
| | |
| and more precisely
| |
| | |
| :<math>\sin x+1=\Omega_+(1)\ (x\rightarrow\infty);</math>
| |
| | |
| however
| |
| | |
| :<math>\sin x+1\not=\Omega_-(1)\ (x\rightarrow\infty).</math>
| |
| | |
| ==== The Knuth definition ====
| |
| | |
| In 1976 [[Donald Knuth|D.E. Knuth]] published a paper<ref name="knuth"/> to justify his use of the <math>\Omega</math>-symbol to describe a stronger property. Knuth wrote: "For all the applications I have seen so far in computer science, a stronger requirement […] is much more appropriate". He defined
| |
| | |
| :<math>f(x)=\Omega(g(x))\Leftrightarrow g(x)=O(f(x))</math>
| |
| | |
| with the comment: "Although I have changed Hardy and Littlewood's definition of <math>\Omega</math>, I feel justified in doing so because their definition is by no means in wide use, and because there are other ways to say what they want to say in the comparatively rare cases when their definition applies". However, the Hardy–Littlewood definition had been used for at least 25 years.<ref name="titchmarsh">E. C. Titchmarsh, The Theory of the Riemann Zeta-Function (Oxford; Clarendon Press, 1951)</ref>
| |
| | |
| ===Family of Bachmann–Landau notations===
| |
| {| class="wikitable"
| |
| |-
| |
| ! Notation
| |
| ! Name
| |
| ! Intuition
| |
| ! Informal definition: for sufficiently large <math>n</math>...
| |
| ! Formal Definition
| |
| <!-- !Alternative definition -->
| |
| |-
| |
| |<math>f(n) \in O(g(n))</math>
| |
| | |
| or | |
| | |
| <math>f(n) = O(g(n))</math>
| |
| | Big O; Big Oh; Big Omicron<ref name="knuth"/>
| |
| | <math>f</math> is bounded above by <math>g</math> (up to constant factor) asymptotically
| |
| <!-- |<math>\limsup_{n \to \infty} \left|\frac{f(n)}{g(n)}\right| < \infty</math> -->
| |
| |<math>|f(n)| \leq k\cdot g(n)</math> for some positive ''k''
| |
| |<math>\exists k>0 \; \exists n_0 \; \forall n>n_0 \; |f(n)| \leq k\cdot |g(n)|</math> <br> or <br> <math> \exists k>0 \; \exists n_0 \; \forall n>n_0 \; f(n) \leq k\cdot g(n)</math>
| |
| |-
| |
| |<math>f(n) \in \Omega(g(n))</math>
| |
| | |
| or
| |
| | |
| <math>f(n) = \Omega(g(n))</math>
| |
| | Big Omega
| |
| |'''Two definitions : '''
| |
| | |
| Number theory:
| |
| | |
| <math>f</math> is not dominated by <math>g</math> asymptotically
| |
| | |
| Complexity theory:
| |
| | |
| <math>f</math> is bounded below by <math>g</math> asymptotically
| |
| |Number theory:
| |
| | |
| <math>f(n) \geq k\cdot g(n)</math> for infinitely many values of ''n'' and for some positive ''k''
| |
| | |
| Complexity theory:
| |
| | |
| <math>f(n) \geq k\cdot g(n)</math> for some positive ''k''
| |
| <!--|<math>\liminf_{n \to \infty} \left|\frac{f(n)}{g(n)}\right| > 0 </math> -->
| |
| |Number theory:
| |
| | |
| <math>\exists k>0 \; \forall n_0 \; \exists n>n_0 \; f(n) \geq k\cdot g(n)</math>
| |
| | |
| Complexity theory:
| |
| | |
| <math>\exists k>0 \; \exists n_0 \; \forall n>n_0 \; f(n) \geq k\cdot g(n)</math>
| |
| |-
| |
| |<math>f(n) \in \Theta(g(n))</math>
| |
| | Big Theta
| |
| | <math>f</math> is bounded both above and below by <math>g</math> asymptotically
| |
| |<math>k_1\cdot g(n) \leq f(n) \leq k_2\cdot g(n)</math> for some positive ''k''<sub>1</sub>, ''k''<sub>2</sub>
| |
| <!-- |<math>0 < \liminf_{n \to \infty} \left|\frac{f(n)}{g(n)}\right| \leq \limsup_{n \to \infty} \left|\frac{f(n)}{g(n)}\right|< \infty</math> -->
| |
| <!--|<math>f(n) \in O(g(n)) \cap \Omega(g(n))</math> -->
| |
| |<math>\exists k_1>0 \; \exists k_2>0 \; \exists n_0 \; \forall n>n_0</math>
| |
| <math>k_1\cdot g(n) \leq f(n) \leq k_2\cdot g(n)</math>
| |
| |-
| |
| |<math>f(n) \in o(g(n))</math>
| |
| | |
| or
| |
| | |
| <math>f(n) = o(g(n))</math>
| |
| | Small O; Small Oh
| |
| | <math>f</math> is dominated by <math>g</math> asymptotically
| |
| | <math>|f(n)| \le k\cdot|g(n)|</math>, for every fixed positive number <math>k</math>
| |
| <!-- |<math>\lim_{n \to \infty} \left|\frac{f(n)}{g(n)}\right| = 0</math> -->
| |
| <!-- |<math>\forall \;k>0,\exists \;n(k) : |f(n)| < \; k |g(n)|, \forall n>n(k).</math> -->
| |
| |<math>\forall k>0 \; \exists n_0 \; \forall n>n_0 \; |f(n)| \le k\cdot |g(n)|</math>
| |
| |-
| |
| |<math>f(n) \in \omega(g(n))</math>
| |
| | Small Omega
| |
| | <math>f</math> dominates <math>g</math> asymptotically
| |
| | <math>|f(n)| \ge k\cdot|g(n)|</math>, for every fixed positive number <math>k</math>
| |
| <!-- |<math>\lim_{n \to \infty} \left|\frac{f(n)}{g(n)}\right| = \infty</math> -->
| |
| |<math>\forall k>0 \; \exists n_0 \; \forall n>n_0 \ |f(n)| \ge k\cdot |g(n)|</math>
| |
| <!-- Sometimes this is expressed as "\forall M<\infty" - any preference here? -->
| |
| |-
| |
| |<math>f(n)\sim g(n)\!</math><!-- force PNG; ~ is often ugly -->
| |
| | On the order of
| |
| | <math>f</math> is equal to <math>g</math> asymptotically
| |
| |<math>f(n)/g(n) \to 1</math>
| |
| |<math>\forall \varepsilon>0\;\exists n_0\;\forall n>n_0\;\left|{f(n) \over g(n)}-1\right|<\varepsilon</math>
| |
| |}
| |
| | |
|
| |
| Aside from the Big ''O'' notation, the Big Theta Θ and Big Omega Ω notations are the two most often used in computer science; the small omega ω notation is occasionally used in computer science.
| |
| | |
| Aside from the Big ''O'' notation, the small ''o'', Big Omega Ω and <math>\sim</math> notations are the three most often used in number theory; the small omega ω notation is never used in number theory.
| |
| | |
| === Use in computer science ===
| |
| {{details|Analysis of algorithms}}
| |
| Informally, especially in computer science, the Big ''O'' notation often is permitted to be somewhat abused to describe an asymptotic tight bound where using Big Theta Θ notation might be more factually appropriate in a given context. For example, when considering a function <math>T(n) = 73n^3 + 22n^2 + 58</math>, all of the following are generally acceptable, but tightnesses of bound (i.e., numbers 2 and 3 below) are usually strongly preferred over laxness of bound (i.e., number 1 below).
| |
| #''T''(''n'') = ''O''(''n''<sup>100</sup>), which is identical to ''T''(''n'') ∈ ''O''(''n''<sup>100</sup>)
| |
| #''T''(''n'') = ''O''(''n''<sup>3</sup>), which is identical to ''T''(''n'') ∈ ''O''(''n''<sup>3</sup>)
| |
| #''T''(''n'') = Θ(''n''<sup>3</sup>), which is identical to ''T''(''n'') ∈ Θ(''n''<sup>3</sup>).
| |
| The equivalent English statements are respectively:
| |
| #''T''(''n'') grows asymptotically no faster than ''n''<sup>100</sup>
| |
| #''T''(''n'') grows asymptotically no faster than ''n''<sup>3</sup>
| |
| #''T''(''n'') grows asymptotically as fast as ''n''<sup>3</sup>.
| |
| So while all three statements are true, progressively more information is contained in each. In some fields, however, the Big O notation (number 2 in the lists above) would be used more commonly than the Big Theta notation (bullets number 3 in the lists above) because functions that grow more slowly are more desirable. For example, if <math>T(n)</math> represents the running time of a newly developed algorithm for input size <math>n</math>, the inventors and users of the algorithm might be more inclined to put an upper asymptotic bound on how long it will take to run without making an explicit statement about the lower asymptotic bound.
| |
| | |
| ===Extensions to the Bachmann–Landau notations===
| |
| Another notation sometimes used in computer science is Õ (read ''soft-O''): ''f''(''n'') = ''Õ''(''g''(''n'')) is shorthand
| |
| for ''f''(''n'') = ''O''(''g''(''n'') log<sup>''k''</sup> ''g''(''n'')) for some ''k''. Essentially, it is Big O notation, ignoring logarithmic factors because the growth-rate effects of some other super-logarithmic function indicate a growth-rate explosion for large-sized input parameters that is more important to predicting bad run-time performance than the finer-point effects contributed by the logarithmic-growth factor(s). This notation is often used to obviate the "nitpicking" within growth-rates that are stated as too tightly bounded for the matters at hand (since log<sup>''k''</sup> ''n'' is always ''o''(''n''<sup>ε</sup>) for any constant ''k'' and any ε > 0).
| |
| | |
| Also the [[L-notation|L notation]], defined as
| |
| :<math>L_n[\alpha,c]=O\left(e^{(c+o(1))(\ln n)^\alpha(\ln\ln n)^{1-\alpha}}\right),</math>
| |
| is convenient for functions that are between polynomial and exponential.
| |
| | |
| ==Generalizations and related usages==
| |
| The generalization to functions taking values in any [[normed vector space]] is straightforward (replacing absolute values by norms), where ''f'' and ''g'' need not take their values in the same space. A generalization to functions ''g'' taking values in any [[topological group]] is also possible.
| |
| The "limiting process" ''x→x<sub>o</sub>'' can also be generalized by introducing an arbitrary [[filter base]], i.e. to directed [[net (mathematics)|net]]s ''f'' and ''g''.
| |
| The ''o'' notation can be used to define [[derivative]]s and [[differentiability]] in quite general spaces, and also (asymptotical) equivalence of functions,
| |
| :<math> f\sim g \iff (f-g) \in o(g) </math>
| |
| which is an [[equivalence relation]] and a more restrictive notion than the relationship "''f'' is Θ(''g'')" from above. (It reduces to <math>\lim f/g = 1</math> if ''f'' and ''g'' are positive real valued functions.) For example, 2''x'' is Θ(''x''), but 2''x'' − ''x'' is not ''o''(''x'').
| |
| | |
| ==History (Bachmann–Landau, Hardy, and Vinogradov notations)==
| |
| The symbol O was first introduced by number theorist [[Paul Bachmann]] in 1894, in the second volume of his book ''Analytische Zahlentheorie'' ("[[analytic number theory]]"), the first volume of which (not yet containing big O notation) was published in 1892.<ref>[[Nicholas J. Higham]], ''Handbook of writing for the mathematical sciences'', SIAM. ISBN 0-89871-420-6, p. 25</ref> The number theorist [[Edmund Landau]] adopted it, and was thus inspired to introduce in 1909 the notation o;<ref>Edmund Landau. Handbuch der Lehre von der Verteilung der Primzahlen, Teubner, Leipzig 1909, p.883.</ref> hence both are now called Landau symbols. These notations were used in applied mathematics during the 1950s for asymptotic analysis.<ref>{{cite book
| |
| | title = Asymptotic Expansions
| |
| | last = Erdelyi
| |
| | first = A.
| |
| | year = 1956
| |
| | isbn = 978-0486603186
| |
| }}</ref> The big O was popularized in computer science by [[Donald Knuth]], who re-introduced the related Omega and Theta notations.<ref name="knuth"/> Knuth also noted that the Omega notation had been introduced by Hardy and Littlewood<ref name="HL" /> under a different meaning "≠''o''" (i.e. "is not an ''o'' of"), and proposed the above definition. Hardy and Littlewood's original definition (which was also used in one paper by Landau<ref name="landau" />) is still used in number theory (where Knuth's definition is never used). In fact, Landau also used in 1924, in the paper just mentioned, the symbols <math>\Omega_R</math> ("right") and <math>\Omega_L</math> ("left"), which were introduced in 1918 by Hardy and Littlewood,<ref name="HL2" /> and which were precursors for the modern symbols <math>\Omega_+</math> ("is not smaller than a small o of") and <math>\Omega_-</math> ("is not larger than a small o of"). Thus the Omega symbols (with their original meanings) are sometimes also referred to as "Landau symbols".
| |
|
| |
| Also, Landau never used the Big Theta and small omega symbols.
| |
| | |
| Hardy's symbols were (in terms of the modern ''O'' notation)
| |
| :<math> f \preceq g\iff f \in O(g) </math> and <math> f\prec g\iff f\in o(g); </math>
| |
|
| |
| (Hardy however never defined or used the notation <math>\prec\!\!\prec</math>, nor <math>\ll</math>, as it has been sometimes reported).
| |
| It should also be noted that Hardy introduces the symbols <math>\preceq </math> and <math>\prec </math> (as well as some other symbols) in his 1910 tract "Orders of Infinity", and makes use of it only in three papers (1910–1913). In his nearly 400 remaining papers and books he consistently uses the Landau symbols O and o.
| |
| | |
| Hardy's notation is not used anymore. On the other hand, in the 1930s,<ref>See for instance "A new estimate for ''G(n)'' in Waring's problem" (Russian). Doklady Akademii Nauk SSSR 5, No 5-6 (1934), 249-253. Translated in English in: Selected works / Ivan Matveevič Vinogradov ; prepared by the Steklov Mathematical Institute of the Academy of Sciences of the USSR on the occasion of his 90th birthday. Springer-Verlag, 1985.</ref> the Russian number theorist [[Ivan Matveyevich Vinogradov]] introduced his notation
| |
| <math>\ll</math>, which has been increasingly used in number theory instead of the <math>O</math> notation. We have
| |
| | |
| :<math> f\ll g \iff f \in O(g), </math>
| |
| | |
| and frequently both notations are used in the same paper.
| |
| | |
| The big-O originally stands for "order of" ("Ordnung", Bachmann 1894), and is thus a roman letter. Neither Bachmann nor Landau ever call it "Omicron". The symbol was much later on (1976) viewed by Knuth as a capital [[omicron]],<ref name="knuth"/> probably in reference to his definition of the symbol [[Omega]]. The digit [[0 (number)|zero]] should not be used.
| |
| | |
| ==See also==
| |
| * [[Asymptotic expansion]]: Approximation of functions generalizing Taylor's formula
| |
| * [[Asymptotically optimal]]: A phrase frequently used to describe an algorithm that has an upper bound asymptotically within a constant of a lower bound for the problem
| |
| * [[Big O in probability notation]]: ''O<sub>p</sub>'',''o<sub>p</sub>''
| |
| * [[Limit superior and limit inferior]]: An explanation of some of the limit notation used in this article
| |
| * [[Nachbin's theorem]]: A precise method of bounding [[complex analytic]] functions so that the domain of convergence of [[integral transform]]s can be stated
| |
| | |
| ==References and Notes==
| |
| {{Reflist}}
| |
| | |
| ==Further reading==
| |
| * [[Paul Bachmann]]. ''Die Analytische Zahlentheorie. Zahlentheorie''. pt. 2 Leipzig: B. G. Teubner, 1894.
| |
| * [[Edmund Landau]]. ''Handbuch der Lehre von der Verteilung der Primzahlen''. 2 vols. Leipzig: B. G. Teubner, 1909.
| |
| * [[G. H. Hardy]]. ''Orders of Infinity: The 'Infinitärcalcül' of Paul du Bois-Reymond'', 1910.
| |
| * [[Donald Knuth]]. ''The Art of Computer Programming'', Volume 1: ''Fundamental Algorithms'', Third Edition. Addison–Wesley, 1997. ISBN 0-201-89683-4. Section 1.2.11: Asymptotic Representations, pp. 107–123.
| |
| * [[Paul Vitanyi]], [[Lambert Meertens]], Big Omega versus the wild functions, Bull. European Association Theoret. Comput. Sci. (EATCS) 22(1984), 14-19. Also: ACM-SIGACT News, 16:4(1984) 56-59.
| |
| * [[Thomas H. Cormen]], [[Charles E. Leiserson]], [[Ronald L. Rivest]], and [[Clifford Stein]]. ''[[Introduction to Algorithms]]'', Second Edition. MIT Press and McGraw–Hill, 2001. ISBN 0-262-03293-7. Section 3.1: Asymptotic notation, pp. 41–50.
| |
| * {{cite book|author = [[Michael Sipser]] | year = 1997 | title = Introduction to the Theory of Computation | publisher = PWS Publishing | isbn = 0-534-94728-X}} Pages 226–228 of section 7.1: Measuring complexity.
| |
| * Jeremy Avigad, Kevin Donnelly. ''[http://www.andrew.cmu.edu/~avigad/Papers/bigo.pdf Formalizing O notation in Isabelle/HOL]''
| |
| * Paul E. Black, [http://www.nist.gov/dads/HTML/bigOnotation.html "big-O notation"], in ''Dictionary of Algorithms and Data Structures'' [online], Paul E. Black, ed., U.S. National Institute of Standards and Technology. 11 March 2005. Retrieved December 16, 2006.
| |
| * Paul E. Black, [http://www.nist.gov/dads/HTML/littleOnotation.html "little-o notation"], in ''Dictionary of Algorithms and Data Structures'' [online], Paul E. Black, ed., U.S. National Institute of Standards and Technology. 17 December 2004. Retrieved December 16, 2006.
| |
| * Paul E. Black, [http://www.nist.gov/dads/HTML/omegaCapital.html "Ω"], in ''Dictionary of Algorithms and Data Structures'' [online], Paul E. Black, ed., U.S. National Institute of Standards and Technology. 17 December 2004. Retrieved December 16, 2006.
| |
| * Paul E. Black, [http://www.nist.gov/dads/HTML/omega.html "ω"], in ''Dictionary of Algorithms and Data Structures'' [online], Paul E. Black, ed., U.S. National Institute of Standards and Technology. 29 November 2004. Retrieved December 16, 2006.
| |
| * Paul E. Black, [http://www.nist.gov/dads/HTML/theta.html "Θ"], in ''Dictionary of Algorithms and Data Structures'' [online], Paul E. Black, ed., U.S. National Institute of Standards and Technology. 17 December 2004. Retrieved December 16, 2006.
| |
| | |
| ==External links==
| |
| {{wikibooks|Data Structures|Asymptotic Notation#Big-O Notation|Big-O Notation}}
| |
| * [http://oeis.org/wiki/Growth_of_sequences Online Encyclopedia of Integer Sequences]
| |
| * [http://www.soe.ucsc.edu/classes/cmps102/Spring04/TantaloAsymp.pdf Introduction to Asymptotic Notations]
| |
| * [http://mathworld.wolfram.com/LandauSymbols.html Landau Symbols]
| |
| * [http://www.perlmonks.org/?node_id=573138 Big-O Notation – What is it good for]
| |
| | |
| {{DEFAULTSORT:Big O Notation}}
| |
| [[Category:Mathematical notation]]
| |
| [[Category:Asymptotic analysis]]
| |
| [[Category:Analysis of algorithms]]
| |