# Thread: Bachman-Landau notation and functions

1. ## Bachman-Landau notation and functions

I have a question, about Bachman-Landau. How do you know when a function fits into some notation?
For example does $\displaystyle x^2-6x+25$ fit into $\displaystyle O(x^2)$.

Or you just look and see, we had some equations in school but I cant' remember them all.

2. ## Re: Bachman-Landau notation and functions

Originally Posted by Nforce
I have a question, about Bachman-Landau. How do you know when a function fits into some notation?
For example does $\displaystyle x^2-6x+25$ fit into $\displaystyle O(x^2)$.
For polynomials, the answer is determined by their degrees. More precisely, f(x) is O(g(x)) iff deg(f(x)) ≤ deg(g(x)). For example, x² - 6x + 25 ≤ x² + 25 ≤ 2x² for x ≥ 5, so x² - 6x + 25 is O(x²).

3. ## Re: Bachman-Landau notation and functions

Ok, I understand the degree of polynomial. But how did you get this expression:

Originally Posted by emakarov
≤ x² + 25 ≤ 2x² for x ≥ 5, so x² - 6x + 25 is O(x²).
And what means "for x ≥ 5"

4. ## Re: Bachman-Landau notation and functions

I mean that for every x, if x ≥ 5, then x² ≥ 25. Therefore, if x ≥ 5, then x² - 6x + 25 ≤ x² + 25 ≤ x² + x² = 2x².

5. ## Re: Bachman-Landau notation and functions

Sorry but I still dont' understand, how did you get that $\displaystyle x^2 + 25$, and then $\displaystyle x^2 + x^2$. From where?

6. ## Re: Bachman-Landau notation and functions

From where I got x² + 25 and x² + x² is a separate question from whether these inequalities are true. You don't have to understand why I chose these specific expressions, but you do have to understand that if you subtract 6x from x² + 25, where x >= 5 and therefore 6x is nonnegative, then you get a smaller value than x² + 25. Therefore, x² - 6x + 25 ≤ x² + 25. Further, you have to understand that x² ≥ 25 for x ≥ 5. Therefore, if you replace 25 with a bigger value x² in x² + 25, you get a bigger result. So, x² + 25 ≤ 2x².

7. ## Re: Bachman-Landau notation and functions

Hmm, ok now I understand the ineqaulities, but why did you choose those terms? At every single expression there is one less term. So the purpose is to rewrite the function into inequalities.

At your first answer you said if deg(f()) ≤ deg(g()) is true, then the polynomial fits into O(x²), so 2 ≤ 2 is true, therefore it fits.

This is how I understand this.

8. ## Re: Bachman-Landau notation and functions

Originally Posted by Nforce
Hmm, ok now I understand the ineqaulities, but why did you choose those terms? At every single expression there is one less term.
You are right. The definition of big-O says that we must show that for some constants $\displaystyle C$ and $\displaystyle x_0$, it is the case that $\displaystyle x^2 - 6x + 25\le Cx^2$ for all $\displaystyle x>x_0$. Therefore, the goal is to prove $\displaystyle x^2 - 6x + 25\le Cx^2$ for some coefficient $\displaystyle C$. One approach is to bound from above every term in the left-hand side by $\displaystyle cx^2$ for some $\displaystyle c$. Then you add them all together and obtain that the left-hand side is bounded from above by $\displaystyle (c+c'+\dots)x^2=Cx^2$.

In this example, $\displaystyle x^2\le1\cdot x^2$; $\displaystyle -6x\le 0\cdot x^2$ for $\displaystyle x\ge0$ and $\displaystyle 25\le1\cdot x^2$ for $\displaystyle x\ge5$. Adding these inequalities, we get $\displaystyle x^2-6x+25\le(1+0+1)x^2$. This holds when $\displaystyle x\ge0$ and $\displaystyle x\ge5$, i.e., when $\displaystyle x\ge5$. Therefore, we can take $\displaystyle C = 2$ and $\displaystyle x_0=5$ and we get, as the definition of big-O demands, that $\displaystyle x^2 - 6x + 25\le Cx^2$ for all $\displaystyle x>x_0$. We could also say that $\displaystyle 25\le25\cdot x^2$ for $\displaystyle x\ge1$. Then $\displaystyle x^2-6x+25\le(1+0+25)x^2=26x^2$ for $\displaystyle x\ge1$. There is some trade-off here: we got a smaller $\displaystyle x_0$ (1 instead of 5) but a significantly larger $\displaystyle C$ (26 instead of 2). If the polynomial were $\displaystyle x^2 + 6x + 25$ instead of $\displaystyle x^2 - 6x + 25$, then, since $\displaystyle 6x\le 1\cdot x^2$ for $\displaystyle x\ge 6$ and $\displaystyle 25\le x^2$ for $\displaystyle x\ge 5$, we could say that $\displaystyle x^2 + 6x + 25\le 3x^2$ for $\displaystyle x\ge 6$. Alternatively, since $\displaystyle 6x\le 6x^2$ and $\displaystyle 25\le 25x^2$ for $\displaystyle x\ge 1$, we have $\displaystyle x^2 + 6x + 25\le (1+6+25)x^2=32x^2$ for $\displaystyle x\ge 1$.

Still another way to prove $\displaystyle x^2 - 6x + 25$ is $\displaystyle O(x^2)$ is to plot the graphs of the two functions and to note that $\displaystyle x^2$ eventually dominates $\displaystyle x^2 - 6x + 25$. (If it did not, then we should plot $\displaystyle 2x^2$, $\displaystyle 3x^2$, etc. until it dominates the left-hand side). Then we can solve $\displaystyle x^2 - 6x + 25\le x^2$ to get $\displaystyle x\ge 25/6$. Thus, we can take $\displaystyle C = 1$ and $\displaystyle x_0=25/6$.

Originally Posted by Nforce
At your first answer you said if deg(f()) ≤ deg(g()) is true, then the polynomial fits into O(x²), so 2 ≤ 2 is true, therefore it fits.
This is correct, but this is a general theorem, and I am not sure you can provide the proof (though it is basically a generalization of the reasoning above). Whether this is sufficient depends on your course. It is possible that you need a way to show that $\displaystyle x^2 - 6x + 25$ is $\displaystyle O(x^2)$ that you can fully justify.

Here by "$\displaystyle f(x)$ eventually dominates $\displaystyle g(x)$" I mean that $\displaystyle f(x)\ge g(x)$ "eventually," i.e., for all $\displaystyle x$ starting from some point $\displaystyle x_0$. That is, if $\displaystyle g'(x)$ is $\displaystyle O(f'(x))$, then there exists a constant $\displaystyle C > 0$ such that $\displaystyle Cf'(x)$ dominates $\displaystyle g'(x)$ (assuming that $\displaystyle f'(x)$ and $\displaystyle g'(x)$ are nonnegative). But, as far as I know, "dominates" does not have a universally accepted precise meaning in mathematics.