Jump to content

Big O notation

From Wikipedia, the free encyclopedia
(Redirected from Asymptotic notation)

Template:Short description Template:Italic title Template: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[1] and Edmund Landau[2] 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 requirementsTemplate:Efn grow with the input.[3] 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.[4] 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.[5][6][7][8]

Bachmann proposed the notation in 1894 and Landau extended it in 1909. An earlier notation was proposed by Paul du Bois-Reymond in 1870.[9]

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 <math display="block"> f(x) = O\bigl(g(x)\bigr)\ </math> which is read as Template:Nobr is Template:Nobr of Template:Nobr 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. Template:Math 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 Template:Nobr 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 Template:Nobr 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,[3][10] 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.[3]

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 (Template: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,[6] the Russian number theorist Template:Nobr introduced the notation <math>\ll,</math> which has been increasingly used in number theory[4][11][12] 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[3] it is common to define Template:Nobr 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 Template:Nobr

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 Template:Bigthe line with Template:Nobr 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 display=block> f_1 = O(g_1) \text{ and } f_2 = O(g_2) \Rightarrow f_1 f_2 = O(g_1 g_2)</math> <math display=block>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 Template:Mvar 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 display=block>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[6] 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[8] defined

<math display=block>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[7] had defined <math>\Omega </math> differently, and their notation enjoys widespread use today in analytic number theory.[13][11][12] Justifying his use of the <math>\Omega</math>-symbol to describe a stronger property,[8] 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."[8] 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,[12] 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.[5] Knuth's notation for the same notion is <math> f(x) = \Theta(g(x)) </math>.[8] 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

Template:Further Template:Redirect

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.

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>
<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>
<math display=inline> 0<c<1</math>
fractional power Searching in a k-d tree
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 Template:Var-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,[14] 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>
<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>
<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

Template:Redirect

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 [2] <math display=block>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 Template:Mvar there exists a constant <math>x_0</math> such that <math display=block>|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>     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 Template:Nowrap

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:[2] <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

Template:AnchorIn 1914 G. H. Hardy and J. E. Littlewood introduced the new symbol <math>\ \Omega,</math>[7] 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:[15]

  • <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.[16] Authors that followed Landau, however, use a different notation for the same definitions:[11] 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.[11][12]

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.

Notation Name[8] Description Formal definition Compact definition

[4] [5] [8] [7] [17][18]

<math>f(n) = O(g(n))</math> or

<math>f(n) \ll g(n) </math> (Vinogradov's notation)

Big O; Big Oh; Big Omicron[8]Template:Efn f|</math> is bounded above by Template:Mvar (up to constant factor <math>k</math>) f(n)| \leq k\, g(n)</math> f(n)\right|}{g(n)} < \infty</math>
<math>f(n) = o(g(n))</math> Small O; Small Oh; Little O; Little Oh Template:Mvar is dominated by Template:Mvar asymptotically (for any constant factor <math>k</math>) 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) f|</math> is not dominated by Template:Mvar asymptotically f(n)| \geq k\, g(n)</math> f(n)|}{g(n)} > 0 </math>
<math>f(n) = \Omega_+(g(n))</math> Omega plus (Hardy–Littlewood) <math>f</math> is not dominated by Template:Mvar 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 Template:Mvar 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_\pm(g(n))</math> Omega plus and minus neither <math>f</math> nor <math>-f</math> is dominated by Template:Mvar 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) Template:Mvar is bounded by Template:Mvar 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 Template:Mvar is equal to Template:Mvar asymptotically \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) \gg g(n) </math> (Vinogradov's notation) or

<math>f(n) = \Omega(g(n))</math> (Knuth's notation)

No particular name in number theory (Vinogradov),

Big Omega in complexity theory (Knuth)

Template:Mvar is bounded below by Template:Mvar, 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 Template:Mvar dominates Template:Mvar 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. [3] 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. [11] [4] [12] The small omega <math>\omega </math> notation is not used as often in analysis or in number theory. [19]

Quality of approximations using different notation

Template:Further 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 .Template:Sfn 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).

  1. <math>T(n)=O(n^{100})</math>
  2. <math>T(n)=O(n^{3})</math>
  3. <math>T(n)=\Theta(n^3)</math>
  4. <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>Template:Citation needed, while others use it as shorthand for <math> f(n)=O(g(n)\log^k g(n)) </math> .Template:Sfn 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* for the same purpose as the latter definition.[20] 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 display=block>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>.

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 possibleTemplate:Citation needed. 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 display=block> 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 [9] 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").[1] The number theorist Edmund Landau adopted it, and was thus inspired to introduce in 1909 the notation o;[2] hence both are now called Landau symbols. These notations were used in applied mathematics during the 1950s for asymptotic analysis.[21] The symbol <math>\Omega</math> (in the sense "is not little o of") was introduced in 1914 by Hardy and Littlewood.[7] 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>).[15] This <math>\Omega</math> notation has been commonly used in number theory since the 1950s.[13]

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",[5] 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.[22] 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,[9] was given its modern definition by Landau in 1909[2] and by Hardy in 1910.[5] 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.[23] [12] 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[6] 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.[4]

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.[8]

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.[24] 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>.[25] In another letter, Knuth also pointed out that[26]

<templatestyles src="Template:Blockquote/styles.css" />

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.{{#if:|

|}}{{#if:|

}}{{#invoke:Check for unknown parameters|check|unknown=Template:Main other|preview=Page using Template:Blockquote with unknown parameter "_VALUE_"|ignoreblank=y| 1 | 2 | 3 | 4 | 5 | author | by | char | character | cite | class | content | multiline | personquoted | publication | quote | quotesource | quotetext | sign | source | style | text | title | ts }}

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>"Template: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>.[25] However, the use of the equals sign is customary.[24][25] 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 [11] [4] [12] 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.[3]

Typesetting

Big O is typeset as an italicized uppercase "Template:MvarTemplate:-", as in the following example: <math>O(n^2)</math>.[27][28] 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.[29][30]

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,[8] probably in reference to his definition of the symbol Omega. The digit zero should not be used.

See also

References and notes

Template:Reflist

Notes

Template:Notelist

Further reading

|CitationClass=web }}

  • {{#invoke:citation/CS1|citation

|CitationClass=web }}

  • {{#invoke:citation/CS1|citation

|CitationClass=web }}

  • {{#invoke:citation/CS1|citation

|CitationClass=web }}

  • {{#invoke:citation/CS1|citation

|CitationClass=web }}

Template:Sister project Template:Sister project

  1. ↑ 1.0 1.1 Template:Cite book
  2. ↑ 2.0 2.1 2.2 2.3 2.4 Template:Cite book
  3. ↑ 3.0 3.1 3.2 3.3 3.4 3.5 Template:Cite book
  4. ↑ 4.0 4.1 4.2 4.3 4.4 4.5 Template:Cite book
  5. ↑ 5.0 5.1 5.2 5.3 5.4 Template:Cite book
  6. ↑ 6.0 6.1 6.2 6.3 Template:Cite journal
    Translated in English in:
    Template:Cite book
  7. ↑ 7.0 7.1 7.2 7.3 7.4 Template:Cite journal
  8. ↑ 8.00 8.01 8.02 8.03 8.04 8.05 8.06 8.07 8.08 8.09 Template:Cite journal
  9. ↑ 9.0 9.1 9.2 Template:Cite journal
  10. ↑ Template:Cite book
  11. ↑ 11.0 11.1 11.2 11.3 11.4 11.5 Template:Cite book
  12. ↑ 12.0 12.1 12.2 12.3 12.4 12.5 12.6 Gérald Tenenbaum, Introduction to analytic and probabilistic number theory, « Notation », page xxiii. American Mathematical Society, Providence RI, 2015.
  13. ↑ 13.0 13.1 E. C. Titchmarsh, The Theory of the Riemann Zeta-Function (Oxford; Clarendon Press, 1951)
  14. ↑ Template:Citation
  15. ↑ 15.0 15.1 Template:Cite journal
  16. ↑ Template:Cite journal
  17. ↑ Template:Cite journal
  18. ↑ Template:Cite book
  19. ↑ for example it is omitted in: {{#invoke:citation/CS1|citation |CitationClass=web }}
  20. ↑ Template:Cite journal See sect.2.3, p.551.
  21. ↑ Template:Cite book.
  22. ↑ Template:Cite book
  23. ↑ Template:Cite book
  24. ↑ 24.0 24.1 Template:Cite book
  25. ↑ 25.0 25.1 25.2 Template:Cite book
  26. ↑ Template:Cite journal (Unabridged version Template:Webarchive)
  27. ↑ Donald E. Knuth, The art of computer programming. Vol. 1. Fundamental algorithms, third edition, Addison Wesley Longman, 1997. Section 1.2.11.1.
  28. ↑ Ronald L. Graham, Donald E. Knuth, and Oren Patashnik, Concrete Mathematics: A Foundation for Computer Science (2nd ed.), Addison-Wesley, 1994. Section 9.2, p. 443.
  29. ↑ 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. 3, 477–501.
  30. ↑ 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. 12, 3844–3860.