Often, big O notation characterizes functions according to their growth rates as the variable becomes large: different functions with the sameasymptotic 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 theorder of the function. A description of a function in terms of big O notation only provides anupper bound on the growth rate of the function.
Associated with big O notation are several related notations, using the symbols,,,,,,, and to describe other kinds of bounds on growth rates.[5][6][7]
Let the function to be estimated, be either areal orcomplex valued function defined on adomain and let the comparison function, be a non-negative real valued function defined on the same set Common choices for the domain are intervals of real numbers, bounded or unbounded, the set of positive integers, the set ofcomplex numbers and tuples of real/complex numbers. With the domain written explicitly or understood implicitly, one writes
which is read as " isbig of" if there exists a positive real number such that
If (i.e.g is also never zero) throughout the domain an equivalent definition is that the ratio isbounded, i.e. there is a positive real number so that for all These encompass all the uses of big incomputer 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 appearing within theargument of to be as simple a form as possible, omitting constant factors and lower order terms. The number is called theimplied constant because it is normally not specified. When usingbig notation, what matters is that some finite 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,[3][8] especially in computer science. When restricted to functions which areeventually positive, the notation
means that for some real number in the domain Here, the expression doesn't indicate alimit, but the notion that the inequality holds forlarge enough The expression often is omitted.[3]
Similarly, for a finite real number the notation
means that for some constant on the interval that is, in a small neighborhood ofIn addition, the notationmeansMore complicated expressions are also possible.
Despite the presence of the equal sign (=) as written, the expression does not refer to anequality, but rather to an inequality relating and
In the 1930s,[6] the Russian number theoristI.M. Vinogradov introduced the notation which has been increasingly used in number theory[4][9][10] and other branches of mathematics, as an alternative to the notation. We have
Frequently both notations are used in the same work.
In computer science[3] it is common to definebig as also defining aset of functions. With the positive (or non-negative) function specified, one interprets as representing theset of all functions that satisfy One can then equivalently write read as "the function is among the set of all functions oforder at most"
In typical usage the notation is applied to an infinite interval of real numbers and captures the behavior of the function for very large. 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 is a sum of several terms, if there is one with largest growth rate, it can be kept, and all others omitted.
If is a product of several factors, any constants (factors in the product that do not depend on) can be omitted.
For example, let, and suppose we wish to simplify this function, using notation, to describe its growth rate for large. This function is the sum of three terms:,, and. Of these three terms, the one with the highest growth rate is the one with the largest exponent as a function of, namely. Now one may apply the second rule:is a product of and in which the first factor does not depend on. Omitting this factor results in the simplified form. Thus, we say that is a "big O" of. Mathematically, we can write for all. One may confirm this calculation using the formal definition: let and. Applying theformal definition from above, the statement that is equivalent to its expansion,for some suitable choice of a positive real number and for all. To prove this, let. Then, for all:soWhile it is also true, by the same argument, that, this is a less preciseapproximation of the function.On the other hand, the statement is false, because the term causes to be unbounded.
When a function describes the numberof steps required in an algorithm with input, an expression such aswith the implied domain being the set of positive integers, may be interpreted as saying that the algorithm hasat most the order of time complexity.
Big O can also be used to describe theerror 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, theexponential series and two expressions of it that are valid when is small:The middle expression(the line with"") means the absolute-value of the error is at most some constant times when is small.This is an example of the use ofTaylor's theorem.
The behavior of a given function may be very different on finite domains than on infinite domains, for example,while
Here we have acomplex variable function of two variables.In general, any bounded function is.
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 depends on oneor more of the variables using subscripts to the big O symbol or the symbol. For example, consider the expression
This means that for each real number, there is a constant,which depends on, so that for all,This particular statement follows from thegeneral binomial theorem.
Another example, common in the theory ofTaylor series, isHere the implied constant depends on the size of the domain.
The subscript convention applies to all of the othernotations in this page.
If the function of a positive integer can be written as a finite sum of other functions, then the fastest growing one determines the order of. For example,
Some general rules about growthtoward infinity; the 2nd and 3rd property belowcan be proved rigorously usingL'Hôpital's rule:
For any positiveno matter how large is and how small is.
A function that grows faster than for any is calledsuperpolynomial. One that grows more slowly than any exponential function of the form with is calledsubexponential. An algorithm can require time that is both superpolynomial and subexponential; examples of this include the fastest known algorithms forinteger factorization and the function.
We may ignore any powers of inside of the logarithms. For any positive, the notation means exactly the same thing as, since. 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, and are not of the same order.
In more complicated usage, can appear in different places in an equation, even several times on each side. For example, the following are true for a positive integer:The meaning of such statements is as follows: forany functions which satisfy each on the left side, there aresome functions satisfying each 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, there is some function such that". The implied constant in the statement "" maydepend on the implied constant in the expression"".
When are both positive functions,Vinogradov[6] introduced the notation, which means the same as. Vinogradov's two notations enjoy visual symmetry, asfor positive functions, we have
Much earlier, Hardy and Littlewood defineddifferently, but this it seldom used anymore (Ivič's book[9] being one exception).Justifying his use of the-symbol to describe a stronger property,[7] 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, 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 enjoys much more widespread use today than the Hardy–Littlewood big, being a common featurein computer science and combinatorics.
In analytic number theory,[10] thenotation means both and. This notation is originally due to Hardy.[5] Knuth's notation for the same notion is.[7] Roughly speaking, these statements assert that and have thesame order. These notations mean that there are positive constantsso thatfor all in the common domain of. When the functions are defined on the positive integers or positive real numbers, as with big O, writers oftentimes interpret statements and as holding for all sufficiently large, that is, for all beyond some point. Sometimes thisis indicated by appending to the statement. For example,is true for the domain but false if thedomain is all positive integers, since the function is zero at.
means that there is a positive constantso that for all. By contrast,means that there is a positive constantso that for all andmeans that there are positive constantsso that for all.
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 andn increases without bound. The slower-growing functions are generally listed first.
The statement is sometimes weakened to to derive simpler formulas for asymptotic complexity.In many of these examples, the running time isactually, which conveys moreprecision.
"Little o" redirects here. For the baseball player, seeOmar Vizquel. For the Greek letter, seeOmicron.
For real or complex-valued functions of a real variable with forsufficiently large, one writes[2]
ifThat is, for every positive constantε there exists a constant such that
Intuitively, this means that grows much faster than, or equivalently grows much slower than.For example, one has
and both as
When one is interested in the behavior of a function for large values of, little-o notation makes astronger statement than the corresponding big-O notation: every function that is little-o of is also big-O of on some interval, but not every function that is big-O of is little-o of. For example, but for.
Little-o respects a number of arithmetic operations. For example,
A relation related to little-o is theasymptotic notation. For real valued functions, the expressionmeansOne can connect this to little-o by observing that is also equivalent to. Here refers to a function tending to zero as. One reads this as" isasymptotic to". For nonzero functions on the same (finite or infinite) domain, forms anequivalence relation.
In 1916 the same authors introduced the two new symbols and defined as:[13]
as if
as if
These symbols were used byE. Landau, with the same meanings, in 1924.[14] Authors that followed Landau, however, use a different notation for the same definitions:[9] The symbol has been replaced by the current notation with the same definition, and became
These three symbols as well as (meaning that and are both satisfied), are now currently used inanalytic number theory.[9][10]
The limit definitions assume for in a neighborhood of the limit; when thelimit is, this means that for sufficiently large.
Computer science and combinatorics use the big, big Theta, little, little omega and Knuth's big Omega notations.[3] Analytic number theory often uses the big, small, Hardy's,Hardy–Littlewood's big Omega (with or without the +, − or ± subscripts), Vinogradov's and notations and notations.[9][4][10] The small omega notation is not used as often in analysis or in number theory.[17]
Quality of approximations using different notation
Informally, especially in computer science, the big notation often can be used somewhat differently to describe an asymptotictight bound where using big Theta notation might be more factually appropriate in a given context.[18]For example, when considering a function, 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).
as.
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 represents the running time of a newly developed algorithm for input size, 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.
Another notation sometimes used in computer science is (readsoft-O), which hides polylogarithmic factors. There are two definitions in use: some authors use as shorthand for for some[citation needed], while others use it as shorthand for.[19]When is polynomial in, there is no difference; however, the latter definition allows one to say, e.g. that while the former definition allows for for any constant. Some authors writeO* for the same purpose as the latter definition.[20] Essentially, it is bigO notation, ignoringlogarithmic factors because thegrowth-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 (sincefor any constant and any
The generalization to functions taking values in anynormed vector space is straightforward (replacing absolute values by norms), where and need not take their values in the same space. A generalization to functions taking values in anytopological group is also possible[citation needed].The "limiting process" can also be generalized by introducing an arbitraryfilter base, i.e. to directednets and. The notation can be used to definederivatives anddifferentiability in quite general spaces, and also (asymptotical) equivalence of functions,
which is anequivalence relation and a more restrictive notion than the relationship " is" from above. (It reduces to if and are positive real valued functions.) For example, is, but.
We sketch the history of the Bois-Reymond, Bachmann–Landau, Hardy, Vinogradov and Knuth notations.
In 1870, Paul du Bois-Reymond[21]defined, andto mean, respectively,These were not widely adopted and are not used today.The first and third enjoy a symmetry: means the same as. Later, Landau adopted in the narrowersense that the limit of equals 1. None of these notations is in use today.
The symbol O was first introduced by number theoristPaul Bachmann in 1894, in the second volume of his bookAnalytische Zahlentheorie ("analytic number theory").[1] The number theoristEdmund 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.[22]The symbol (in the sense "is not ano of") was introduced in 1914 by Hardy and Littlewood.[12] Hardy and Littlewood also introduced in 1916 the symbols ("right") and ("left"),.[13] This notation became somewhat commonly used in number theory at least since the 1950s.[23]
The symbol, although it had been used before with different meanings,[21] was given its modern definition by Landau in 1909[2] and by Hardy in 1910.[5] Just above on the same page of his tract Hardy defined the symbol, where means that both and are satisfied. The notation is still currently used in analytic number theory.[24][10] In his tract Hardy also proposed the symbol, where means that for some constant (this corresponds to Bois-Reymond's notation).
In the 1930s, Vinogradov[6] popularized the notationand, both of which mean. This notation became standard in analytic number theory.[4]
In the 1970s the big O was popularized in computer science byDonald Knuth, who proposed the different notation for Hardy's, and proposed a different definition for the Hardy and Littlewood Omega notation.[7]
Hardy introduced the symbols and advocated for Boid-Reymond's (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.[25]Hardy's symbols and are not used anymore.
In mathematics, an expression such as indicates the presence of alimit. In big-O notation and related notations, there is no implied limit, in contrast withlittle-o, and notations.Notation such as can be considered anabuse of notation.
Some consider to also be anabuse of notation, since the use of the equals sign could be misleading as it suggests a symmetry that this statement does not have. Asde Bruijn says, is true but is not.[26]Knuth describes such statements as "one-way equalities", since if the sides could be reversed, "we could deduce ridiculous things like from the identities and.[27] In another letter, Knuth also pointed out that[28]
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 usingset notation and write,read as "is an element of", or " is in the set" – thinking of as the class of all functions such that.[27] However, the use of the equals sign is customary.[26][27]and is more convenient in more complex expressions of the form
The Vinogradov notations and, which are widely used in number theory[9][4][10]do not suffer from this defect, as they more clearly indicate that big-O indicates aninequality rather than anequality. They also enjoy a symmetry that big-O notation lacks: means the same as. In combinatorics and computer science, these notationsare rarely seen.[3]
Big O is typeset as an italicized uppercase "O", as in the following example:.[29][30] InTeX, 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 instead.[31][32]
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 capitalomicron,[7] probably in reference to his definition of the symbolOmega. The digitzero should not be used.
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
^abcdVinogradov, Matveevič (1934). "A new estimate forG(n) in Waring's problem".Doklady Akademii Nauk SSSR (in Russian).5 (5–6):249–253.
Translated in English in:
Vinogradov, Matveevič (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. Springer-Verlag.
^Sipser, Michael (2012).Introduction to the Theory of Computation (3 ed.). Boston, MA: PWS Publishin.
^abcdefIvić, A. (1985).The Riemann Zeta-Function. John Wiley & Sons. chapter 9.
^abcdefGérald Tenenbaum, Introduction to analytic and probabilistic number theory, « Notation », page xxiii. American Mathematical Society, Providence RI, 2015.
^Landau, E. (1924). "Über die Anzahl der Gitterpunkte in gewissen Bereichen. IV" [On the number of grid points in known regions].Nachr. Gesell. Wiss. Gött. Math-phys. (in German):137–150.
^for example it is omitted in:Hildebrand, A.J."Asymptotic Notations"(PDF). Department of Mathematics.Asymptotic Methods in Analysis. Math 595, Fall 2009. Urbana, IL: University of Illinois.Archived(PDF) from the original on 14 March 2017. Retrieved14 March 2017.
^Donald E. Knuth, The art of computer programming. Vol. 1. Fundamental algorithms, third edition, Addison Wesley Longman, 1997. Section 1.2.11.1.
^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.
^Sivaram Ambikasaran and Eric Darve, An Fast Direct Solver for Partial Hierarchically Semi-Separable Matrices,J. Scientific Computing57 (2013), no. 3, 477–501.
^Saket Saurabh and Meirav Zehavi,-Max-Cut: An-Time Algorithm and a Polynomial Kernel,Algorithmica80 (2018), no. 12, 3844–3860.
^Note that the "size" of the input is typically used as an indication of how challenging a giveninstance 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 thatinstance of the problem. For purposes ofComputational complexity theory, Big 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.
Knuth, Donald (1997). "1.2.11: Asymptotic Representations".Fundamental Algorithms. The Art of Computer Programming. Vol. 1 (3rd ed.). Addison-Wesley.ISBN978-0-201-89683-1.
Black, Paul E. (11 March 2005). Black, Paul E. (ed.)."big-O notation".Dictionary of Algorithms and Data Structures. U.S. National Institute of Standards and Technology. RetrievedDecember 16, 2006.
Black, Paul E. (17 December 2004). Black, Paul E. (ed.)."little-o notation".Dictionary of Algorithms and Data Structures. U.S. National Institute of Standards and Technology. RetrievedDecember 16, 2006.
Black, Paul E. (17 December 2004). Black, Paul E. (ed.)."Ω".Dictionary of Algorithms and Data Structures. U.S. National Institute of Standards and Technology. RetrievedDecember 16, 2006.
Black, Paul E. (17 December 2004). Black, Paul E. (ed.)."ω".Dictionary of Algorithms and Data Structures. U.S. National Institute of Standards and Technology. RetrievedDecember 16, 2006.
Black, Paul E. (17 December 2004). Black, Paul E. (ed.)."Θ".Dictionary of Algorithms and Data Structures. U.S. National Institute of Standards and Technology. RetrievedDecember 16, 2006.