Big O notation explained

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 German mathematicians Paul Bachmann and Edmund Landau[1] and expanded by others, collectively called Bachmann–Landau notation. The letter O was chosen by Bachmann to stand for Ordnung, meaning the order of approximation.

In computer science, big O notation is used to classify algorithms according to how their run time or space requirements grow as the input size grows.[2] In analytic number theory, big O notation is often used to express bounds on the growth of an arithmetical function; one well-known example is the remainder term in the prime number theorem.In mathematical analysis, including calculus,Big O notation is used to bound the error when truncating a power series and to express the qualityof approximation of a real or complex valued functionby 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

o

,

\sim

,

\Omega

,

\ll

,

\gg

,

\asymp

,

\omega

, and

\Theta

to describe other kinds of bounds on growth rates.[3]

Formal definition

Let f, the function to be estimated, be either a real or complex valued function defined on a domain D, and let g, the comparison function, be a non-negative real valued function defined on the same set D. 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

f(x) = O\bigl(g(x)\bigr)\ which is read as is of if there exists a positive real number M such that

\left| f(x) \right|\le M\ g(x) \qquad ~ \mathsf ~ \quad x \in D.

If

g(x)>0

(i.e. is also never zero) throughout the domain

D,

an equivalent definition is that the ratio \frac is bounded, i.e. there is a positive real number

M

so that \Big|\frac\Big| \le M for all

x\inD.

These encompass all the uses of 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

g(x)

appearing within the argument of O\bigl(\cdot \bigr) to be as simple a form as possible, omitting constant factors and lower order terms. The number M is called the implied constant because it is normally not specified. When using notation, what matters is that some finite

M

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 definitionis still in common use,[2] [4] especially in computer science. When restricted to functions which are eventually positive, the notation

f(x) =O\bigl(g(x)\bigr) \qquad ~ \mathsf \quad x \to \inftymeans that for some real number a, f(x) = O\bigl(g(x)\bigr) in the domain \left[a,\infty\right).</math> Here, the expression <math display="inline">x \to \infty</math> doesn't indicate a [[limit (mathematics)|limit]], but the notion that the inequality holds for large enough x. The expression x \to \infty often is omitted.[2]

Similarly, for a finite real number a, the notation

f(x) = O\bigl(g(x)\bigr) \qquad ~ \text \ x \to a means that for some constant c > 0, f(x) = O\bigl(g(x)\bigr) on the interval

\left[a-c,a+c\right];

that is, in a small neighborhood of

a.

In addition, the notation\ f(x) = h(x) + O\bigl(g(x)\bigr)\ means f(x) - h(x)= O\bigl(g(x)\bigr). More complicated expressions are also possible.

Despite the presence of the equal sign as written, the expression f(x) = O\bigl(g(x)\bigr) does not refer to an equality, but rather to an inequality relating f and g.

In the 1930s,[5] the Russian number theorist introduced the notation

\ll,

which has been increasingly used in number theory[6] and other branches of mathematics, as an alternative to the O notation. We have

\ f \ll g \iff f = O\bigl(g\bigr). Frequently both notations are used in the same work.

Set version of big O

In computer science[2] it is common to define as also defining a set of functions. With the positive (or non-negative) function

g(x)

specified, one interprets O\bigl(g(x)\bigr) as representing the set of all functions \tilde f that satisfy \tilde f(x) =O\bigl(g(x)\bigr). One can then equivalently write f(x) \in O\bigl(g(x)\bigr), read as "the function \ f(x)\ is among the set of all functions of

Examples with an infinite domain

In typical usage the

O

notation is applied to an infinite interval of real numbers

[a,infty)

and captures the behavior of the function for very large

x

. 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:

f(x)

is a sum of several terms, if there is one with largest growth rate, it can be kept, and all others omitted.

f(x)

is a product of several factors, any constants (factors in the product that do not depend on

x

) can be omitted.For example, let

f(x)=6x4-2x3+5

, and suppose we wish to simplify this function, using

O

notation, to describe its growth rate for large

x

. This function is the sum of three terms:

6x4

,

-2x3

, and

5

. Of these three terms, the one with the highest growth rate is the one with the largest exponent as a function of

x

, namely

6x4

. Now one may apply the second rule:

6x4

is a product of

6

and

x4

in which the first factor does not depend on

x

. Omitting this factor results in the simplified form

x4

. Thus, we say that

f(x)

is a "big O" of

x4

. Mathematically, we can write

f(x)=O(x4)

for all

x\ge1

. One may confirm this calculation using the formal definition: let

f(x)=6x4-2x3+5

and

g(x)=x4

. Applying the formal definition from above, the statement that

f(x)=O(x4)

is equivalent to its expansion,|f(x)| \le M x^4 for some suitable choice of a positive real number

M

and for all

x\ge1

. To prove this, let

M=13

. Then, for all

x\ge1

:\begin|6x^4 - 2x^3 + 5| &\le 6x^4 + |-2x^3| + 5\\ &\le 6x^4 + 2x^4 + 5x^4\\ &= 13x^4\endso |6x^4 - 2x^3 + 5| \le 13 x^4 .While it is also true, by the same argument, that

f(x)=O(x10)

, this is a less preciseapproximation of the function

f

.On the other hand, the statement

f(x)=O(x3)

is false, because the term

6x4

causes

f(x)/x3

to be unbounded.

When a function

T(n)

describes the numberof steps required in an algorithm with input

n

, an expression such as T(n)=O(n^2) with the implied domain being the set of positive integers, may be interpreted as saying that the algorithm has at most the order of

n2

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

x

is small:\begine^x &= 1 + x + \frac +\frac+\frac + \dotsb && \text x\\[4pt] &= 1 + x + \frac+O(|x|^3) && \text |x|\le 1 \\[4pt] &= 1 + x + O(x^2) && \text |x|\le 1.\endThe middle expression the line with means the absolute-value of the error

ex-(1+x+

x2 
2

)

is at most some constant times

~|x3|

when

x~

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,(x+1)^8 = x^8 + O(x^7) \quad \text x\ge 1while(x+1)^8 = 1 + 8x + O(x^2) \quad \text |x|\le 1.

Multivariate examples

x \sin y = O(x) \quad \textx\ge 1,y\text

3a^2+7ab+2b^2+a+3b+14 \ll a^2+b^2 \ll a^2 \quad \text a\ge b\ge 1

\frac = O(1) \quad \text x,y \text 0

x^ = O(1) \quad \text x\ne 0,t\in \mathbb.

Here we have a complex variable function of two variables.In general, any bounded function is

O(1)

.

(x+y)^ = O(x^) \quad \textx\ge 1, -2\le y\le 2.

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

In all of these examples, the bound is uniformin both variables. Sometimes in a multivariate expression, one variable ismore important than others, and one may expressthat the implied constant

M

depends on oneor more of the variables using subscripts to the big O symbol or the

\ll

symbol. For example, consider the expression

(1+x)^b = 1 + O_b(x) \quad \text 0 \le x\le 1, b\text

This means that for each real number

b

, there is a constant

Mb

, which depends on

b

, so that for all

0\lex\le1

, |(1+x)^b-1| \le M_b \cdot x. This particular statement follows from the general binomial theorem.

Another example, common in the theory of Taylor series, is e^x = 1 + x + O_r(x^2) \quad \text |x|\le r, r\textHere the implied constant depends on the size of the domain.

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

Properties

Product

f1=O(g1)andf2=O(g2)f1f2=O(g1g2)

fO(g)=O(|f|g)

Sum

If

f1=O(g1)

and

f2=O(g2)

then

f1+f2=O(max(g1,g2))

. It follows that if

f1=O(g)

and

f2=O(g)

then

f1+f2=O(g)

.

Multiplication by a constant

Let be a nonzero constant. Then

O(|k|g)=O(g)

. In other words, if

f=O(g)

, then

kf=O(g).

Transitive property

If

f=O(g)

and

g=O(h)

then

f=O(h)

.

If the function

f

of a positive integer

n

can be written as a finite sum of other functions, then the fastest growing one determines the order of

f(n)

. For example,

f(n)=9logn+5(logn)4+3n2+2n3=O(n3)    forn\ge1.

Some general rules about growth toward infinity; the 2nd and 3rd property belowcan be proved rigorously using L'Hôpital's rule:

Large powers dominate small powers

For

b\gea

, thenn^a = O(n^b)as

n\toinfty

.

Powers dominate logarithms

For any positive

a,b,

(\log n)^a = O_(n^b),no matter how large

a

is and how small

b

is. Here, the implied constant dependson both

a

and

b

.

Exponentials dominate powers

For any positive

a,b,

n^a = O_(e^),no matter how large

a

is and how small

b

is.

A function that grows faster than

nc

for any

c

is called superpolynomial. One that grows more slowly than any exponential function of the form

cn

with

c>1

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

nlog

.

We may ignore any powers of

n

inside of the logarithms. For any positive

c

, the notation

O(logn)

means exactly the same thing as

O(log(nc))

, since

log(nc)=clogn

. 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,

2n

and

3n

are not of the same order.

More complicated expressions

In more complicated usage,

O()

can appear in different places in an equation, even several times on each side. For example, the following are true for

n

a positive integer:\begin(n+1)^2 & = n^2 + O(n), \\(n + O(n^)) \cdot (n + O(\log n))^2 & = n^3 + O(n^), \\n^ & = O(e^n).\endThe meaning of such statements is as follows: for any functions which satisfy each

O()

on the left side, there are some functions satisfying each

O()

on the right side, such that substituting all these functions into the equation makes the two sides equal. For example, the third equation above means: "For any function satisfying

f(n)=O(1)

, there is some function

g(n)=O(en)

such that

nf(n)=g(n)

". The implied constant in the statement "

g(n)=O(en)

" maydepend on the implied constant in the expression"

f(n)=O(1)

".

Some further examples:\beginf=O(g)\; &\Rightarrow\; \int_a^b f = O\bigg(\int_a^b g \bigg) \\f(x)=g(x)+O(1)\; &\Rightarrow\; e^=O(e^) \\(1+O(1/x))^ &= O(1) \quad \text x>0\\\sin x &= O(|x|) \quad \text x.\end

Vinogradov's ≫ and Knuth's big Ω

When

f,g

are both positive functions,Vinogradov introduced the notation

f(x)\ggg(x)

, which means the same as

g(x)=O(f(x))

. Vinogradov's two notations enjoy visual symmetry, asfor positive functions

f,g

, we havef(x) \ll g(x) \Longleftrightarrow g(x) \gg f(x).

In 1976, Donald Knuthdefined

f(x)=\Omega(g(x))\Longleftrightarrowg(x)=O(f(x))

which has the same meaning as Vinogradov's

f(x)\ggg(x)

.

Much earlier, Hardy and Littlewood defined

\Omega

differently, but this it seldom used anymore (Ivič's book being one exception).Justifying his use of the

\Omega

-symbol to describe a stronger property, Knuth wrote: "For all the applications I have seen so far in computer science, a stronger requirement ... is much more appropriate". Knuth further wrote, "Although I have changed Hardy and Littlewood's definition of

\Omega

, 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."[7]

Indeed, Knuth's big

\Omega

enjoys much more widespread use today than the Hardy–Littlewood big

\Omega

, being a common featurein computer science and combinatorics.

Hardy's ≍ and Knuth's big Θ

In analytic number theory, thenotation

f(x)\asympg(x)

means both

f(x)=O(g(x))

and

g(x)=O(f(x))

. This notation is originally due to Hardy. Knuth's notation for the same notion is

f(x)=\Theta(g(x))

. Roughly speaking, these statements assert that

f(x)

and

g(x)

have the same order. These notations mean that there are positive constants

M,N

so that N g(x) \le f(x) \le M g(x) for all

x

in the common domain of

f,g

. When the functions are defined on the positive integers or positive real numbers, as with big O, writers oftentimes interpret statements

f(x)=\Omega(g(x))

and

f(x)=\Theta(g(x))

as holding for all sufficiently large

x

, that is, for all

x

beyond some point

x0

. Sometimes thisis indicated by appending

x\toinfty

to the statement. For example, 2n^2 - 10n = \Theta(n^2) is true for the domain

n\ge6

but false if thedomain is all positive integers, since the function is zero at

n=5

.

Further examples

n^3 + 20n^2 +n+12 \asymp n^3 \quad \text n\ge 1.

(1+x)^8 = x^8 + \Theta(x^7) \quad \text x\ge 1.

The notation

f(n) = e^ \quad \text n\ge 1,means that there is a positive constant

M

so that

f(n)\geeMn

for all

n\ge1

. By contrast,f(n) = e^ \quad \text n\ge 1,means that there is a positive constant

M

so that

f(n)\gee-Mn

for all

n\ge1

andf(n) = e^ \quad \text n\ge 1,means that there are positive constants

M,N

so that

eM\lef(n)\leeN

for all

n\ge1

.

For any domain

D

,f(x) = g(x)+O(1) \Longleftrightarrow e^ \asymp e^,each statement being for all

x

in

D

.

Orders of common functions

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

O(1)

Finding the median value for a sorted array of numbers; Calculating

(-1)n

; Using a constant-size lookup table

O(\alpha(n))

Amortized complexity per operation for the Disjoint-set data structure

O(loglogn)

double logarithmic Average number of comparisons spent finding an item using interpolation search in a sorted array of uniformly distributed values

O(logn)

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

O((logn)c)


c>1
Matrix chain ordering can be solved in polylogarithmic time on a parallel random-access machine.

O(nc)


0
fractional power Searching in a k-d tree

O(n)

Finding an item in an unsorted list or in an unsorted array; adding two n-bit integers by ripple carry

O(nlog*n)

n log-star n Performing triangulation of a simple polygon using Seidel's algorithm, where

log*(n)= \begin{cases} 0,&ifn\leq1\\ 1+log*(logn),&ifn>1 \end{cases}

O(nlogn)=O(logn!)

linearithmic, loglinear, quasilinear, or "

nlogn

"
Performing a fast Fourier transform; fastest possible comparison sort; heapsort and merge sort

O(n2)

Multiplying two

n

-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

O(nc)

polynomial or algebraic Tree-adjoining grammar parsing; maximum matching for bipartite graphs; finding the determinant with LU decomposition

Ln[\alpha,c]=

(c+o(1))(lnn)\alpha(lnlnn)1-\alpha
e

0 < \alpha < 1
Factoring a number using the quadratic sieve or number field sieve

O(cn)


c>1
Finding the (exact) solution to the travelling salesman problem using dynamic programming; determining if two logical statements are equivalent using brute-force search

O(n!)

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

f(n)=O(n!)

is sometimes weakened to

f(n)=O\left(nn\right)

to derive simpler formulas for asymptotic complexity.In many of these examples, the running time isactually

\Theta(g(n))

, which conveys moreprecision.

Little-o notation

For real or complex-valued functions of a real variable

x

with

g(x)>0

for sufficiently large

x

, one writes

f(x)=o(g(x))asx\toinfty

if \lim_ \frac = 0.That is, for every positive constant there exists a constant

x0

such that

|f(x)|\leq\varepsilong(x)forallx\geqx0.

Intuitively, this means that

g(x)

grows much faster than

f(x)

, or equivalently

f(x)

grows much slower than

g(x)

.For example, one has

200x=o(x2)

and

1/x=o(1),

    both as

x\toinfty.

When one is interested in the behavior of a function for large values of

x

, little-o notation makes a stronger statement than the corresponding big-O notation: every function that is little-o of

g

is also big-O of

g

on some interval

[a,infty)

, but not every function that is big-O of

g

is little-o of

g

. For example,

2x2=O(x2)

but

Little-o respects a number of arithmetic operations. For example,

if

c

is a nonzero constant and

f=o(g)

then

cf=o(g)

, and

if

f=o(F)

and

g=o(G)

then

fg=o(FG).

if

f=o(F)

and

g=o(G)

then

f+g=o(F+G)

It also satisfies a transitivity relation:

if

f=o(g)

and

g=o(h)

then

f=o(h).

Little-o can also be generalized to the finite case:[1]

f(x)=o(g(x))asx\tox0

if \lim_ \frac = 0.In other words,

f(x)=\alpha(x)g(x)

for some

\alpha(x)

with
\lim
x\tox0

\alpha(x)=0

.

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

\sinx=x-

x3
3!

+\ldots=x+o(x2)asx\to0

, so

\limx\to

\sinx
x

=\limx\to

x+o(x2)
x

=\limx\to1+o(x)=1

Asymptotic notation

A relation related to little-o is the asymptotic notation

\sim

. For real valued functions

f,g

, the expression f(x) \sim g(x)\quad \textx\to\inftymeans \lim_ \frac=1.One can connect this to little-o by observing that

f(x)\simg(x)

is also equivalent to

f(x)=(1+o(1))g(x)

. Here

o(1)

refers to a function tending to zero as

x\toinfty

. One reads this as"

f(x)

is asymptotic to

g(x)

". For nonzero functions on the same (finite or infinite) domain,

\sim

forms anequivalence relation.

One of the most famous theorems using the notation

\sim

is Stirling's formulan! \sim \bigg(\frac\bigg)^n \sqrt \quad \textn\to\infty.In number theory, the famous prime number theorem states that\pi(x) \sim \frac \quad \textx\to\infty,where

\pi(x)

is the number of primes whichare at most

x

and

log

is thenatural logarithm of

x

.

As with little-o, there is a version with finite limits (two-sided or one-sided) as well, for example \sin x \sim x \quad \textx\to 0.

Further examples:x^a=o_ (e^) \quad \textx\to\infty,\texta,b,f(x)=g(x)+o(1) \quad \Longleftrightarrow\quade^\sim e^ \quad (x\to\infty). \sum_^\infty \frac \sim \frac\quad(x\to\infty).The last asymptotic is a basic property of theRiemann zeta function.

Knuth's little

For eventually positive, real valued functions

f,g,

the notationf(x) = \omega(g(x)) \quad \text x\to\inftymeans \lim_ \frac = \infty.In other words,

g(x)=o(f(x))

.Roughly speaking, this means that

f(x)

grows much faster than does

g(x)

.

The Hardy–Littlewood Ω notation

In 1914 G.H. Hardy and J.E. Littlewood introduced the new symbol

\Omega,

[8] which is defined as follows:

f(x)=\Omegal(g(x)r)

as

x\toinfty

if

\limsupx\left|

f(x)
g(x)

\right|>0~.

Thus

~f(x)=\Omegal(g(x)r)~

is the negation of

~f(x)=ol(g(x)r)~.

In 1916 the same authors introduced the two new symbols

\OmegaR

and

\OmegaL,

defined as:[9]

f(x)=\OmegaRl(g(x)r)

as

x\toinfty

if

\limsupx

f(x)
g(x)

>0 ;

f(x)=\OmegaLl(g(x)r)

as

x\toinfty

if

~\liminfx

f(x)
g(x)

<0~.

These symbols were used by E. Landau, with the same meanings, in 1924.[10] Authors that followed Landau, however, use a different notation for the same definitions: The symbol

\OmegaR

has been replaced by the current notation

\Omega+

with the same definition, and

\OmegaL

became

\Omega-~.

These three symbols

\Omega,\Omega+,\Omega-,

as well as

f(x)=\Omega\pml(g(x)r)

(meaning that

f(x)=\Omega+l(g(x)r)

and

f(x)=\Omega-l(g(x)r)

are both satisfied), are now currently used in analytic number theory.[11]

Simple examples

We have

\sinx=\Omega(1)

as

x\toinfty,

and more precisely

\sinx=\Omega\pm(1)

as

x\toinfty,~

where

\Omega\pm

means that the left side is both

\Omega+(1)

and

\Omega-(1)

,

We have

1+\sinx=\Omega(1)

as

x\toinfty,

and more precisely

1+\sinx=\Omega+(1)

as

x\toinfty;

however

1+\sinx\ne\Omega-(1)

as

x\toinfty~.

Family of Bachmann–Landau notations

For understanding the formal definitions, consult thelist of logic symbols used in mathematics.

NotationNameDescriptionFormal definitionCompact definition[12] [13]

f(n)=o(g(n))

Small O; Small Oh; Little O; Little Oh is dominated by asymptotically (for any constant factor

k

)

\forallk>0\existsn0\foralln>n0\colon

f(n)\leq k\, g(n)

\limn

f(n)
g(n)

=0

f(n)=O(g(n))

or

f(n)\llg(n)

(Vinogradov's notation)
Big O; Big Oh; Big Omicron
f is bounded above by (up to constant factor

k

)

\existsk>0\foralln\inD\colon

f(n)\leq k\, g(n)

\supn

\left|f(n)\right|
g(n)

<infty

f(n)\asympg(n)

(Hardy's notation) or

f(n)=\Theta(g(n))

(Knuth notation)
Of the same order as (Hardy); Big Theta (Knuth) is bounded by both above (with constant factor

k2

) and below (with constant factor

k1

)

\existsk1>0\existsk2>0\foralln\inD\colon

k1g(n)\leqf(n)\leqk2g(n)

f(n)=O(g(n))

and

g(n)=O(f(n))

f(n)\simg(n)

as

n\toa

, where

a

is finite,

infty

or

-infty

Asymptotic equivalence is equal to asymptotically

\forall\varepsilon>0\existsn0\foralln>n0\colon\left

\frac - 1 \right< \varepsilon (in the case

a=infty

)

\limn

f(n)
g(n)

=1

f(n)=\Omega(g(n))

(Knuth's notation), or

f(n)\ggg(n)

(Vinogradov's notation)
Big Omega in complexity theory (Knuth) is bounded below by, up to a constant factor

\existsk>0\foralln\inD\colonf(n)\geqkg(n)

infn

f(n)
g(n)

>0

f(n)=\omega(g(n))

as

n\toa

,where

a

can be finite,

infty

or

-infty

Small Omega; Little Omega dominates asymptotically

\forallk>0\existsn0\foralln>n0\colonf(n)>kg(n)

(for

a=infty

)

\limn

f(n)
g(n)

=infty

f(n)=\Omega(g(n))

Big Omega in number theory (Hardy–Littlewood)
f is not dominated by asymptotically

\existsk>0\foralln0\existsn>n0\colon

f(n)\geq k\, g(n)

\limsupn

\left|f(n)\right|
g(n)

>0

The limit definitions assume

g(n)>0

for

n

in a neighborhood of the limit; when thelimit is

infty

, this means that

g(n)>0

for sufficiently large

n

.

Computer science and combinatorics use the big

O

, big Theta

\Theta

, little

o

, little omega

\omega

and Knuth's big Omega

\Omega

notations.[2] Analytic number theory often uses the big

O

, small

o

, Hardy's

\asymp

,Hardy–Littlewood's big Omega

\Omega

(with or without the +, − or ± subscripts), Vinogradov's

\ll

and

\gg

notations and

\sim

notations. [6] [14] The small omega

\omega

notation is not used as often in analysis or in number theory.[15]

Quality of approximations using different notation

Informally, especially in computer science, the big

O

notation often can be used somewhat differently to describe an asymptotic tight bound where using big Theta

\Theta

notation might be more factually appropriate in a given context.For example, when considering a function

T(n)=73n3+22n2+58

, 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).

T(n)=O(n100)

T(n)=O(n3)

T(n)=\Theta(n3)

T(n)\sim73n3

as

n\toinfty

.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

T(n)

represents the running time of a newly developed algorithm for input size

n

, 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

\tilde{O}

(read soft-O), which hides polylogarithmic factors. There are two definitions in use: some authors use

f(n)=\tilde{O}(g(n))

as shorthand for

f(n)=O(g(n)logkn)

for some

k

, while others use it as shorthand for

f(n)=O(g(n)logkg(n))

.When

g(n)

is polynomial in

n

, there is no difference; however, the latter definition allows one to say, e.g. that

n2n=\tildeO(2n)

while the former definition allows for

logkn=\tildeO(1)

for any constant

k

. Some authors write O* for the same purpose as the latter definition.[16] Essentially, it is big O notation, ignoring logarithmic factors because the growth-rate effects of some other super-logarithmic function indicate a growth-rate explosion for large-sized input parameters that is more important to predicting bad run-time performance than the finer-point effects contributed by the logarithmic-growth factor(s). This notation is often used to obviate the "nitpicking" within growth-rates that are stated as too tightly bounded for the matters at hand (since

logkn=o(n\varepsilon)

for any constant

k

and any

\varepsilon>0.

Also, the L notation, defined as

Ln[\alpha,c]=

(c+o(1))(lnn)\alpha(lnlnn)1-\alpha
e

,

is convenient for functions that are between polynomial and exponential in terms of

logn

.

Generalizations and related usages

The generalization to functions taking values in any normed vector space is straightforward (replacing absolute values by norms), where

f

and

g

need not take their values in the same space. A generalization to functions

g

taking values in any topological group is also possible.The "limiting process"

x\tox0

can also be generalized by introducing an arbitrary filter base, i.e. to directed nets

f

and

g

. The

o

notation can be used to define derivatives and differentiability in quite general spaces, and also (asymptotical) equivalence of functions,

f\simg\iff(f-g)\ino(g)

which is an equivalence relation and a more restrictive notion than the relationship "

f

is

\Theta(g)

" from above. (It reduces to

\limf/g=1

if

f

and

g

are positive real valued functions.) For example,

2x=\Theta(x)

is, but

2x-x\neo(x)

.

History

We sketch the history of the Bois-Reymond, Bachmann–Landau, Hardy, Vinogradov and Knuth notations.

In 1870, Paul du Bois-Reymond [17] defined

f(x)\succ\phi(x)

,

f(x)\sim\phi(x)

and

f(x)\prec\phi(x)

to mean, respectively,\lim_\frac=\infty, \quad\lim_\frac>0, \quad\lim_\frac=0.These were not widely adopted and are not used today.The first and third enjoy a symmetry:

f(x)\prec\phi(x)

means the same as

\phi(x)\succf(x)

. Later, Landau adopted

\sim

in the narrowersense that the limit of

f(x)/\phi(x)

equals 1. None of these notations is in use today.

The symbol O was first introduced by number theorist Paul Bachmann in 1894, in the second volume of his book Analytische Zahlentheorie ("analytic number theory").[18] The number theorist Edmund Landau adopted it, and was thus inspired to introduce in 1909 the notation o; hence both are now called Landau symbols. These notations were used in applied mathematics during the 1950s for asymptotic analysis.[19] The symbol

\Omega

(in the sense "is not an o of") was introduced in 1914 by Hardy and Littlewood. Hardy and Littlewood also introduced in 1916 the symbols

\OmegaR

("right") and

\OmegaL

("left"),. This notation

\Omega

became somewhat commonly used in number theory at least since the 1950s.[20]

The symbol

\sim

, although it had been used before with different meanings, was given its modern definition by Landau in 1909 and by Hardy in 1910. Just above on the same page of his tract Hardy defined the symbol

\asymp

, where

f(x)\asympg(x)

means that both

f(x)=O(g(x))

and

g(x)=O(f(x))

are satisfied. The notation is still currently used in analytic number theory.[21] In his tract Hardy also proposed the symbol

n{\asymp    -}

, where

fn{\asymp    -}g

means that

f\simKg

for some constant

K\not=0

(this corresponds to Bois-Reymond's notation

f\simg

).

In the 1930s, Vinogradov popularized the notation

f(x)\llg(x)

and

g(x)\ggf(x)

, both of which mean

f(x)=O(g(x))

. This notation became standard in analytic number theory.

In the 1970s the big O was popularized in computer science by Donald Knuth, who proposed the different notation

f(x)=\Theta(g(x))

for Hardy's

f(x)\asympg(x)

, and proposed a different definition for the Hardy and Littlewood Omega notation.

Hardy introduced the symbols

\preccurlyeq

and advocated for Boid-Reymond's

\prec

(as well as the already mentioned other symbols) in his 1910 tract "Orders of Infinity", 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

\preccurlyeq

and

n{\asymp    -}

are not used anymore.

Matters of notation

Arrows

In mathematics, an expression such as

x\toinfty

indicates the presence of a limit. In big-O notation and related notations

\Omega,\Theta,\gg,\ll,\asymp

, there is no implied limit, in contrast with little-o,

\sim

and

\omega

notations.Notation such as

f(x)=O(g(x))  (x\toinfty)

can be considered an abuse of notation.

Equals sign

Some consider

f(x)=O(g(x))

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,

O(x)=O(x2)

is true but

O(x2)=O(x)

is not.[23] Knuth describes such statements as "one-way equalities", since if the sides could be reversed, "we could deduce ridiculous things like

n=n2

from the identities

n=O(n2)

and

n2=O(n2)

.[24] In another letter, Knuth also pointed out that[25]

For these reasons, some advocate for using set notation and write

f(x)\inO(g(x))

,read as "

f(x)

is an element of

O(g(x))

", or "

f(x)

is in the set

O(g(x))

" thinking of

O(g(x))

as the class of all functions

h(x)

such that

h(x)=O(g(x))

. However, the use of the equals sign is customary.[23] [24] and is more convenient in more complex expressions of the formf(x) = g(x) + O(h(x)) = O(k(x)).

The Vinogradov notations

\ll

and

\gg

, which are widely used in number theory[11] [6] [14] 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:

f(x)\llg(x)

means the same as

g(x)\ggf(x)

. In combinatorics and computer science, these notationsare rarely seen.[2]

Typesetting

Big O is typeset as an italicized uppercase ", as in the following example:

O(n2)

.[26] [27] 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

l{O}

instead.[28] [29]

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

See also

References and notes

Notes

Further reading

External links

Notes and References

  1. Book: Landau, Edmund . Edmund Landau . Handbuch der Lehre von der Verteilung der Primzahlen . B.G. Teubner; reprinted as two volumes in one by Chelsea, 1974, with an appendix by Dr. Paul T. Bateman . 1909 . Leipzig . Handbook on the theory of the distribution of the primes . de . 59–63 .
  2. Book: Cormen . Thomas H. . Thomas H. Cormen . Introduction to Algorithms . Introduction to Algorithms . Leiserson . Charles E. . Charles E. Leiserson . Rivest . Ronald L. . Ronald L. Rivest . Stein . Clifford . Clifford Stein . MIT Press and McGraw-Hill . 2022 . 978-0-262-53091-0 . 4th . Characterizing running times.
  3. Book: Hardy, G. H. . G. H. Hardy . Orders of Infinity: The 'Infinitärcalcül' of Paul du Bois-Reymond . 1910 . 2. Cambridge University Press.
  4. Book: Sipser , Michael . 2012 . Introduction to the Theory of Computation . 3 . Boston, MA . PWS Publishin.
  5. Matveevič . Vinogradov . Ivan Matveyevich Vinogradov . 1934 . A new estimate for in Waring's problem . ru . Doklady Akademii Nauk SSSR . 5 . 5-6 . 249–253.

    Translated in English in:
    Book: Vinogradov, Matveevič . Ivan Matveyevich Vinogradov . 1985 . 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 . en . Springer-Verlag.

  6. Book: Iwaniec . Henryk . Henryk Iwaniec . Kowalski . Emmanuel . 2004 . Analytic Number Theory . American Mathematical Society.
  7. Donald . Knuth . free . free . Big Omicron and big Omega and big Theta . . April–June 1976 . 8 . 2 . 18–24 . 10.1145/1008328.1008329 . 5230246 .
  8. Hardy . G.H. . Godfrey Harold Hardy . Littlewood . J.E. . John Edensor Littlewood . 1914 . Some problems of diophantine approximation: trigonometrical series associated with the elliptic  functions . . 37 . 225 . 10.1007/BF02401834 . free . live . 2017-03-14 . https://web.archive.org/web/20181212063403/https://projecteuclid.org/download/pdf_1/euclid.acta/1485887376 . 2018-12-12 .
  9. G.H. . Hardy . Godfrey Harold Hardy . J.E. . Littlewood . John Edensor Littlewood . 1916 . Contribution to the theory of the Riemann zeta-function and the theory of the distribution of primes . . 41 . 119–196 . 10.1007/BF02422942 .
  10. E. . Landau . Edmund Landau . 1924 . Über die Anzahl der Gitterpunkte in gewissen Bereichen. IV. . de . On the number of grid points in known regions . Nachr. Gesell. Wiss. Gött. Math-phys. . 137–150 .
  11. Book: Ivić, A. . Aleksandar Ivić . 1985 . The Riemann Zeta-Function . chapter 9 . John Wiley & Sons .
  12. Balcázar . José L. . Gabarró . Joaquim . Nonuniform complexity classes specified by lower and upper bounds . RAIRO – Theoretical Informatics and Applications – Informatique Théorique et Applications . 23 . 2 . 180 . Numdam . 14 March 2017 . en . 0988-3754 . 14 March 2017 . https://web.archive.org/web/20170314153158/http://archive.numdam.org/article/ITA_1989__23_2_177_0.pdf . live .
  13. Book: Cucker . Felipe . Bürgisser . Peter . Condition: The Geometry of Numerical Algorithms . 2013 . Springer . Berlin, Heidelberg . 978-3-642-38896-5 . 467–468 . A.1 Big Oh, Little Oh, and Other Comparisons . https://books.google.com/books?id=SNu4BAAAQBAJ&pg=PA467 . 10.1007/978-3-642-38896-5.
  14. Gérald Tenenbaum, Introduction to analytic and probabilistic number theory, « Notation », page xxiii. American Mathematical Society, Providence RI, 2015.
  15. for example it is omitted in: Web site: Hildebrand . A.J. . Asymptotic Notations . Asymptotic Methods in Analysis . Math 595, Fall 2009 . University of Illinois . Urbana, IL . Department of Mathematics . 14 March 2017 . 14 March 2017 . https://web.archive.org/web/20170314153801/http://www.math.uiuc.edu/~ajh/595ama/ama-ch2.pdf . live .
  16. Set partitioning via inclusion-exclusion . Andreas Björklund and Thore Husfeldt and Mikko Koivisto . . 39 . 2 . 546 - 563 . 2009 . 10.1137/070683933 . 2022-02-03 . 2022-02-03 . https://web.archive.org/web/20220203095918/https://www.cs.helsinki.fi/u/mkhkoivi/publications/sicomp-2009.pdf . live . See sect.2.3, p.551.
  17. Bois-Reymond . Paul du . Sur la grandeur relative des infinis des fonctions . Annali di Matematica . Series 2 . 1870 . 4 . 338–353 . 10.1007/BF02420041 .
  18. Book: Bachmann, Paul . Paul Bachmann . Analytische Zahlentheorie . Analytic Number Theory . de . 2 . Leipzig . Teubner . 1894 .
  19. Book: Erdelyi, A. . Asymptotic Expansions . 1956 . Courier Corporation . 978-0-486-60318-6. .
  20. E. C. Titchmarsh, The Theory of the Riemann Zeta-Function (Oxford; Clarendon Press, 1951)
  21. Book: Hardy . G. H. . Wright . E. M. . E. M. Wright . Revised by D. R. Heath-Brown and J. H. Silverman, with a foreword by Andrew Wiles. An Introduction to the Theory of Numbers . 6th . Oxford University Press . Oxford . 2008 . 1st ed. 1938 . 978-0-19-921985-8. 1.6. Some notations.
  22. Book: Hardy . G. H. . Collected papers of G. H. Hardy (Including Joint papers with J. E. Littlewood and others), 7 vols. . 1966–1979 . Clarendon Press, Oxford.
  23. Book: de Bruijn, N.G. . N. G. de Bruijn . Asymptotic Methods in Analysis . Amsterdam . North-Holland . 1958 . 5–7 . 978-0-486-64221-5 . 2021-09-15 . 2023-01-17 . https://web.archive.org/web/20230117051949/https://books.google.com/books?id=_tnwmvHmVwMC&q=%22The+trouble+is%22&pg=PA5 . live .
  24. Book: Graham . Ronald . Ronald Graham . Donald . Knuth . Donald Knuth . Patashnik . Oren . Oren Patashnik . Concrete Mathematics . Reading, Massachusetts . Addison–Wesley . 2 . 1994 . 446 . 978-0-201-55802-9 . 2016-09-23 . 2023-01-17 . https://web.archive.org/web/20230117051955/https://books.google.com/books?id=pntQAAAAMAAJ . live .
  25. Donald Knuth . Teach Calculus with Big O . June–July 1998 . . 45 . 6 . 687 . 2021-09-05 . 2021-10-14 . https://web.archive.org/web/20211014070416/https://www.ams.org/notices/199806/commentary.pdf . live . (Unabridged version)
  26. Donald E. Knuth, The art of computer programming. Vol. 1. Fundamental algorithms, third edition, Addison Wesley Longman, 1997. Section 1.2.11.1.
  27. 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.
  28. Sivaram Ambikasaran and Eric Darve, An

    lO(NlogN)

    Fast Direct Solver for Partial Hierarchically Semi-Separable Matrices, J. Scientific Computing 57 (2013), no. 3, 477–501.
  29. Saket Saurabh and Meirav Zehavi,

    (k,n-k)

    -Max-Cut: An

    l{O}*(2p)

    -Time Algorithm and a Polynomial Kernel, Algorithmica 80 (2018), no. 12, 3844–3860.