{{Short description|Describes approximate behavior of a function}} {{Italic title|string=O}} {{Order-of-approx}} '''Big ''O'' notation''' is a mathematical notation that describes the approximate size of a function on a domain. Big O is a member of a family of notations invented by the German mathematicians Paul Bachmann<ref name=Bachmann /> and Edmund Landau<ref name=Landau>{{cite book |first=Edmund |last=Landau |author-link=Edmund Landau |title=Handbuch der Lehre von der Verteilung der Primzahlen |publisher=B.G. Teubner; reprinted as two volumes in one by Chelsea, 1974, with an appendix by Dr. Paul T. Bateman |year=1909 |location=Leipzig |trans-title=Handbook on the theory of the distribution of the primes |language=de |pages=59–63 | url=https://archive.org/stream/handbuchderlehre01landuoft#page/31/mode/2up }}</ref> and expanded by others, collectively called '''Bachmann–Landau notation'''. The letter O stands for ''Ordnung'', that is, the order of approximation.

In computer science, big O notation is used to classify algorithms by how their run time or space requirements{{efn|Note that the "size" of the input is typically used as an indication of how challenging a given ''instance'' is, of the problem to be solved. The amount of [execution] time, and the amount of [memory] space required to compute the answer, (or to "solve' the problem), are seen as indicating the difficulty of that ''instance'' of the problem. For purposes of Computational complexity theory, Big <math>O</math> notation is used for an upper bound on [the "order of magnitude" of] all 3 of those: the size of the input [data stream], the amount of [execution] time required, and the amount of [memory] space required.}} grow with the input.<ref name=":0"> {{Cite book |last1=Cormen |first1=Thomas H. |author-link=Thomas H. Cormen |title=Introduction to Algorithms |title-link=Introduction to Algorithms |last2=Leiserson |first2=Charles E. |author-link2=Charles E. Leiserson |last3=Rivest |first3=Ronald L. |author-link3=Ronald L. Rivest |last4=Stein |first4=Clifford |author-link4=Clifford Stein |publisher=MIT Press and McGraw-Hill |year=2022 |isbn=978-0-262-53091-0 |edition=4th |chapter=Characterizing running times}} </ref> In analytic number theory, big O notation expresses bounds on the growth of an arithmetical function, as for the remainder term in the prime number theorem.<ref name="iwaniec-kowalski" /> In mathematical analysis, including calculus, Big O notation bounds the error when truncating a power series and expresses the quality of approximation of a real or complex valued function by a simpler function.

Often, big O notation characterizes functions according to their growth rates as the variable becomes large: different functions with the same asymptotic 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 the '''order of the function'''. A description of a function in terms of big O notation only provides an upper bound on the growth rate of the function.

Associated with big O notation are several related notations, using the symbols <math> o</math>, <math>\sim</math>, <math> \Omega</math>, <math>\ll</math>, <math>\gg</math>, <math>\asymp</math>, <math> \omega</math>, and <math> \Theta</math> to describe other kinds of bounds on growth rates.<ref name=Hardy>{{cite book | first=G. H. | last=Hardy | author-link=G. H. Hardy | title=Orders of Infinity: The 'Infinitärcalcül' of Paul du Bois-Reymond | date=1910 |page=2| url=https://archive.org/details/ordersofinfinity00harduoft | publisher=Cambridge University Press}}</ref><ref name="vinogradov" /><ref name=HL/><ref name="knuth" />

Bachmann proposed the notation in 1894 and Landau extended it in 1909. An earlier notation was proposed by Paul du Bois-Reymond in 1870.<ref name="Bois-Reymond"/>

== Formal definition == Let <math display="inline">f,</math> the function to be estimated, be either a real or complex valued function defined on a domain <math display="inline">D,</math> and let <math display="inline">g,</math> the comparison function, be a non-negative real valued function defined on the same set <math display="inline">D.</math> Common choices for the domain are intervals of real numbers, bounded or unbounded, the set of positive integers, the set of complex numbers and tuples of real/complex numbers. With the domain written explicitly or understood implicitly, one writes <!-- The large O is typeset in this article as O inside math displays --> :<math display="block"> f(x) = O\bigl(g(x)\bigr)\ </math> which is read as {{nobr|&ensp;"<math display="inline">f(x)</math>}} is {{nobr|big <math display="inline">O</math>}} of {{nobr|<math display="inline">g(x)</math>"&ensp;}} if there exists a positive real number <math display="inline">M</math> such that :<math display="block">\left| f(x) \right|\le M\ g(x) \qquad ~ \mathsf{\ for\ all\ } ~ \quad x \in D.</math>

If <math>g(x) > 0</math> (i.e. {{math|g}} is also never zero) throughout the domain <math>D,</math> an equivalent definition is that the ratio <math display="inline">\frac{f(x)}{g(x)} </math> is ''bounded'', i.e. there is a positive real number <math>M</math> so that <math display="inline">\Big|\frac{f(x)}{g(x)}\Big| \le M</math> for all <math>x \in D.</math> These encompass all the uses of {{nobr| big <math display="inline">O</math> }} in computer science and mathematics, including its use where the domain is finite, infinite, real, complex, single variate, or multivariate. In most applications, one chooses the function <math>g(x)</math> appearing within the argument of <math display="inline">O\bigl( \cdot \bigr)</math> to be as simple a form as possible, omitting constant factors and lower order terms. The number <math display="inline">M</math> is called the ''implied constant'' because it is normally not specified. When using {{nobr|big <math display="inline">O</math>}} notation, what matters is that some finite <math>M</math> exists, not its specific value. This simplifies the presentation of many analytic inequalities.

For functions defined on positive real numbers or positive integers, a more restrictive and somewhat conflicting definition is still in common use,<ref name=":0"/><ref> {{cite book | first=Michael | last=Sipser | year=2012 | title=Introduction to the Theory of Computation | edition=3 |location=Boston, MA | publisher=PWS Publishin }} </ref> especially in computer science. When restricted to functions which are eventually positive, the notation : <math display="block">f(x) =O\bigl(g(x)\bigr) \qquad ~ \mathsf{ as } \quad x \to \infty</math> means that for some real number <math display="inline">a,</math> <math display="inline">f(x) = O\bigl(g(x)\bigr)</math> in the domain <math display="inline">\left[a,\infty\right).</math> Here, the expression <math display="inline">x \to \infty</math> does not indicate a limit, but the notion that the inequality holds for ''large enough'' <math display="inline">x.</math> The expression <math display="inline">x \to \infty</math> often is omitted.<ref name=":0"/>

Similarly, for a real number <math display="inline">a,</math> the notation :<math display="block"> f(x) = O\bigl(g(x)\bigr) \qquad ~ \text{ as } \ x \to a </math> means that for some constant <math display="inline">c > 0,</math> <math display="inline">f(x) = O\bigl(g(x)\bigr)</math> on the interval <math>\left[a-c, a+c\right];</math> that is, in a small neighborhood of <math>a.</math> In addition, the notation <math display="block">\ f(x) = h(x) + O\bigl(g(x)\bigr)\ </math> means <math display="inline">f(x) - h(x)= O\bigl(g(x)\bigr).</math> More complicated expressions are also possible.

Despite the presence of the equal sign ({{math|{{=}}}}) as written, the expression <math display="inline">f(x) = O\bigl(g(x)\bigr)</math> does not refer to an equality, but rather to an inequality relating <math display="inline">f</math> and <math display="inline">g.</math>

In the 1930s,<ref name=vinogradov> {{cite journal |first=Matveevič |last=Vinogradov |author-link=Ivan Matveyevich Vinogradov |year=1934 |title=A new estimate for {{math|''G''(''n'')}} in Waring's problem |lang=ru |journal=Doklady Akademii Nauk SSSR |volume=5 |issue=5-6 |pages=249–253 }} : Translated in English in:<br/> {{cite book |first=Matveevič |last=Vinogradov |author-link=Ivan Matveyevich Vinogradov |year=1985 |title=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 |lang=en |publisher=Springer-Verlag }} </ref> the Russian number theorist {{nobr|I.M. Vinogradov}} introduced the notation <math>\ll,</math> which has been increasingly used in number theory<ref name=iwaniec-kowalski> {{cite book |last1=Iwaniec |first1=Henryk |author1-link=Henryk Iwaniec |last2=Kowalski |first2=Emmanuel |year=2004 |title=Analytic Number Theory |publisher=American Mathematical Society }} </ref><ref name=Ivic/><ref name=tenenbaum/> and other branches of mathematics, as an alternative to the <math display="inline">O</math> notation. We have :<math display="block">\ f \ll g \iff f = O\bigl(g\bigr). </math> Frequently both notations are used in the same work.

=== Set version of big O === In computer science<ref name=":0"/> it is common to define {{nobr|big <math display="inline">O</math>}} as also defining a set of functions. With the positive (or non-negative) function <math>g(x)</math> specified, one interprets <math display="inline">O\bigl(g(x)\bigr)</math> as representing the ''set'' of all functions <math display="inline">\tilde f</math> that satisfy <math display="inline">\tilde f(x) = O\bigl(g(x)\bigr).</math> One can then equivalently write <math display="inline">f(x) \in O\bigl(g(x)\bigr),</math> read as "the function <math display="inline">\ f(x)\ </math> is among the set of all functions of {{nobr|order at most <math display="inline">g(x).</math>"}}

== Examples with an infinite domain == In typical usage the <math>O </math> notation is applied to an infinite interval of real numbers <math>[a,\infty)</math> and captures the behavior of the function for very large <math>x </math>. In this setting, the contribution of the terms that grow "most quickly" will eventually make the other ones irrelevant. As a result, the following simplification rules can be applied: *If <math>f(x) </math> is a sum of several terms, if there is one with largest growth rate, it can be kept, and all others omitted. *If <math>f(x) </math> is a product of several factors, any constants (factors in the product that do not depend on <math>x </math>) can be omitted. For example, let <math>f(x)=6x^4-2x^3+5 </math>, and suppose we wish to simplify this function, using <math>O </math> notation, to describe its growth rate for large <math>x </math>. This function is the sum of three terms: <math>6x^4 </math>, <math>-2x^3 </math>, and <math>5 </math>. Of these three terms, the one with the highest growth rate is the one with the largest exponent as a function of <math>x </math>, namely <math>6x^4 </math>. Now one may apply the second rule: <math> 6x^4 </math>is a product of <math>6 </math> and <math>x^4 </math> in which the first factor does not depend on <math>x </math>. Omitting this factor results in the simplified form <math>x^4 </math>. Thus, we say that <math>f(x) </math> is a "big O" of <math>x^4 </math>. Mathematically, we can write <math>f(x)=O(x^4) </math> for all <math>x\ge 1</math>. One may confirm this calculation using the formal definition: let <math>f(x)=6x^4-2x^3+5 </math> and <math>g(x)=x^4 </math>. Applying the formal definition from above, the statement that <math>f(x)=O(x^4) </math> is equivalent to its expansion, <math display="block">|f(x)| \le M x^4 </math> for some suitable choice of a positive real number <math> M </math> and for all <math>x \ge 1 </math>. To prove this, let <math>M=13 </math>. Then, for all <math>x\ge 1 </math>: <math display="block">\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 display="block"> |6x^4 - 2x^3 + 5| \le 13 x^4 .</math> While it is also true, by the same argument, that <math> f(x)=O(x^{10})</math>, this is a less precise approximation of the function <math>f</math>. On the other hand, the statement <math> f(x)=O(x^3)</math> is false, because the term <math> 6x^4</math> causes <math> f(x)/x^3 </math> to be unbounded.

When a function <math> T(n) </math> describes the number of steps required in an algorithm with input <math>n</math>, an expression such as <math display="block"> T(n)=O(n^2) </math> with the implied domain being the set of positive integers, may be interpreted as saying that the algorithm has ''at most the order of <math>n^2</math>'' time complexity.

== Example with a finite domain == Big O can also be used to describe the error term in an approximation to a mathematical function on a finite interval. The most significant terms are written explicitly, and then the least-significant terms are summarized in a single big O term. Consider, for example, the exponential series and two expressions of it that are valid when <math>x</math> is small: <math display=block>\begin{align} e^x &= 1 + x + \frac{\; x^2\ } {2! }+\frac{\; x^3\ }{3!}+\frac{\; x^4\ }{4!} + \dotsb && \text{ for all finite } x\\[4pt] &= 1 + x + \frac{\; x^2\ }{ 2 }+O(|x|^3) && \text{ for all } |x|\le 1 \\[4pt] &= 1 + x + O(x^2) && \text{ for all } |x|\le 1. \end{align}</math> The middle expression {{big|(}}the line with {{nobr|"<math>O(|x^3|)</math>"{{big|)}}}} means the absolute-value of the error <math>\ e^x- (1 + x + \frac{\; x^2\ }{2} )\ </math> is at most some constant times <math>~ |x^3|\ </math> when <math>\ x ~</math> is small. This is an example of the use of Taylor's theorem.

The behavior of a given function may be very different on finite domains than on infinite domains, for example, <math display=block> (x+1)^8 = x^8 + O(x^7) \quad \text{ for } x\ge 1 </math> while <math display=block> (x+1)^8 = 1 + 8x + O(x^2) \quad \text{ for } |x|\le 1. </math>

== Multivariate examples ==

<math display=block> x \sin y = O(x) \quad \text{ for }x\ge 1,y\text{ any real number} </math>

<math display=block> 3a^2+7ab+2b^2+a+3b+14 \ll a^2+b^2 \ll a^2 \quad \text{ for all } a\ge b\ge 1 </math>

<math display=block> \frac{xy}{x^2+y^2} = O(1) \quad \text{ for all real } x,y \text{ that are not both } 0 </math>

<math display=block> x^{it} = O(1) \quad \text{ for } x\ne 0,t\in \mathbb{R}. </math>

Here we have a complex variable function of two variables. In general, any bounded function is <math> O(1) </math>.

<math display=block> (x+y)^{10} = O(x^{10}) \quad \text{ for }x\ge 1, -2\le y\le 2. </math>

The last example illustrates a mixing of finite and infinite domains on the different variables.

In all of these examples, the bound is uniform in both variables. Sometimes in a multivariate expression, one variable is more important than others, and one may express that the implied constant <math>M</math> depends on one or more of the variables using subscripts to the big O symbol or the <math>\ll</math> symbol. For example, consider the expression

<math display=block> (1+x)^b = 1 + O_b(x) \quad \text{ for } 0 \le x\le 1, b\text{ any real number.} </math>

This means that for each real number <math>b</math>, there is a constant <math>M_b</math>, ''which depends on <math>b</math>'', so that for all <math>0\le x\le 1</math>, <math display=block> |(1+x)^b-1| \le M_b \cdot x. </math> This particular statement follows from the general binomial theorem.

Another example, common in the theory of Taylor series, is <math display=block> e^x = 1 + x + O_r(x^2) \quad \text{ for all } |x|\le r, r\text{ being any real number.} </math> Here the implied constant depends on the size of the domain.

The subscript convention applies to all of the other notations in this page.

== Properties ==

=== Product === :<math> f_1 = O(g_1) \text{ and } f_2 = O(g_2) \Rightarrow f_1 f_2 = O(g_1 g_2)</math> :<math>f\cdot O(g) = O(|f| g)</math>

=== Sum === If <math> f_1 = O(g_1)</math> and <math> f_2= O(g_2) </math> then <math> f_1 + f_2 = O(\max(g_1, g_2))</math>. It follows that if <math> f_1 = O(g) </math> and <math> f_2 = O(g)</math> then <math> f_1+f_2 = O(g) </math>.

=== Multiplication by a constant === Let {{mvar|k}} be a nonzero constant. Then <math>O(|k| \cdot g) = O(g)</math>. In other words, if <math>f = O(g)</math>, then <math>k \cdot f = O(g). </math>

=== Transitive property === If <math>f=O(g)</math> and <math> g=O(h) </math> then <math> f=O(h) </math>.

If the function <math>f</math> of a positive integer <math>n</math> can be written as a finite sum of other functions, then the fastest growing one determines the order of <math>f(n)</math>. For example, :<math>f(n) = 9 \log n + 5 (\log n)^4 + 3n^2 + 2n^3 = O(n^3) \qquad\text{for } n\ge 1 .</math> Some general rules about growth ''toward infinity''; the 2nd and 3rd property below can be proved rigorously using L'Hôpital's rule:

=== Large powers dominate small powers ===

For <math>b\ge a</math>, then <math display=block> n^a = O(n^b) </math> as <math> n \to \infty </math>.

=== Powers dominate logarithms ===

For any positive <math> a,b, </math> <math display="block"> (\log n)^a = O_{a,b}(n^b), </math> no matter how large <math> a</math> is and how small <math>b</math> is. Here, the implied constant depends on both <math> a </math> and <math>b</math>.

=== Exponentials dominate powers ===

For any positive <math> a,b, </math> <math display="block"> n^a = O_{a,b}(e^{bn}), </math> no matter how large <math> a</math> is and how small <math>b</math> is.

A function that grows faster than <math>n^c</math> for any <math> c</math> is called ''superpolynomial''. One that grows more slowly than any exponential function of the form <math> c^n </math> with <math> c>1 </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 and the function <math> n^{\log n} </math>.

We may ignore any powers of <math> n </math> inside of the logarithms. For any positive <math>c</math>, the notation <math> O(\log n)</math> means exactly the same thing as <math> O(\log (n^c))</math>, since <math> \log(n^c)=c\log n</math>. Similarly, logs with different constant bases are equivalent with respect to Big O notation. On the other hand, exponentials with different bases are not of the same order. For example, <math> 2^n </math> and <math> 3^n </math> are not of the same order.

=== More complicated expressions ===

In more complicated usage, <math> O(\cdot) </math> can appear in different places in an equation, even several times on each side. For example, the following are true for <math>n </math> a positive integer: <math display="block"> \begin{align} (n+1)^2 & = n^2 + O(n), \\ (n + O(n^{1/2})) \cdot (n + O(\log n))^2 & = n^3 + O(n^{5/2}), \\ n^{O(1)} & = O(e^n). \end{align}</math> The meaning of such statements is as follows: for ''any'' functions which satisfy each <math> O(\cdot) </math> on the left side, there are ''some'' functions satisfying each <math> O(\cdot) </math> 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 satisfying <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>". The implied constant in the statement "<math> g(n)=O(e^n) </math>" may depend on the implied constant in the expression "<math> f(n)=O(1)</math>".

Some further examples: <math display="block"> \begin{align} f=O(g)\; &\Rightarrow\; \int_a^b f = O\bigg( \int_a^b g \bigg) \\ f(x)=g(x)+O(1)\; &\Rightarrow\; e^{f(x)}=O(e^{g(x)}) \\ (1+O(1/x))^{O(x)} &= O(1) \quad \text{ for } x>0\\ \sin x &= O(|x|) \quad \text{ for all real } x. \end{align} </math>

=== Vinogradov's ≫ and Knuth's big Ω ===

When <math>f, g</math> are both positive functions, Vinogradov<ref name="vinogradov" /> introduced the notation <math> f(x) \gg g(x) </math>, which means the same as <math> g(x) = O(f(x)) </math>. Vinogradov's two notations enjoy visual symmetry, as for positive functions <math> f,g </math>, we have <math display=block> f(x) \ll g(x) \Longleftrightarrow g(x) \gg f(x). </math>

In 1976, Donald Knuth<ref name="knuth"/> defined

:<math>f(x)=\Omega(g(x))\Longleftrightarrow g(x)=O(f(x))</math>

which has the same meaning as Vinogradov's <math> f(x) \gg g(x) </math>.

However, much earlier, Hardy and Littlewood<ref name=HL/> had defined <math>\Omega </math> differently, and their notation enjoys widespread use today in analytic number theory.<ref name="titchmarsh"/><ref name="Ivic"/><ref name="tenenbaum"/> Justifying his use of the <math>\Omega</math>-symbol to describe a stronger property,<ref name="knuth"/> Knuth wrote: "For all the applications I have seen so far in computer science, a stronger requirement ... is much more appropriate". Knuth further wrote, "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."<ref name="knuth">{{cite journal |first=Donald |last=Knuth |doi-access=free |s2cid-access=free |title=Big Omicron and big Omega and big Theta |journal=SIGACT News |date=April–June 1976 |volume=8 |issue=2 |pages=18–24 |doi=10.1145/1008328.1008329 |s2cid=5230246 }}</ref> Knuth's big <math> \Omega </math> enjoys widespread use today in computer science and combinatorics.

=== Hardy's ≍ and Knuth's big Θ ===

In analytic number theory,<ref name="tenenbaum" /> the notation <math> f(x) \asymp g(x) </math> means both <math> f(x)=O(g(x)) </math> and <math> g(x)=O(f(x)) </math>. This notation is originally due to Hardy.<ref name="Hardy" /> Knuth's notation for the same notion is <math> f(x) = \Theta(g(x)) </math>.<ref name="knuth" /> Roughly speaking, these statements assert that <math> f(x) </math> and <math> g(x) </math> have the ''same order''. These notations mean that there are positive constants <math> M,N </math> so that <math display=block> N g(x) \le f(x) \le M g(x) </math> for all <math> x </math> in the common domain of <math> f,g </math>. When the functions are defined on the positive integers or positive real numbers, as with big O, writers oftentimes interpret statements <math> f(x) = \Omega(g(x)) </math> and <math> f(x)=\Theta(g(x)) </math> as holding for all sufficiently large <math> x </math>, that is, for all <math>x</math> beyond some point <math> x_0 </math>. Sometimes this is indicated by appending ''<math> x\to\infty </math>'' to the statement. For example, <math display=block> 2n^2 - 10n = \Theta(n^2) </math> is true for the domain <math> n\ge 6 </math> but false if the domain is all positive integers, since the function is zero at <math> n=5 </math>.

==== Further examples ====

<math display=block> n^3 + 20n^2 +n+12 \asymp n^3 \quad \text{ for all } n\ge 1. </math>

<math display=block> (1+x)^8 = x^8 + \Theta(x^7) \quad \text{ for all } x\ge 1. </math>

The notation

<math display=block> f(n) = e^{\Omega(n)} \quad \text{ for all } n\ge 1, </math> means that there is a positive constant <math> M </math> so that <math> f(n) \ge e^{Mn} </math> for all <math>n\ge 1</math>. By contrast, <math display=block> f(n) = e^{-O(n)} \quad \text{ for all } n\ge 1, </math> means that there is a positive constant <math> M </math> so that <math> f(n) \ge e^{-Mn} </math> for all <math>n\ge 1</math> and <math display=block> f(n) = e^{\Theta(n)} \quad \text{ for all } n\ge 1, </math> means that there are positive constants <math> M,N </math> so that <math> e^{M n} \le f(n) \le e^{N n} </math> for all <math>n\ge 1</math>.

For any domain <math> D</math>, <math display=block> f(x) = g(x)+O(1) \Longleftrightarrow e^{f(x)} \asymp e^{g(x)}, </math> each statement being for all <math>x</math> in <math>D</math>.

== Orders of common functions == {{Further|Time complexity#Table of common time complexities}} {{redirect|O(1)|the quasicoherent sheaf|Proj construction#The twisting sheaf of Serre}}

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 positive constant and ''n'' increases without bound. The slower-growing functions are generally listed first.

{| class="wikitable" |- !Notation !! Name !! Example |- |<math>O(1)</math> || constant || Finding the median value for a sorted array of numbers; Calculating <math>(-1)^n</math>; Using a constant-size lookup table |- |<math>O(\alpha (n))</math> || inverse Ackermann function || Amortized complexity per operation for the Disjoint-set data structure |-

|<math>O(\log \log n)</math> || double logarithmic || Average number of comparisons spent finding an item using interpolation search in a sorted array of uniformly distributed values |- |<math>O(\log n)</math> || logarithmic || Finding an item in a sorted array with a binary search or a balanced search tree as well as all operations in a binomial heap |- |<math>O((\log n)^c)</math><br /><math display=inline> c>1</math> || polylogarithmic || Matrix chain ordering can be solved in polylogarithmic time on a parallel random-access machine. |- |<math>O(n^c)</math><br /><math display=inline> 0<c<1</math> || fractional power || Searching in a k-d tree<br>Trial division naive primality testing (<math>O(\sqrt{n})</math>) |- |<math>O(n)</math> || linear || Finding an item in an unsorted list or in an unsorted array; adding two ''n''-bit integers by ripple carry |- |<math>O(n\log^* n)</math> || ''n'' log-star ''n'' || Performing triangulation of a simple polygon using Seidel's algorithm,<ref>{{Citation |last=Seidel |first=Raimund |title=A Simple and Fast Incremental Randomized Algorithm for Computing Trapezoidal Decompositions and for Triangulating Polygons |journal=Computational Geometry |volume=1 |pages=51–64 |year=1991 |citeseerx=10.1.1.55.5877 |doi=10.1016/0925-7721(91)90012-4 |author-link=Raimund Seidel |doi-access=free}}</ref> where <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, loglinear, quasilinear, or "<math>n\log n</math>" || Performing a fast Fourier transform; fastest possible comparison sort; heapsort and merge sort |- |<math>O(n^2)</math> || quadratic || Multiplying two <math>n</math>-digit numbers by schoolbook multiplication; simple sorting algorithms, such as bubble sort, selection sort and insertion sort; (worst-case) bound on some usually faster sorting algorithms such as quicksort, Shellsort, and tree sort |- |<math>O(n^c)</math> || polynomial or algebraic || Tree-adjoining grammar parsing; maximum matching for bipartite graphs; finding the determinant with LU decomposition |- |<math>L_n[\alpha,c] = e^{(c + o(1)) (\ln n)^\alpha (\ln \ln n)^{1-\alpha}}</math><br /><math display=inline> 0 < \alpha < 1</math> || L-notation or sub-exponential || Factoring a number using the quadratic sieve or number field sieve |- |<math>O(c^n)</math><br/><math display=inline> c>1</math> || 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 travelling salesman problem via brute-force search; generating all unrestricted permutations of a poset; finding the determinant with Laplace expansion; enumerating all partitions of a set |} 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. In many of these examples, the running time is actually <math> \Theta(g(n)) </math>, which conveys more precision.

==Little-o notation== <!-- Little-o notation redirects here --> {{Redirect|Little o|the baseball player|Omar Vizquel|the Greek letter|Omicron}}

For real or complex-valued functions of a real variable <math>x</math> with <math>g(x)>0</math> for sufficiently large <math>x</math>, one writes <ref name="Landau" /> :<math>f(x) = o(g(x)) \quad \text{ as } x \to \infty</math> if <math display=block> \lim_{x\to\infty} \frac{f(x)}{g(x)} = 0. </math> That is, for every positive constant {{mvar|ε}} there exists a constant <math>x_0</math> such that :<math>|f(x)| \leq \varepsilon g(x) \quad \text{ for all } x \geq x_0.</math> Intuitively, this means that <math>g(x)</math> grows much faster than <math>f(x)</math>, or equivalently <math>f(x)</math> grows much slower than <math>g(x)</math>. For example, one has : <math>200x = o(x^2)</math> and <math>1/x = o(1),</math> &nbsp; &nbsp; both as <math> x \to \infty .</math>

When one is interested in the behavior of a function for large values of <math>x</math>, little-o notation makes a ''stronger statement'' than the corresponding big-O notation: every function that is little-o of <math>g</math> is also big-O of <math>g</math> on some interval <math>[a,\infty)</math>, but not every function that is big-O of <math>g</math> is little-o of <math>g</math>. For example, <math>2x^2 = O(x^2) </math> but {{nowrap|<math>2x^2 \neq o(x^2)</math> for <math>x\ge 1</math>.}}

Little-o respects a number of arithmetic operations. For example, : if <math>c</math> is a nonzero constant and <math>f = o(g)</math> then <math>c \cdot f = o(g)</math>, and : if <math>f = o(F)</math> and <math>g = o(G)</math> then <math> f \cdot g = o(F \cdot G).</math> : if <math>f = o(F)</math> and <math>g = o(G)</math> then <math>f+g=o(F+G)</math> It also satisfies a transitivity relation: : if <math>f = o(g)</math> and <math> g = o(h)</math> then <math>f = o(h).</math>

Little-o can also be generalized to the finite case:<ref name="Landau"/> <math>f(x) = o(g(x)) \quad \text{ as } x \to x_0</math> if <math display=block> \lim_{x\to x_0} \frac{f(x)}{g(x)} = 0. </math> In other words, <math>f(x) = \alpha(x)g(x)</math> for some <math>\alpha(x)</math> with <math>\lim_{x\to x_0} \alpha(x) = 0</math>.

This definition is especially useful in the computation of limits using Taylor series. For example:

<math>\sin x = x - \frac{x^3}{3!} + \ldots = x + o(x^2) \text{ as } x\to 0</math>, so <math>\lim_{x\to 0}\frac{\sin x}x = \lim_{x\to 0} \frac{x + o(x^2)}{x} = \lim_{x\to 0} 1 + o(x) = 1</math>

=== Asymptotic notation ===

A relation related to little-o is the ''asymptotic'' notation <math>\sim</math>. For real valued functions <math>f,g</math>, the expression <math display=block> f(x) \sim g(x)\quad \text{ as }x\to\infty</math> means <math display=block> \lim_{x\to\infty} \frac{f(x)}{g(x)}=1.</math> One can connect this to little-o by observing that <math> f(x) \sim g(x) </math> is also equivalent to <math> f(x) = (1+o(1)) g(x) </math>. Here <math>o(1)</math> refers to a function tending to zero as <math>x\to\infty</math>. One reads this as "<math>f(x)</math> is ''asymptotic to'' <math>g(x)</math>". For nonzero functions on the same (finite or infinite) domain, <math> \sim </math> forms an equivalence relation.

One of the most famous theorems using the notation <math>\sim</math> is Stirling's formula <math display=block> n! \sim \bigg(\frac{n}{e}\bigg)^n \sqrt{2\pi n} \quad \text{ as }n\to\infty. </math> In number theory, the famous prime number theorem states that <math display=block> \pi(x) \sim \frac{x}{\log x} \quad \text{ as }x\to\infty, </math> where <math>\pi(x)</math> is the number of primes which are at most <math>x</math> and <math>\log</math> is the natural logarithm of <math>x</math>.

As with little-o, there is a version with finite limits (two-sided or one-sided) as well, for example <math display=block> \sin x \sim x \quad \text{ as }x\to 0. </math>

Further examples: <math display=block> x^a=o_{a,b} (e^{bx}) \quad \text{ as }x\to\infty, \text{ for any positive constants }a,b, </math> <math display=block> f(x)=g(x)+o(1) \quad \Longleftrightarrow\quad e^{f(x)}\sim e^{g(x)} \quad (x\to\infty). </math> <math display="block"> \sum_{n=1}^\infty \frac{1}{n^s} \sim \frac{1}{s-1}\quad (s\to1^+). </math> The last asymptotic is a basic property of the Riemann zeta function.

=== Knuth's little 𝜔 ===

For eventually positive, real valued functions <math>f, g,</math> the notation <math display=block> f(x) = \omega(g(x)) \quad \text{ as } x\to\infty </math> means <math display=block> \lim_{x\to\infty} \frac{f(x)}{g(x)} = \infty. </math> In other words, <math> g(x)=o(f(x)) </math>. Roughly speaking, this means that <math>f(x)</math> grows much faster than does <math>g(x)</math>.

=== The Hardy–Littlewood Ω notation === {{Anchor|The Hardy–Littlewood Ω}}In 1914 G. H. Hardy and J. E. Littlewood introduced the new symbol <math>\ \Omega,</math><ref name=HL>{{cite journal |last1=Hardy |first1=G. H. |author1-link=Godfrey Harold Hardy |last2=Littlewood |first2=J. E. |author2-link=John Edensor Littlewood |year=1914 |title=Some problems of diophantine approximation: {{nobr|Part II. The}} trigonometrical series associated with the elliptic {{mvar|θ}}&nbsp;functions |journal=Acta Mathematica |volume=37 |page=225 |doi=10.1007/BF02401834 |doi-access=free |url=https://projecteuclid.org/download/pdf_1/euclid.acta/1485887376 |url-status=live |access-date=2017-03-14 |archive-url=https://web.archive.org/web/20181212063403/https://projecteuclid.org/download/pdf_1/euclid.acta/1485887376 |archive-date=2018-12-12 }}</ref> which is defined as follows: :<math> f(x) = \Omega(g(x)) \quad </math> as <math>\quad x \to \infty \quad</math> if <math>\quad \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 1916 the same authors introduced the two new symbols <math>\ \Omega_R\ </math> and <math>\ \Omega_L\ ,</math> defined as:<ref name=HL2>{{cite journal |first1=G. H. |last1=Hardy |author1-link=Godfrey Harold Hardy |first2=J. E. |last2=Littlewood |author2-link=John Edensor Littlewood |year=1916 |title=Contribution to the theory of the Riemann zeta-function and the theory of the distribution of primes|journal=Acta Mathematica |volume=41 |pages=119–196 |doi=10.1007/BF02422942 }}</ref>

:<math> f(x) = \Omega_R(g(x)) \quad</math> as <math>\quad x \to \infty \quad</math> if <math>\quad \limsup_{x \to \infty}\ \frac{\ f(x)\ }{ g(x) } > 0\ ;</math>

:<math> f(x)=\Omega_L(g(x)) \quad</math> as <math>\quad x \to \infty \quad</math> if <math>\quad ~ \liminf_{x \to \infty}\ \frac{\ f(x)\ }{ g(x) }< 0 ~.</math>

These symbols were used by E. Landau, with the same meanings, in 1924.<ref name=landau>{{cite journal |first=E. |last=Landau |author-link=Edmund Landau |year=1924 |title=Über die Anzahl der Gitterpunkte in gewissen Bereichen.&nbsp;IV. |language=de |trans-title=On the number of grid points in known regions |journal=Nachr. Gesell. Wiss. Gött. Math-phys. |pages=137–150 }}</ref> Authors that followed Landau, however, use a different notation for the same definitions:<ref name="Ivic"/> The symbol <math>\ \Omega_R\ </math> has been replaced by the current notation <math>\ \Omega_{+}\ </math> with the same definition, 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.<ref name=Ivic>{{cite book |first=A. |last=Ivić |author-link=Aleksandar Ivić |year=1985 |title=The Riemann Zeta-Function |at=chapter&nbsp;9 |publisher=John Wiley & Sons }}</ref><ref name="tenenbaum"/>

==== Simple examples ====

We have

:<math>\sin x = \Omega(1) \quad</math> as <math>\quad x \to \infty\ ,</math>

and more precisely

:<math> \sin x = \Omega_\pm(1) \quad</math> as <math>\quad x\to\infty, ~</math> where <math> \Omega_{\pm}</math> means that the left side is both <math> \Omega_+(1)</math> and <math>\Omega_-(1)</math>,

We have

:<math> 1 + \sin x = \Omega(1) \quad</math> as <math>\quad x \to \infty\ ,</math>

and more precisely

:<math> 1 + \sin x = \Omega_{+}(1) \quad</math> as <math>\quad x \to \infty\ ;</math>

however

:<math> 1 + \sin x \ne \Omega_{-}(1) \quad</math> as <math>\quad x \to \infty ~.</math>

=== Family of Bachmann–Landau notations ===

For understanding the formal definitions, consult the list of logic symbols used in mathematics. {| class="wikitable" |- ! Notation ! Name<ref name="knuth" /> ! Description ! Formal definition ! Compact definition <ref name="iwaniec-kowalski"/> <ref name="Hardy"/> <ref name="knuth"/> <ref name="HL"/> <ref name="Balcázar">{{cite journal |last1=Balcázar |first1=José L. |last2=Gabarró |first2=Joaquim |title=Nonuniform complexity classes specified by lower and upper bounds |journal=RAIRO – Theoretical Informatics and Applications – Informatique Théorique et Applications |volume=23 |issue=2 |page=180 |url=http://archive.numdam.org/article/ITA_1989__23_2_177_0.pdf |via=Numdam |access-date=14 March 2017 |language=en |issn=0988-3754 |archive-date=14 March 2017 |archive-url=https://web.archive.org/web/20170314153158/http://archive.numdam.org/article/ITA_1989__23_2_177_0.pdf |url-status=live }}</ref><ref name=Cucker>{{cite book |last1=Cucker |first1=Felipe |last2=Bürgisser |first2=Peter |title=Condition: The Geometry of Numerical Algorithms |year=2013 |publisher=Springer |location=Berlin, Heidelberg |isbn=978-3-642-38896-5 |pages=467–468 |chapter=A.1 Big Oh, Little Oh, and Other Comparisons |chapter-url=https://books.google.com/books?id=SNu4BAAAQBAJ&pg=PA467 |doi=10.1007/978-3-642-38896-5}}</ref> |- | <math>f(n) = O(g(n))</math> or <math>f(n) \ll g(n) </math> (Vinogradov's notation) | Big O; Big Oh; Big Omicron<ref name="knuth" />{{efn| This name is suggested in the title of a paper of Knuth in 1976, and is found nowhere else in the rest of the paper. It is seldom or never used.}} | <math>|f|</math> is bounded above by {{mvar|g}} (up to constant factor <math>k</math>) | <math>\exists k > 0 \, \forall n\in D\colon |f(n)| \leq k\, g(n)</math> | <math>\sup_{n \in D} \frac{\left|f(n)\right|}{g(n)} < \infty</math> |- | <math>f(n) = o(g(n))</math> | Small O; Small Oh; Little O; Little Oh | {{mvar|f}} is dominated by {{mvar|g}} asymptotically (for any constant factor <math>k</math>) | <math>\forall k>0 \, \exists n_0 \, \forall n > n_0\colon |f(n)| \leq k\, g(n)</math> | <math>\lim_{n \to \infty} \frac{f(n)}{g(n)} = 0</math> |- |- | <math>f(n) = \Omega(g(n))</math> | Big Omega in number theory (Hardy–Littlewood) | <math>|f|</math> is not dominated by {{mvar|g}} asymptotically | <math>\exists k>0 \, \forall n_0 \, \exists n > n_0\colon |f(n)| \geq k\, g(n)</math> | <math>\limsup_{n \to \infty} \frac{|f(n)|}{g(n)} > 0 </math> |- | <math>f(n) = \Omega_+(g(n))</math> | Omega plus (Hardy–Littlewood) | <math>f</math> is not dominated by {{mvar|g}} asymptotically | <math>\exists k>0 \, \forall n_0 \, \exists n > n_0\colon f(n) \geq k\, g(n)</math> | <math>\limsup_{n \to \infty} \frac{f(n)}{g(n)} > 0 </math> |- | <math>f(n) = \Omega_-(g(n))</math> | Omega minus (Hardy–Littlewood) | <math>-f</math> is not dominated by {{mvar|g}} asymptotically | <math>\exists k>0 \, \forall n_0 \, \exists n > n_0\colon -f(n) \geq k\, g(n)</math> | <math>\limsup_{n \to \infty} \frac{-f(n)}{g(n)} > 0 </math> |- #style="border-top: 2px solid gray;" | <math>f(n) = \Omega_\pm(g(n))</math> | Omega plus and minus | neither <math>f</math> nor <math>-f</math> is dominated by {{mvar|g}} asymptotically | <math>f(n)=\Omega_+(g(n))</math> and <math>f(n)=\Omega_-(g(n))</math> |- | <math>f(n) \asymp g(n)</math> (Hardy's notation) or <math>f(n) = \Theta(g(n))</math> (Knuth notation) | Of the same order as (Hardy); Big Theta (Knuth) | {{mvar|f}} is bounded by {{mvar|g}} both above (with constant factor <math>k_2</math>) and below (with constant factor <math>k_1</math>) | <math>\exists k_1 > 0 \, \exists k_2>0 \, \forall n\in D\colon</math> <math>k_1 \, g(n) \leq f(n) \leq k_2 \, g(n)</math> | <math>f(n) = O(g(n))</math> and <math>g(n) = O(f(n))</math> |- | <math>f(n)\sim g(n)</math> as <math> n\to a </math>, where <math>a </math> is finite, <math>\infty</math> or <math>-\infty </math> | Asymptotic equivalence | {{mvar|f}} is equal to {{mvar|g}} asymptotically | <math>\forall \varepsilon > 0 \, \exists n_0 \, \forall n > n_0\colon \left| \frac{f(n)}{g(n)} - 1 \right| < \varepsilon</math> (in the case <math>a=\infty</math>) | <math>\lim_{n \to a} \frac{f(n)}{g(n)} = 1</math> |- | <math>f(n) = \Omega(g(n))</math> (Knuth's notation), or <math> f(n) \gg g(n) </math> (Vinogradov's notation) | Big Omega in complexity theory (Knuth) | {{mvar|f}} is bounded below by {{mvar|g}}, up to a constant factor | <math>\exists k > 0 \, \forall n\in D\colon f(n) \geq k\, g(n)</math> | <math>\inf_{n \in D} \frac{f(n)}{g(n)} > 0 </math> |- | <math>f(n) = \omega(g(n))</math> as <math>n\to a</math>, where <math>a</math> can be finite, <math>\infty</math> or <math>-\infty</math> | Small Omega; Little Omega | {{mvar|f}} dominates {{mvar|g}} asymptotically | <math>\forall k > 0 \, \exists n_0 \, \forall n > n_0 \colon f(n) > k\, g(n)</math> (for <math>a=\infty</math>) | <math>\lim_{n \to a} \frac{f(n)}{g(n)} = \infty</math> |}

The limit definitions assume <math>g(n) > 0</math> for <math>n</math> in a neighborhood of the limit; when the limit is <math>\infty</math>, this means that <math> g(n)>0</math> for sufficiently large <math>n</math>.

Computer science and combinatorics use the big <math>O </math>, big Theta <math>\Theta </math>, little <math>o </math>, little omega <math>\omega </math> and Knuth's big Omega <math>\Omega </math> notations. <ref name=":0"/> Analytic number theory often uses the big <math>O </math>, small <math>o </math>, Hardy's <math>\asymp</math>, Hardy–Littlewood's big Omega <math>\Omega </math> (with or without the +, − or ± subscripts), Vinogradov's <math>\ll</math> and <math>\gg</math> notations and <math>\sim</math> notations. <ref name=Ivic /> <ref name="iwaniec-kowalski"/> <ref name="tenenbaum">Gérald Tenenbaum, Introduction to analytic and probabilistic number theory, « Notation », page xxiii. American Mathematical Society, Providence RI, 2015.</ref> The small omega <math>\omega </math> notation is not used as often in analysis or in number theory. <ref>for example it is omitted in: {{cite web |last1=Hildebrand |first1=A.J. |title=Asymptotic Notations |url=http://www.math.uiuc.edu/~ajh/595ama/ama-ch2.pdf |website=Asymptotic Methods in Analysis |series=Math&nbsp;595, Fall 2009 |publisher=University of Illinois |place=Urbana, IL |department=Department of Mathematics |access-date=14 March 2017 |archive-date=14 March 2017 |archive-url=https://web.archive.org/web/20170314153801/http://www.math.uiuc.edu/~ajh/595ama/ama-ch2.pdf |url-status=live }}</ref>

=== Quality of approximations using different notation === {{Further|Analysis of algorithms}} Informally, especially in computer science, the big <math>O</math> notation often can be used somewhat differently to describe an asymptotic tight bound where using big Theta <math>\Theta</math> notation might be more factually appropriate in a given context .{{sfn|Cormen|Leiserson|Rivest|Stein|2022|p=57}} For example, when considering a function <math>T(n)=73n^3+22n^2+58</math>, all of the following are generally acceptable, but tighter bounds (such as numbers 2,3 and 4 below) are usually strongly preferred over looser bounds (such as number 1 below). #<math>T(n)=O(n^{100})</math> #<math>T(n)=O(n^{3})</math> #<math>T(n)=\Theta(n^3)</math> #<math>T(n)\sim 73n^3</math> as <math>n\to\infty</math>. 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 (items numbered 3 in the lists above). 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 bound on how long it will take to run without making an explicit statement about the lower bound or asymptotic behavior.

=== Extensions to the Bachmann–Landau notations === Another notation sometimes used in computer science is <math>\tilde{O}</math> (read ''soft-O''), which hides polylogarithmic factors. There are two definitions in use: some authors use <math> f(n) = \tilde{O}(g(n))</math> as shorthand for <math> f(n)=O(g(n)\log^k n) </math> for some <math>k</math>{{Citation needed|date=November 2025}}, while others use it as shorthand for <math> f(n)=O(g(n)\log^k g(n)) </math> .{{sfn|Cormen|Leiserson|Rivest|Stein|2022|p=74–75}} When <math>g(n)</math> is polynomial in <math>n</math>, there is no difference; however, the latter definition allows one to say, e.g. that <math>n2^n = \tilde O(2^n)</math> while the former definition allows for <math>\log^k n = \tilde O(1)</math> for any constant <math>k</math>. Some authors write ''O''<sup>*</sup> for the same purpose as the latter definition.<ref>{{cite journal | url=https://www.cs.helsinki.fi/u/mkhkoivi/publications/sicomp-2009.pdf | author=Andreas Björklund and Thore Husfeldt and Mikko Koivisto | title=Set partitioning via inclusion-exclusion | journal=SIAM Journal on Computing | volume=39 | number=2 | pages=546&ndash;563 | year=2009 | doi=10.1137/070683933 | access-date=2022-02-03 | archive-date=2022-02-03 | archive-url=https://web.archive.org/web/20220203095918/https://www.cs.helsinki.fi/u/mkhkoivi/publications/sicomp-2009.pdf | url-status=live }} See sect.2.3, p.551.</ref> Essentially, it is less precise version of the big ''O'' notation, ignoring logarithmic factors in the growth-rate of the function. Since <math> \log^k n = o(n^\varepsilon)</math> for any constant <math>k</math> and any <math>\varepsilon>0</math>, logarithmic factors are far less significant than powers of <math> n </math> and even more insignificant compared with exponentials.

Also, the ''L'' notation, defined as :<math>L_n[\alpha,c] = e^{(c + o(1))(\ln n)^\alpha(\ln\ln n)^{1-\alpha}},</math> is convenient for functions that are between polynomial and exponential in terms of <math>\log n</math>.

== Generalizations and related usages == The generalization to functions taking values in any normed vector space is straightforward (replacing absolute values by norms), where <math>f</math> and <math>g</math> need not take their values in the same space. A generalization to functions <math>g</math> taking values in any topological group is also possible{{Citation needed|date=May 2017}}. The "limiting process" <math>x\to x_0</math> can also be generalized by introducing an arbitrary filter base, i.e. to directed nets <math>f</math> and <math>g</math>. The <math>o</math> notation can be used to define derivatives 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 "<math>f</math> is <math>\Theta(g)</math>" from above. (It reduces to <math>\lim f/g = 1</math> if <math>f</math> and <math>g</math> are positive real valued functions.) For example, <math>2x=\Theta(x)</math> is, but <math> 2x-x \ne o(x) </math>.

== History == In 1870, Paul du Bois-Reymond <ref name="Bois-Reymond">{{cite journal |last1=Bois-Reymond |first1=Paul du |title=Sur la grandeur relative des infinis des fonctions |journal=Annali di Matematica |series=Series 2 |date=1870 |volume=4 |pages=338–353 |doi=10.1007/BF02420041 |url=https://link.springer.com/article/10.1007/BF02420041}}</ref> defined <math> f(x) \succ \phi(x) </math>, <math> f(x) \sim \phi(x) </math> and <math> f(x) \prec \phi(x)</math> to mean, respectively, <math display="block"> \lim_{x\to\infty}\frac{f(x)}{\phi(x)}=\infty, \quad \lim_{x\to\infty}\frac{f(x)}{\phi(x)}>0, \quad \lim_{x\to\infty}\frac{f(x)}{\phi(x)}=0. </math> These were not widely adopted and are not used today. The first and third are symmetric: <math> f(x) \prec \phi(x)</math> means the same as <math> \phi(x) \succ f(x)</math>. Landau later adopted <math> \sim </math> with the narrower definition that the limit of <math> f(x)/\phi(x)</math> equals 1.

The symbol O was first introduced by the number theorist Paul Bachmann in 1894, in the second volume of his book ''Analytische Zahlentheorie'' ("analytic number theory").<ref name="Bachmann">{{cite book |first=Paul |last=Bachmann |author-link=Paul Bachmann |title=Analytische Zahlentheorie |trans-title=Analytic Number Theory |language=de |volume=2 |location=Leipzig |publisher=Teubner |date=1894 |url=https://archive.org/stream/dieanalytischeza00bachuoft#page/402/mode/2up}}</ref> The number theorist Edmund Landau adopted it, and was thus inspired to introduce in 1909 the notation o;<ref name="Landau" /> 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 |publisher=Courier Corporation |isbn=978-0-486-60318-6}}.</ref> The symbol <math>\Omega</math> (in the sense "is not little ''o'' of") was introduced in 1914 by Hardy and Littlewood.<ref name="HL" /> Hardy and Littlewood also introduced in 1916 the left and right <math>\Omega</math> symbols <math>\Omega_R</math>, <math>\Omega_L</math> (now commonly denoted <math>\Omega_+, \Omega_-</math>).<ref name="HL2" /> This <math>\Omega</math> notation has been commonly used in number theory since the 1950s.<ref name="titchmarsh">E. C. Titchmarsh, The Theory of the Riemann Zeta-Function (Oxford; Clarendon Press, 1951)</ref>

Hardy introduced the symbols <math>\preccurlyeq </math> and advocated for Bois-Reymond's <math>\prec </math> (as well as the already mentioned other symbols) in his 1910 tract "Orders of Infinity",<ref name="Hardy" /> but made use of them only in three papers (1910–1913). In his nearly 400 remaining papers and books he consistently used the Landau symbols O and o.<ref>{{cite book |last1=Hardy |first1=G. H. |title=Collected papers of G. H. Hardy (Including Joint papers with J. E. Littlewood and others), 7 vols. |date=1966–1979 |publisher=Clarendon Press, Oxford}}</ref> Hardy's symbols <math>\preccurlyeq</math> and <math>\mathbin{\,\asymp\;\;\;\;\!\!\!\!\!\!\!\!\!\!\!\!\!-}</math> are not used any more.

The symbol <math>\sim</math>, although it had been used before with different meanings,<ref name="Bois-Reymond" /> was given its modern definition by Landau in 1909<ref name="Landau" /> and by Hardy in 1910.<ref name="Hardy" /> On the same page, Hardy defined the symbol <math>\asymp</math>, where <math>f(x)\asymp g(x)</math> means that both <math>f(x)=O(g(x))</math> and <math>g(x)=O(f(x))</math> are satisfied. The notation is still used in analytic number theory.<ref>{{cite book |last1=Hardy |first1=G. H. |last2=Wright |first2=E. M. |author-link2=E. M. Wright |others=Revised by D. R. Heath-Brown and J. H. Silverman, with a foreword by Andrew Wiles|title=An Introduction to the Theory of Numbers |edition=6th |publisher=Oxford University Press |location=Oxford |year=2008 |orig-year=1st ed. 1938 |isbn=978-0-19-921985-8|chapter=1.6. Some notations}}</ref> <ref name="tenenbaum" /> Hardy also proposed the symbol <math>\mathbin{\,\asymp\;\;\;\;\!\!\!\!\!\!\!\!\!\!\!\!\!-}</math>, where <math>f \mathbin{\,\asymp\;\;\;\;\!\!\!\!\!\!\!\!\!\!\!\!\!-} g</math> means that <math> f\sim Kg </math> for some constant <math>K\not=0</math> (this corresponds to Bois-Reymond's notation <math> f\sim g</math>).

In the 1930s, Vinogradov<ref name="vinogradov" /> popularized the notation <math> f(x) \ll g(x) </math> and <math> g(x) \gg f(x)</math>, both of which mean <math> f(x)=O(g(x)) </math>. This notation became standard in analytic number theory.<ref name="iwaniec-kowalski" />

In the 1970s, big O was popularized in computer science by Donald Knuth, who proposed the different notation <math>f(x)=\Theta(g(x))</math> for Hardy's <math>f(x)\asymp g(x)</math>, and proposed a different definition for the Hardy and Littlewood Omega notation.<ref name="knuth" />

== Matters of notation ==

=== Arrows ===

In mathematics, an expression such as <math> x\to\infty </math> indicates the presence of a limit. In big-O notation and related notations <math> \Omega, \Theta, \gg, \ll, \asymp</math>, there is no implied limit, in contrast with little-o, <math>\sim</math> and <math>\omega</math> notations. Notation such as <math> f(x)=O(g(x)) \;\; (x\to\infty)</math> can be considered an abuse of notation.

=== Equals sign === Some consider <math>f(x)=O(g(x))</math> to also 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 de Bruijn says, <math> O(x)=O(x^2)</math> is true but <math> O(x^2)=O(x)</math> is not.<ref name=deBruijn>{{cite book |first=N.G. |last=de Bruijn | author-link=N. G. de Bruijn | title=Asymptotic Methods in Analysis | place=Amsterdam | publisher=North-Holland | year=1958 | pages=5–7 | url=https://books.google.com/books?id=_tnwmvHmVwMC&q=%22The+trouble+is%22&pg=PA5 | isbn=978-0-486-64221-5 | access-date=2021-09-15 | archive-date=2023-01-17 | archive-url=https://web.archive.org/web/20230117051949/https://books.google.com/books?id=_tnwmvHmVwMC&q=%22The+trouble+is%22&pg=PA5 | url-status=live }}</ref> Knuth describes such statements as "one-way equalities", since if the sides could be reversed, "we could deduce ridiculous things like <math>n=n^2</math> from the identities <math>n=O(n^2)</math> and <math> n^2=O(n^2) </math>.<ref name="Concrete Mathematics">{{cite book |last1=Graham |first1=Ronald |author1-link=Ronald Graham |first2=Donald |last2=Knuth |author2-link=Donald Knuth |last3=Patashnik |first3=Oren |author3-link=Oren Patashnik |title=Concrete Mathematics |location=Reading, Massachusetts |publisher=Addison–Wesley |edition=2 |date=1994 |page=446 |url=https://books.google.com/books?id=pntQAAAAMAAJ |isbn=978-0-201-55802-9 |access-date=2016-09-23 |archive-date=2023-01-17 |archive-url=https://web.archive.org/web/20230117051955/https://books.google.com/books?id=pntQAAAAMAAJ |url-status=live }}</ref> In another letter, Knuth also pointed out that<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=https://www.ams.org/notices/199806/commentary.pdf | access-date=2021-09-05 | archive-date=2021-10-14 | archive-url=https://web.archive.org/web/20211014070416/https://www.ams.org/notices/199806/commentary.pdf | url-status=live }} ([http://www-cs-staff.stanford.edu/~knuth/ocalc.tex Unabridged version] {{Webarchive|url=https://web.archive.org/web/20080513234708/http://www-cs-staff.stanford.edu/~knuth/ocalc.tex |date=2008-05-13 }})</ref> {{blockquote|text= the equality sign is not symmetric with respect to such notations [as, in this notation,] mathematicians customarily use the '=' sign as they use the word 'is' in English: Aristotle is a man, but a man isn't necessarily Aristotle.}}

For these reasons, some advocate for using set notation and write <math> f(x) \in O(g(x)) </math>, read as "<math>f(x)</math> is an element of <math>O(g(x))</math>", or "<math>f(x)</math> is in the set <math>O(g(x))</math>"{{snd}} thinking of <math>O(g(x))</math> as the class of all functions <math>h(x)</math> such that <math>h(x)=O(g(x))</math>.<ref name="Concrete Mathematics" /> However, the use of the equals sign is customary.<ref name=deBruijn/><!-- p. 7: "Once this warning has been given, there is, however, not much harm in using the sign =, and we shall maintain it, for no other reason than that it is customary" --><ref name="Concrete Mathematics"/><!-- p. 446: "why don't we use ‘⊆’ instead of abusing the equals sign? There are four reasons. First, tradition ..." --> and is more convenient in more complex expressions of the form <math display=block> f(x) = g(x) + O(h(x)) = O(k(x)). </math>

The Vinogradov notations <math>\ll</math> and <math>\gg</math>, which are widely used in number theory <ref name="Ivic"/> <ref name="iwaniec-kowalski"/> <ref name="tenenbaum"/> do not suffer from this defect, as they more clearly indicate that big-O indicates an ''inequality'' rather than an ''equality''. They also enjoy a symmetry that big-O notation lacks: <math> f(x)\ll g(x)</math> means the same as <math> g(x)\gg f(x)</math>. In combinatorics and computer science, these notations are rarely seen.<ref name=":0"/>

=== Typesetting === Big O is typeset as an italicized uppercase "{{mvar|O}}{{-"}}, as in the following example: <math>O(n^2)</math>.<ref name="KnuthArt">Donald E. Knuth, The art of computer programming. Vol. 1. Fundamental algorithms, third edition, Addison Wesley Longman, 1997. Section 1.2.11.1.</ref><ref name="ConcreteMath">Ronald L. Graham, Donald E. Knuth, and Oren Patashnik, ''Concrete Mathematics: A Foundation for Computer Science (2nd ed.)'', Addison-Wesley, 1994. Section&nbsp;9.2, p.&nbsp;443.</ref> In TeX, it is produced by simply typing 'O' inside math mode. Unlike Greek-named Bachmann–Landau notations, it needs no special symbol. However, some authors use the calligraphic variant <math>\mathcal{O}</math> instead.<ref>Sivaram Ambikasaran and Eric Darve, An <math>\mathcal O (N \log N)</math> Fast Direct Solver for Partial Hierarchically Semi-Separable Matrices, ''J. Scientific Computing'' '''57''' (2013), no.&nbsp;3, 477–501.</ref><ref>Saket Saurabh and Meirav Zehavi, <math>(k,n-k)</math>-Max-Cut: An <math>\mathcal{O}^*(2^p)</math>-Time Algorithm and a Polynomial Kernel, ''Algorithmica'' '''80''' (2018), no.&nbsp;12, 3844–3860.</ref>

The big-O originally stands for "order of" ("Ordnung", Bachmann 1894), and is thus a Latin 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 zero should not be used.

== See also == * Asymptotic computational complexity * Asymptotic expansion: Approximation of functions by a series, generalizing Taylor's formula * Asymptotically optimal algorithm: 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 inferior and limit superior: An explanation of some of the limit notation used in this article * Master theorem (analysis of algorithms): For analyzing divide-and-conquer recursive algorithms using big O notation * Nachbin's theorem: A precise method of bounding complex analytic functions so that the domain of convergence of integral transforms can be stated * Order of approximation * Order of accuracy * Computational complexity of mathematical operations

== References and notes == {{Reflist|30em}}

=== Notes === {{Notelist}}

== Further reading == * {{cite book | first=Donald | last=Knuth | author-link=Donald Knuth | title=Fundamental Algorithms | volume=1 | series=The Art of Computer Programming | edition=3rd | publisher=Addison-Wesley | date=1997 | isbn=978-0-201-89683-1 | section=1.2.11: Asymptotic Representations}} * {{cite book | first=Michael | last=Sipser | author-link=Michael Sipser | year = 1997 | title = Introduction to the Theory of Computation | url=https://archive.org/details/introductiontoth00sips_928 | url-access=limited | publisher = PWS Publishing | isbn = 978-0-534-94728-6 | pages=[https://archive.org/details/introductiontoth00sips_928/page/n239 226]–228}} * {{cite conference | first1=Jeremy | last1=Avigad | first2=Kevin | last2=Donnelly | url=https://www.andrew.cmu.edu/~avigad/Papers/bigo.pdf | title=Formalizing O notation in Isabelle/HOL | doi=10.1007/978-3-540-25984-8_27 | conference=International Joint Conference on Automated Reasoning | date=2004}} * {{cite web | first=Paul E. | last=Black | url=https://xlinux.nist.gov/dads/HTML/bigOnotation.html | title=big-O notation | work=Dictionary of Algorithms and Data Structures | editor-first=Paul E. | editor-last=Black | publisher=U.S. National Institute of Standards and Technology | date=11 March 2005 | access-date=December 16, 2006}} * {{cite web | first=Paul E. | last=Black | url=https://xlinux.nist.gov/dads/HTML/littleOnotation.html | title=little-o notation | work=Dictionary of Algorithms and Data Structures | editor-first=Paul E. | editor-last=Black | publisher=U.S. National Institute of Standards and Technology | date=17 December 2004 | access-date=December 16, 2006}} * {{cite web | first=Paul E. | last=Black | url=https://xlinux.nist.gov/dads/HTML/omegaCapital.html | title=Ω | work=Dictionary of Algorithms and Data Structures | editor-first=Paul E. | editor-last=Black | publisher=U.S. National Institute of Standards and Technology | date=17 December 2004 | access-date=December 16, 2006}} * {{cite web | first=Paul E. | last=Black | url=https://xlinux.nist.gov/dads/HTML/omega.html | title=ω | work=Dictionary of Algorithms and Data Structures | editor-first=Paul E. | editor-last=Black | publisher=U.S. National Institute of Standards and Technology | date=17 December 2004 | access-date=December 16, 2006}} * {{cite web | first=Paul E. | last=Black | url=https://xlinux.nist.gov/dads/HTML/theta.html | title=Θ | work=Dictionary of Algorithms and Data Structures | editor-first=Paul E. | editor-last=Black | publisher=U.S. National Institute of Standards and Technology | date=17 December 2004 | access-date=December 16, 2006}}

== External links == {{Wikibooks|Data Structures|Asymptotic Notation#Big-O Notation|Big-O Notation}} {{sister project|project=wikiversity|text=Wikiversity solved a ''MyOpenMath problem'' using '''''Big-O Notation'''''}} * [https://oeis.org/wiki/Growth_of_sequences Growth of sequences — OEIS (Online Encyclopedia of Integer Sequences) Wiki] * [https://classes.soe.ucsc.edu/cse102/Fall21/Handouts/AsymptoticGrowth.pdf Introduction to Asymptotic Notations] * [http://www.perlmonks.org/?node_id=573138 Big-O Notation – What is it good for] *{{usurped|1=[https://web.archive.org/web/20181007223123/https://autarkaw.org/2013/01/30/making-sense-of-the-big-oh/ An example of Big O in accuracy of central divided difference scheme for first derivative]}} *[https://web.archive.org/web/20190729015611/https://discrete.gr/complexity/ A Gentle Introduction to Algorithm Complexity Analysis]

Category:Mathematical notation Category:Asymptotic analysis Category:Analysis of algorithms