Big Oh notation (Landau symbols)

In summary, the notation f(n)=O(g(n)) is a sloppy notation that was introduced by physicists. It is more accurate to write f(x)\in O(g(x)) but it is not necessary to do so.
  • #1
Edgardo
706
17
I have a question with respect to the Big Oh notation, in which the Landau symbol [tex]O(n)[/tex] is involved.
The Landau symbol [itex]O(n)[/itex] is defined as:

[tex]f(n)=O(g(n))[/tex] if there exists an integer [tex]n_0[/tex] and a constant [tex]C>0[/tex]
such that for all integers [tex]n \geq n_0[/tex], [tex]f(n) \leq C \cdot g(n)[/tex].

For example [tex]f(n)= 5 \cdot n = O(n)[/tex].
Now the equality sign is not to be understand as an equality sign in the common sense, but rather as [tex]f(n) \in O(n)[/tex], see Big Oh Fallacies and Pitfalls and
the Wikipedia article.

( [itex]5 \cdot n = O(n)[/itex] and [itex]2 \cdot n = O(n)[/itex], but [itex] 5 \cdot n \neq 2 \cdot n[/itex])

So it would be better to think of [tex]O(n)[/tex] as a set of functions.

My question:
Does anyone know why it became common to use the notation f(n)=O(g(n))?
I remember my professor mentioning that physicists introduced this sloppy notation.
 
Last edited:
Physics news on Phys.org
  • #2
Yes usually I use ~ notation. But I have no idea why anyone introduced that notation, I HATE it.
 
  • #3
Well, Landau was a physicist, but I didn't know it was him who introduced the notation.

Certainly, if we write [itex]f(x)=O(g(x))[/itex], we mean that f belongs to the class of function for which there exists a C with [tex]f(x) \leq C \cdot g(x)[/tex] for some x_0 onward. So yes, IMHO, writing [itex]f(x)\in O(g(x))[/itex] would be more accurate, but it would not make sense to write things like

[tex]f(x)=\sum_{k=0}^{n-1}\frac{f^{(k)}(0)}{k!}x^k+O(x^n)[/tex]

We would have to write

[tex]f(x)=\sum_{k=0}^{n-1}\frac{f^{(k)}(0)}{k!}x^k+g(x) \ \ \ \ \ \ \ \mbox{where} \ g(x)\in O(x^n)[/tex]

There is no ambiguity in the first formula. It reads "f(x)=sum plus some function for which there exists a C with [tex]f(x) \leq C \cdot g(x)[/tex] for some x_0 onward". In the second, we gain in rigor but loose a little bit of gut feeling for the equation. Personally, I'm fine with the original notation.
 
Last edited:
  • #4
I write, for example:

[tex] O( ln(n^2)) = O(ln (n)) [/tex]

and I never thought to write:

[tex] ln( n^2) = O(ln(n)) [/tex]

I liked quasar's post, and I agree with the conclusion that the gain in rigor is not worth the extra effort. Compare with the hyper-common:

"A topological space is a pair [tex] (X,\tau) [/tex] satisfying...

...now let [tex] X [/tex] be a topological space..."
 
  • #5
Crosson said:
I write, for example:


"A topological space is a pair [tex] (X,\tau) [/tex] satisfying...

...now let [tex] X [/tex] be a topological space..."

Well, there's nothing wrong with that quite yet! :wink:
 
  • #6
Well, is this overload of the equality sign any more grievous than the programmers' assignment operation i=i+1?
 

1. What is Big Oh notation?

Big Oh notation, also known as Landau symbols, is a mathematical notation used to describe the worst-case time complexity of an algorithm or function. It describes the rate at which the algorithm's execution time increases as the input size grows.

2. How is Big Oh notation calculated?

The Big Oh notation is calculated by analyzing the number of operations performed by an algorithm in terms of the input size. It disregards constant factors and lower-order terms, only focusing on the dominant term that determines the overall growth rate.

3. What is the significance of Big Oh notation?

Big Oh notation is significant because it allows us to compare and analyze the efficiency of different algorithms and determine which one is the most time-efficient. It also helps us make informed decisions about which algorithm to use for a specific problem based on its input size.

4. What are the different types of Big Oh notation?

The different types of Big Oh notation are O(1), O(log n), O(n), O(n log n), O(n^2), O(n^c), O(c^n), and O(n!). These notations represent different growth rates, with O(1) being the most time-efficient and O(n!) being the least time-efficient.

5. How does Big Oh notation relate to the performance of an algorithm?

Big Oh notation provides a theoretical upper bound on the worst-case time complexity of an algorithm. It helps us understand the relationship between the input size and the algorithm's execution time, and allows us to predict the performance of an algorithm for larger input sizes.

Similar threads

Replies
1
Views
908
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Calculus and Beyond Homework Help
Replies
3
Views
540
  • Calculus and Beyond Homework Help
Replies
7
Views
702
Replies
1
Views
2K
  • Linear and Abstract Algebra
Replies
23
Views
1K
Back
Top