In mathematics and science, it’s often too difficult to get precise formulas for things, so often researchers just estimate the growth. For example, in a previous post on the Fibonacci sequence, we found that the Fibonacci numbers grow roughly exponentially; that is, they are close to an exponential function, but there is a tiny error term. Often, we don’t actually care about the exact formula but we just want an idea of how quickly something grows. In order to capture this vague notion precisely, we use asymptotic notation, which captures all the long-run information contained in the original function.
Since all we care about is what happens in the long run, the definition of asymptotic notation involves limits. There are five primary notations: big-O, little-o, big-Omega, little-omega, and big-Theta. Don’t be intimidated by the large number of definitions. These are all defined very similarly, so once you understand one of them, you can understand them all. For that reason, we will focus on understanding big-O, and merely describe the differences from the others.
Big-O notation is used to describe upper bounds. Intuitively, the function is , pronounced “big-O of ,” if in the long run grows no faster than . We’ll briefly take a look at the technical definition, and then explain it in English:
A function if there is a constant such that whenever , for some .
The phrase “whenever , for some ” can be interpreted as “when gets large enough.” The can be seen as the “cutoff point,” where any larger will cause . Why do we want the constant to be there? Intuitively, constant multipliers don’t affect asymptotic growth. That is, we want to say that grows faster than , no matter how small is or how large is. These details only matter if you want to know the precise definition of big-O. If you just want to understand intuitively what big-O means, it means “grows no faster than.” Some properties and examples:
- ; obviously, no function grows faster than itself
- ; this is a consequence of how we designed big-O so that constant multipliers don’t matter
- If and , then ; this can be checked by the definitions, but it also makes sense intuitively—if grows no faster than , which grows no faster than , then of course grows no faster than !
- If $f(n) = O(g(n))$, then $O(f(n) + g(n)) = O(f(n))$
The last property is extremely important for polynomials. It basically means that when we look at polynomials, in big-O only the highest degree term matters, and we don’t care about the constants. This makes finding big-O of polynomials super easy. For example:
This comes in especially handy when estimating running times for algorithms. Let’s say we have an algorithm which, given points in the plane, finds the closest pair of points, and it does so by brute-force, comparing every pair of points. There are possible pairs, and each comparison takes some constant amount of time (this is why we don’t care about constants, because they change with advances in hardware), so in total the algorithm’s running time is .
Now, the other asymptotic notations are defined similarly. Intuitively, all you need to know is the following:
- A function is little-o of , written , if grows strictly slower than . In other words, little-o is to big-O as is to .
- A function is big-Omega of , written , if grows at least as fast as . In other words, big-Omega is to big-O as is to .
- A function is little-omega of , written , if grows strictly faster than . In other words, little-omega is to big-O as is to .
- Finally, a function is big-Theta of , written , if and . This means that grows asymptotically at the same rate as .
To recap, you should have learned the following from this post:
- What asymptotic notation is
- How to compute big-O of polynomials
- The use of asymptotic notation