πŸ“ˆ

Big O Notation: Computer Science Study Notes

October 10, 2026

πŸ“š Big O Notation: A Comprehensive Guide

  • Main Topics Covered:
    • Foundational concepts and historical context of Big O notation
    • Formal definitions for general, infinite, and finite domains, including set-based interpretations
    • Practical examples across infinite, finite, and multivariate domains
    • Core mathematical properties and algebraic manipulation rules
    • Comparative growth rates of functions (polynomials, logarithms, and exponentials)
    • Advanced usage and specialized notations

πŸ’‘ Core Concepts and Background

Big O notation is a mathematical notation that describes the approximate size of a function on a domain. It is part of the Bachmann–Landau notation family, originally invented by German mathematicians Paul Bachmann (1894) and Edmund Landau (1909), with earlier contributions by Paul du Bois-Reymond (1870).

  • The letter O stands for Ordnung, meaning the order of approximation.
  • Upper bound: A description of a function using Big O notation only provides an upper bound on its growth rate.

Applications Across Fields

  • Computer Science: Classifies algorithms by how their run time or space requirements grow relative to the input size.
  • Analytic Number Theory: Expresses bounds on the growth of arithmetical functions (e.g., remainder terms in the prime number theorem).
  • Mathematical Analysis (Calculus): Bounds errors when truncating power series and expresses the quality of approximation of functions by simpler functions.

Related Notations

Several related symbols describe different kinds of bounds on growth rates:

  • oo (little-o)
  • ∼\sim (asymptotic equivalence)
  • Ξ©\Omega (Big Omega - lower bound)
  • β‰ͺ\ll (Vinogradov notation)
  • ≫\gg
  • ≍\asymp (asymptotic tightness)
  • Ο‰\omega (little omega)
  • Θ\Theta (Theta - tight bound)

πŸ“ Formal Definitions

1. General Definition

Let ff be a real or complex-valued function defined on a domain DD, and let gg be a non-negative real-valued comparison function on the same domain DD.

We write: f(x)=O(g(x))f(x) = O(g(x))

Read as: "f(x)f(x) is big OO of g(x)g(x)" if there exists a positive real number MM (called the implied constant) such that: ∣f(x)βˆ£β‰€Mβ‹…g(x)forΒ allΒ x∈D|f(x)| \leq M \cdot g(x) \quad \text{for all } x \in D

If g(x)>0g(x) > 0 throughout DD, an equivalent definition states that the ratio f(x)g(x)\frac{f(x)}{g(x)} is bounded; that is, there is a positive real number MM such that: ∣f(x)g(x)βˆ£β‰€MforΒ allΒ x∈D\left|\frac{f(x)}{g(x)}\right| \leq M \quad \text{for all } x \in D

Note: The equality sign (==) does not represent strict mathematical equality, but rather an inequality relating ff and gg. Vinogradov introduced the alternative notation fβ‰ͺgβ€…β€ŠβŸΊβ€…β€Šf=O(g)f \ll g \iff f = O(g).

2. Asymptotic Definitions (xβ†’βˆžx \to \infty or xβ†’ax \to a)

  • As xβ†’βˆžx \to \infty: For functions eventually positive on [a,∞)[a, \infty): f(x)=O(g(x))asΒ xβ†’βˆžf(x) = O(g(x)) \quad \text{as } x \to \infty means that for some real number aa, f(x)=O(g(x))f(x) = O(g(x)) holds on the domain [a,∞)[a, \infty).
  • In a neighborhood of aa: f(x)=O(g(x))asΒ xβ†’af(x) = O(g(x)) \quad \text{as } x \to a means that for some constant c>0c > 0, f(x)=O(g(x))f(x) = O(g(x)) holds on the interval [aβˆ’c,a+c][a-c, a+c].
  • Error terms: f(x)=h(x)+O(g(x))β€…β€ŠβŸΉβ€…β€Šf(x)βˆ’h(x)=O(g(x))f(x) = h(x) + O(g(x)) \implies f(x) - h(x) = O(g(x))

3. Set Version of Big O

In computer science, O(g(x))O(g(x)) often represents the set of all functions f~\tilde{f} that satisfy f~(x)=O(g(x))\tilde{f}(x) = O(g(x)). This is written as: f(x)∈O(g(x))f(x) \in O(g(x)) Read as: "The function f(x)f(x) is among the set of all functions of order at most g(x)g(x)."


πŸ“Š Practical Examples

Infinite Domain Examples (Large xx)

When analyzing behavior for very large xx, terms that grow most quickly dominate.

  • Sum Rule: Keep the term with the highest growth rate; omit all others.
  • Product Rule: Omit any constant factors that do not depend on xx.

Detailed Example: Let f(x)=6x4βˆ’2x3+5f(x) = 6x^4 - 2x^3 + 5 and g(x)=x4g(x) = x^4. To prove f(x)=O(x4)f(x) = O(x^4) for xβ‰₯1x \geq 1: ∣6x4βˆ’2x3+5βˆ£β‰€6x4+βˆ£βˆ’2x3∣+5≀6x4+2x4+5x4=13x4|6x^4 - 2x^3 + 5| \leq 6x^4 + |-2x^3| + 5 \leq 6x^4 + 2x^4 + 5x^4 = 13x^4 Choosing M=13M = 13 satisfies ∣f(x)βˆ£β‰€13x4|f(x)| \leq 13x^4 for all xβ‰₯1x \geq 1. (Note: O(x10)O(x^{10}) is a valid upper bound but less precise; O(x3)O(x^3) is false).

Finite Domain Examples

On finite intervals, error terms in function approximations are summarized using Big O. For example, using Taylor's theorem for small xx:

  • ex=1+x+x22!+x33!+β‹―(forΒ allΒ finiteΒ x)e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \dotsb \quad (\text{for all finite } x)
  • ex=1+x+x22+O(∣x∣3)(forΒ all ∣xβˆ£β‰€1)e^x = 1 + x + \frac{x^2}{2} + O(|x|^3) \quad (\text{for all } |x| \leq 1)
  • ex=1+x+O(x2)(forΒ all ∣xβˆ£β‰€1)e^x = 1 + x + O(x^2) \quad (\text{for all } |x| \leq 1)

Domain behavior can drastically change outcomes. For instance:

  • (x+1)8=x8+O(x7)(forΒ xβ‰₯1)(x+1)^8 = x^8 + O(x^7) \quad (\text{for } x \geq 1)
  • (x+1)8=1+8x+O(x2)(for ∣xβˆ£β‰€1)(x+1)^8 = 1 + 8x + O(x^2) \quad (\text{for } |x| \leq 1)

Multivariate Examples

ExpressionDomain ConstraintsInterpretation
xsin⁑y=O(x)x \sin y = O(x)xβ‰₯1,y∈Rx \ge 1, y \in \mathbb{R}Bound is uniform across variables.
xyx2+y2=O(1)\frac{xy}{x^2+y^2} = O(1)Real x,yx, y (not both 00)Any bounded function is O(1)O(1).
(x+y)10=O(x10)(x+y)^{10} = O(x^{10})xβ‰₯1,βˆ’2≀y≀2x \ge 1, -2 \le y \le 2Mix of finite and infinite domains.
(1+x)b=1+Ob(x)(1+x)^b = 1 + O_b(x)0≀x≀1,b∈R0 \le x \le 1, b \in \mathbb{R}Implied constant MbM_b depends on parameter bb.

βš™οΈ Algebraic Properties

OperationRule
Productf1=O(g1)Β andΒ f2=O(g2)β€…β€ŠβŸΉβ€…β€Šf1f2=O(g1g2)f_1 = O(g_1) \text{ and } f_2 = O(g_2) \implies f_1 f_2 = O(g_1 g_2)
fβ‹…O(g)=O(βˆ₯fβˆ₯g)f \cdot O(g) = O(\|f\|g)
Sumf1=O(g1)Β andΒ f2=O(g2)β€…β€ŠβŸΉβ€…β€Šf1+f2=O(max⁑(g1,g2))f_1 = O(g_1) \text{ and } f_2 = O(g_2) \implies f_1 + f_2 = O(\max(g_1, g_2))
If f1=O(g)f_1 = O(g) and f2=O(g)f_2 = O(g), then f1+f2=O(g)f_1 + f_2 = O(g).
Constant MultiplicationFor nonzero constant kk: O(βˆ₯kβˆ₯β‹…g)=O(g)β€…β€ŠβŸΉβ€…β€Škβ‹…f=O(g)O(\|k\| \cdot g) = O(g) \implies k \cdot f = O(g)
Transitive PropertyIf f=O(g)f = O(g) and g=O(h)g = O(h), then f=O(h)f = O(h).

πŸ“ˆ Growth Rate Hierarchies Toward Infinity

When analyzing polynomial, logarithmic, and exponential expressions as nβ†’βˆžn \to \infty, specific domination rules apply:

  1. Large powers dominate small powers: For bβ‰₯ab \ge a, na=O(nb)n^a = O(n^b) as nβ†’βˆžn \to \infty.
  2. Powers dominate logarithms: For any positive a,ba, b, (log⁑n)a=Oa,b(nb)(\log n)^a = O_{a,b}(n^b), regardless of how large aa is or how small bb is.
  3. Exponentials dominate powers: For any positive a,ba, b, na=Oa,b(ebn)n^a = O_{a,b}(e^{bn}).

Terminology Classifications

  • Superpolynomial: Grows faster than ncn^c for any cc.
  • Subexponential: Grows more slowly than any exponential function cnc^n (c>1c > 1).
  • Note on Logarithms & Bases: Powers of nn inside logarithms can be ignored (e.g., O(log⁑n)=O(log⁑(nc))O(\log n) = O(\log(n^c))). Logs with different constant bases are equivalent, whereas exponentials with different bases (2n2^n vs 3n3^n) are not of the same order.