I am carrying on war with Landau notation during the whole math study I have. We used that in different variations for many traditional purposes including algorithm runtimes.
But I still cannot get clear with this notation, and cannot answer questions like "Is this function a big O from another function?", "Is that true that being a small o implies a function to be a big O of another function?", "What complexity has this certain algorithm?", etc.
Every time I meet such questions I normally land on reading definitions on Wikipedia and scarce descriptions in the books I've read. And, I have no idea how to use these definitions for the answers I have to give. Also, in all the exercises where I have to found such O-s or prove if one function is an o of another I just do not know where to start and if my solutions are correct.
Do you know, or, could you advice me some certain material, so that I can get clear with these O-s for all times? I would need all the theory necessary for the notation, accompanied with exercises. After completing the exercises I want to be sure that my solutions are correct and I come clear with the usage.
Thank you.
Edit for Jose Brox:
Well, the confusion comes from not knowing how to use the definitions and can be a subject of a separate question.
Example 1: find functions $g$ and $h$ such that $f(x) = o(g(x))$ and $f(x) = O(h(x))$ for $x \to -\infty, f(x) = \frac{x^3 + x + 12}{x-4}$.
Step 1: question. When should I write $\in$, when $=$?
Step 2: Why we write $=$, if we mean $\in$?
Step 3: What should I write and when?
Step 4: definitions.
- If $f = O(g)$ is defined as $\limsup_{x \to a} \left\vert \frac{f(x)}{g(x)}\right\vert < \infty$, then I have to find a function $h$, such that $\displaystyle \limsup_{x \to - \infty}\left\vert \frac{x^3 + x + 12}{(x-4) \cdot h(x)}\right\vert <\infty. $
Step 4.1.1 Why an absolute value?
Step 4.1.2 The limit should exist and be finite. Why $\limsup$? What is the difference to $\lim$? Why not $\liminf$?
Step 4.1.3 Solution. Take 1. I have a function $fh(x) = \left\vert \frac{x^3 + x + 12}{(x-4) \cdot h(x)}\right\vert$ and have to find a sequence $(x_n)$ such that $fh((x)_n) \to y < \infty$ for $x \to -\infty$. Not sure I am right already. We used to use limes superior for sequences, I am not sure how to use this here. I have to find some $h$, such that $\limsup$ of the absolute value of some fraction that we used for sequences is finite. BrainOverHeatException, Compiler Error, System.exit(1).
Step 4.1.4 Solution. Take 2. Let's keep it simple. Let us pick just random $h$ and look what happens. $h = x^3$ looks good. Solution found. Have a learnt something? Nope, pure luck. What shall I do, if the solution will be not as obvious? No idea.
Step 4.1.5 Conclusion. No idea how it works and what the definition means. Ask me if there is a function that bounds $f$ better, I will stare at $\limsup_{x \to a} \left\vert \frac{f(x)}{g(x)}\right\vert < \infty$ and do not know what to say.
- If $f(x) = O(g)$ means $\exists C>0 \ \exists x_0 > 0 \ \forall x> x_0: \vert(f(x)\vert \le C \cdot \vert g(x)\vert$. Ok, I have to some $h$ such that $\exists C>0 \ \exists x_0 > 0 \ \forall x> x_0: \vert\frac{x^3 + x + 12}{x-4}\vert \le C \cdot \vert h(x)\vert.$
Step 4.2.1 I have to find a $h$ such that there exists a $C$. What?!
LogicOutOfBoundException, Compiler Error, System.exit(1).
Step 4.2.2 Ok, let's play an old game. For a random $h$ check if there is such a $C$. Hm, I thought I have to found $h$, not pick it up random. Ok, but then how can I tell if there is a $C$, if I do not know $h$?
terminated
Step 4.2.3 I have no idea if there is a $C$ or not. Even if there is, I have no idea if there is a $x_0$ in dependence of $C$. I have no definite answer how one should try to answer on existence question. Maybe there is justice in the world, but it depends on $h$ that I have to find...
Without describing further attempts I can just say - I have no idea how to use this series of quantifiers to solve my exercise. And, I see no certain way how to combine them.
In many kind cases definitions really define something. You read them, you understand what we talking about: is this here a normed space? Well, let's check the conditions. If "this here" satisfy all the conditions, it is a normed space.
In the case of Landau notation definitions usually starts with "We say the $f$ is a big O of $g$...". So we are really about saying something but mean something totally complete different.
Returning to the question you've asked: what is my confusion about these definitions? I do not understand them, I do not understand what they define, and I do not understand how to use them even for this certain exercise I've written here. For me at my grade the two definitions seem to be two different approaches to define something. Some people use quantifiers, some the limits. But I do not understand how they do that and what they mean.
Example 2 was actually thought to be an example, where I have to determine the complexity of some algorithm. That would be (in steps): 1) estimating the amount of steps, 2) approximating it with some "O". I have no idea how to find such O either. I would usually go back to definitions and start from the step 4 the analogous game...
All in all, the "O"-question becomes for me a non-NP problem, where I just waste time for finding a solution. There are many interesting things to do in math. Instead, I continue my war against some notations invented by somebody else long time ago.
...