Big Oh is a mathematical expression meant to describe the behaviour of a function as its parameter tends to a certain value or infinity. This is done, usually, by expressing the function in a simpler function. In mathematical form, it takes the following shape:
f(x) ∈ O(g(x))
The full definition would be the following:
∃ c ∈ ℝ⁺, ∃ B ∈ ℕ, ∀ n ∈ ℕ, n ≥ B ⇒ f(x) ≤ c(g(x))
Relating this to everything we have learnt before, we need to use proofs to establish whether the left side of the inequality is equal to the right side of the inequality. To go from left to right, we need to be very, very creative.
Let's work with the following example:
n^4 - 5n^2 + 1 ∈ O(6n^5 - 5n^3 + 3n)
Then this would be equal to:
∃ c ∈ ℝ⁺, ∃ B ∈ ℕ, ∀ n ∈ ℕ, n ≥ B ⇒ n^4 - 5n^2 + 1 ≤ c(6n^5 - 5n^3 + 3n)
First, we should work on the inequality
n^4 - 5n^2 + 1 ≤ n^4 + 1 #we remove - 5n^2 to start off the inequality
≤ n^4 + n^4 #since n^4 ≥ 1, this inequality would still be true
≤ 2n^4 #addition
≤ n∙n^4 #since we have 2 as a coefficient, we could make B = 2 so that n ≥ 2
≤ n^5 #multiplication
≤ 6n^5 - 5n^5 #still n^5
≤ 6n^5 - 5n^3 #since - n^5 ≤ - n^3 this is still true
≤ 6n^5 - 5n^3 + 3n #adding 3n, this is still true
≤ 1(6n^5 - 5n^3 + 3n) #we could make c = 1
We have established values for both c and B, so that c = 1 and B = 2. In order to work the proof, we would have to do the following arrangement:
n^4 - 5n^2 + 1 ∈ O(6n^5 - 5n^3 + 3n)
∃ c ∈ ℝ⁺, ∃ B ∈ ℕ, ∀ n ∈ ℕ, n ≥ B ⇒ n^4 - 5n^2 + 1 ≤ c(6n^5 - 5n^3 + 3n)
Assume n ∈ ℕ and n ≥ 2 #domain assumption and antecedent
Then n^4 - 5n^2 + 1 ≤ n^4 + 1 #add 5n^2
≤ n^4 + n^4 #since n^4 ≥ 1
≤ 2n^4 #add both together
≤ n∙n^4 #since n ≥ 2
≤ n^5 #multiply both together
≤ 6n^5 - 5n^5
≤ 6n^5 - 5n^3 #since - n^5 ≤ - n^3
≤ 6n^5 - 5n^3 + 3n #add 3n
Then ∀ n ∈ ℕ, n ≥ 2 ⇒ n^4 - 5n^2 + 1 ≤ c(6n^5 - 5n^3 + 3n) #introduce ⇒
Then n^4 - 5n^2 + 1 ∈ O(6n^5 - 5n^3 + 3n) #introduce Big Oh
Done!