1.1 - Upper Bounds
π± O ( g ) O(g) O ( g ) is the set of all functions that (1) have (exist) constants c , n 0 > 0 c, n_0 > 0 c , n 0 β > 0 that is greater than or equal to f ( n ) f(n) f ( n ) for all n β₯ n 0 n \ge n_0 n β₯ n 0 β .
O ( g ) = { f β£ β c , n 0 > 0 β β n β₯ n 0 β 0 β€ f ( n ) β€ c β
g ( n ) }
O(g)=\{f | \exists c, n_0\gt 0 \bullet \forall n\ge n_0 \bullet 0 \le f(n) \le c\cdot g(n) \}
O ( g ) = { f β£β c , n 0 β > 0 β β n β₯ n 0 β β 0 β€ f ( n ) β€ c β
g ( n )}
That is, the set of functions (where c , n 0 > 0 c, n_0>0 c , n 0 β > 0 ) exist and for all values of n β₯ n 0 n\ge n_0 n β₯ n 0 β , the function f ( n ) f(n) f ( n ) is bounded above by c β
g ( n ) c\cdot g(n) c β
g ( n ) .
Using the formal definition above, prove that 2 n 3 β O ( n 3 ) 2n^3\in O(n^3) 2 n 3 β O ( n 3 )
To do this, we need to find constants c , n 0 > 0 c,n_0 > 0 c , n 0 β > 0 such that ( β n β₯ n 0 β 0 β€ 2 n 3 β€ c n 3 ) (\forall n \ge n_0 \bullet 0 \le2n^3\le cn^3) ( β n β₯ n 0 β β 0 β€ 2 n 3 β€ c n 3 )
Choosing c = 2 c=2 c = 2 and n 0 = 1 n_0=1 n 0 β = 1 will suffice since
β n β₯ 1 β 0 β€ 2 n 3 β€ 2 n 3 β‘ Β true
\begin{aligned}&\forall n\ge1 \bullet 0 \le2n^3\le 2n^3\\
\equiv &\text{ true}
\end{aligned}
β‘ β β n β₯ 1 β 0 β€ 2 n 3 β€ 2 n 3 Β true β
Using the formal definition above, prove that 2 n 2 β O ( n 3 β n 2 ) 2n^2 \in O(n^3-n^2) 2 n 2 β O ( n 3 β n 2 )
To do this, we need to find constants c , n 0 > 0 c,n_0 > 0 c , n 0 β > 0 such that ( β n β₯ n 0 β 0 β€ 2 n 3 β€ c n 3 ) (\forall n \ge n_0 \bullet 0 \le2n^3\le cn^3) ( β n β₯ n 0 β β 0 β€ 2 n 3 β€ c n 3 )
Trivially, we know that:
0 β€ 2 n 2 β‘ Β trueΒ Β Β Β Β Β Β Β Β Β Β Β Β Β ifΒ n β₯ 0
\begin{aligned}
&0\le 2n^2\\
\equiv & \text{ true}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \text{if } n \ge 0
\end{aligned}
β‘ β 0 β€ 2 n 2 Β true Β Β Β Β Β Β Β Β Β Β Β Β Β Β ifΒ n β₯ 0 β
Additionally, we have:
2 n 2 β€ c ( n 3 β n 2 ) β‘ Β 2 β€ c ( n β 1 ) Β Β Β Β Β Β Β Β ifΒ n > 0 , b y ( Γ· n 2 ) β‘ Β 2 + c β€ c n β‘ Β 2 + 2 β€ 2 n Β Β Β Β Β Β Β Β Β Β Β ifΒ c = 2 β‘ Β 2 β€ n
\begin{aligned}
&2n^2\le c(n^3-n^2)\\
\equiv\ &2\le c(n-1)\ \ \ \ \ \ \ \ \text{if } n > 0, by (\div n^2)\\
\equiv\ &2+c\le cn\\
\equiv\ &2+2\le 2n\ \ \ \ \ \ \ \ \ \ \ \text{if } c=2\\
\equiv\ &2 \le n
\end{aligned}
β‘ Β β‘ Β β‘ Β β‘ Β β 2 n 2 β€ c ( n 3 β n 2 ) 2 β€ c ( n β 1 ) Β Β Β Β Β Β Β Β ifΒ n > 0 , b y ( Γ· n 2 ) 2 + c β€ c n 2 + 2 β€ 2 n Β Β Β Β Β Β Β Β Β Β Β ifΒ c = 2 2 β€ n β
Therefore, c = 2 c=2 c = 2 and n 0 = 2 n_0=2 n 0 β = 2 will therefore suffice.
1.2 - Lower Bounds
π± Ξ© ( g ) \Omega(g) Ξ© ( g ) is the set of all functions that (1) have (exist) constants c , n 0 > 0 c, n_0 > 0 c , n 0 β > 0 that is less than or equal to c β
g ( n ) c\cdot g(n) c β
g ( n ) for all n β₯ n 0 n \ge n_0 n β₯ n 0 β .
Ξ© ( g ) = { f β£ β c , n 0 > 0 β β n β₯ n 0 β , 0 β€ c β
g ( n ) β€ f ( n ) }
\Omega(g)=\{f|\exists c, n_0> 0\bullet \forall n\ge n_0 \bullet, 0 \le c\cdot g(n)\le f(n) \}
Ξ© ( g ) = { f β£β c , n 0 β > 0 β β n β₯ n 0 β β , 0 β€ c β
g ( n ) β€ f ( n )}
Using the above definition, prove that 2 n 3 β Ξ© ( n 3 ) 2n^3\in \Omega(n^3) 2 n 3 β Ξ© ( n 3 )
We need to find constants c , n 0 > 0 c, n_0>0 c , n 0 β > 0 such that ( β n β₯ n 0 β 0 β€ c n 3 β€ 2 n 3 ) (\forall n \ge n_0\bullet 0\le cn^3\le2n^3) ( β n β₯ n 0 β β 0 β€ c n 3 β€ 2 n 3 )
Choosing c = 2 c=2 c = 2 and n 0 n_0 n 0 β will suffice, since:
β n β₯ 1 β 0 β€ 2 n 3 β€ 2 n 3 β‘ Β true
\begin{aligned}
&\forall n \ge1\bullet 0 \le 2n^3\le 2n^3\\
\equiv\ &\text{true}
\end{aligned}
β‘ Β β β n β₯ 1 β 0 β€ 2 n 3 β€ 2 n 3 true β
1.3 - Tight Bounds
π± Ξ ( g ) \Theta(g) Ξ ( g ) is the set of all functions that (1) have (exist) constants c 1 , c 2 , n 0 > 0 c_1, c_2, n_0>0 c 1 β , c 2 β , n 0 β > 0 that bounds the function f ( n ) f(n) f ( n ) on the top and bottom to within a constant factor.
Ξ ( g ) = { f β£ β c 1 , c 2 , n 0 > 0 β β n β₯ n 0 β 0 β€ c 1 β
g ( n ) β€ f ( n ) β€ c 2 β
g ( n ) }
\Theta(g)=\{f | \exists c_1, c_2, n_0 > 0\bullet \forall n\ge n_0 \bullet 0\le c_1\cdot g(n) \le f(n)\le c_2\cdot g(n)\}
Ξ ( g ) = { f β£β c 1 β , c 2 β , n 0 β > 0 β β n β₯ n 0 β β 0 β€ c 1 β β
g ( n ) β€ f ( n ) β€ c 2 β β
g ( n )}
Using the above definition, prove that 2 n 3 β Ξ ( n 3 ) 2n^3\in\Theta (n^3) 2 n 3 β Ξ ( n 3 )
We need to find constants c 1 , c 2 , n 0 > 0 c_1, c_2, n_0>0 c 1 β , c 2 β , n 0 β > 0 such that ( β n β₯ n 0 , β 0 β€ c 1 n 3 β€ 2 n 3 β€ c 2 n 3 ) (\forall n\ge n_0, \bullet 0 \le c_1n^3\le2n^3\le c_2n^3) ( β n β₯ n 0 β , β 0 β€ c 1 β n 3 β€ 2 n 3 β€ c 2 β n 3 )
Choosing c 1 = c 2 = 2 c_1=c_2=2 c 1 β = c 2 β = 2 and n 0 = 1 n_0=1 n 0 β = 1 will suffice since:
β n β₯ 1 β 0 β€ 2 n 3 β€ 2 n 3 β€ 2 n 3 β‘ Β true
\begin{aligned}
&\forall n\ge 1 \bullet 0 \le 2n^3\le 2n^3 \le 2n^3\\
\equiv\ &\text{true}
\end{aligned}
β‘ Β β β n β₯ 1 β 0 β€ 2 n 3 β€ 2 n 3 β€ 2 n 3 true β
Using the above definition, prove that n 2 2 β Ξ ( n 2 ) \frac{n^2}2\in\Theta(n^2) 2 n 2 β β Ξ ( n 2 )
We need to find constants c 1 , c 2 , n 0 > 0 c_1,c_2,n_0>0 c 1 β , c 2 β , n 0 β > 0 such that
( β n β₯ n 0 β 0 β€ c 1 n 2 β€ n 2 2 ) β 2 β€ c 2 n 2
(\forall n\ge n_0\bullet 0\le c_1 n^2 \le\frac{n^2}2)-2\le c_2n^2
( β n β₯ n 0 β β 0 β€ c 1 β n 2 β€ 2 n 2 β ) β 2 β€ c 2 β n 2
Trivially, we know that:
0 β€ c 1 n 2 β‘ Β trueΒ ifΒ n β₯ 0
\begin{aligned}
&0\le c_1 n^2\\
\equiv\ &\text{true if } n \ge 0
\end{aligned}
β‘ Β β 0 β€ c 1 β n 2 trueΒ ifΒ n β₯ 0 β
Additionally:
c 1 n 2 β€ n 2 2 β 2 n β‘ Β 2 β€ n ( 1 2 β c 1 ) Β Β Β Β ifΒ n > 0 β‘ Β 8 β€ n Β Β Β Β ifΒ c 1 = 4
\begin{aligned}
&c_1 n^2\le \frac{n^2}2 -2n\\
\equiv\ &2\le n(\frac12 - c_1) \ \ \ \ \text{if } n>0\\
\equiv\ & 8\le n \ \ \ \ \text{if } c_1=4\\
\end{aligned}
β‘ Β β‘ Β β c 1 β n 2 β€ 2 n 2 β β 2 n 2 β€ n ( 2 1 β β c 1 β ) Β Β Β Β ifΒ n > 0 8 β€ n Β Β Β Β ifΒ c 1 β = 4 β
Finally:
n 2 2 β 2 n β€ c 2 n 2 β‘ Β trueΒ Β Β Β Β Β Β Β Β Β Β ifΒ n β₯ 0 Β andΒ c 2 β€ 1 2
\begin{aligned}
&\frac{n^2}{2}-2n\le c_2n^2\\
\equiv\ &\text{true\ \ \ \ \ \ \ \ \ \ \ if }n\ge0 \text{ and } c_2\le\frac12
\end{aligned}
β‘ Β β 2 n 2 β β 2 n β€ c 2 β n 2 trueΒ Β Β Β Β Β Β Β Β Β Β ifΒ n β₯ 0 Β andΒ c 2 β β€ 2 1 β β
Therefore, choosing c 1 = 1 4 , c 2 = 1 2 c_1=\frac14, c_2=\frac12 c 1 β = 4 1 β , c 2 β = 2 1 β and n 0 = 8 n_0=8 n 0 β = 8 will therefore suffice
Using the above definition, prove that n 2 2 β 2 n β Ξ ( n 2 ) \frac{n^2}2 -2n\in \Theta(n^2) 2 n 2 β β 2 n β Ξ ( n 2 )
We need to find constants c 1 , c 2 , n 0 > 0 c_1, c_2, n_0>0 c 1 β , c 2 β , n 0 β > 0 such that:
( β n β₯ n 0 , 0 β€ c 1 n 2 β€ n 2 2 β 2 n β€ c 2 n 2 )
(\forall n\ge n_0, 0 \le c_1 n^2 \le \frac{n^2}2-2n\le c_2 n^2)
( β n β₯ n 0 β , 0 β€ c 1 β n 2 β€ 2 n 2 β β 2 n β€ c 2 β n 2 )
Firstly, we know that 0 β€ c 1 n 2 0 \le c_1 n^2 0 β€ c 1 β n 2 is true for all n β₯ 0 n \ge 0 n β₯ 0
Additionally, we prove that:
c 1 n 2 β€ n 2 2 β 2 n β‘ Β 2 β€ n ( 1 2 β c 1 ) Β Β Β Β Β ifΒ n > 0 β‘ Β 8 β€ n Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ifΒ c 1 = 1 4
\begin{aligned}
&c_1 n^2\le \frac{n^2}{2}-2n\\
\equiv\ &2\le n(\frac 12-c_1) \ \ \ \ \ \text{if } n > 0\\
\equiv\ & 8 \le n \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \text{if } c_1 =\frac14\\
\end{aligned}
β‘ Β β‘ Β β c 1 β n 2 β€ 2 n 2 β β 2 n 2 β€ n ( 2 1 β β c 1 β ) Β Β Β Β Β ifΒ n > 0 8 β€ n Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ifΒ c 1 β = 4 1 β β
Finally, we prove that:
n 2 2 β 2 n β€ c 2 n 2 β‘ Β trueΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ifΒ n β₯ 0 Β andΒ c 2 β₯ 1 2
\begin{aligned}
&\frac{n^2}2-2n\le c_2 n^2\\
\equiv\ &\text{true}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \text{if } n \ge 0 \text{ and } c_2\ge \frac12
\end{aligned}
β‘ Β β 2 n 2 β β 2 n β€ c 2 β n 2 true Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β ifΒ n β₯ 0 Β andΒ c 2 β β₯ 2 1 β β
Therefore, choosing c 1 = 1 4 , c 2 = 1 2 c_1=\frac14, c_2=\frac12 c 1 β = 4 1 β , c 2 β = 2 1 β and n 0 = 8 n_0=8 n 0 β = 8 will therefore suffice
1.4 - Properties of Asymptotic Notation
π± Theorem:
f β O ( g ) βΉ g + f β Ξ ( g ) f\in O(g)\Longrightarrow g+f\in \Theta(g) f β O ( g ) βΉ g + f β Ξ ( g )
For example, n β O ( n 2 ) βΉ n 2 + n β Ξ ( n 2 ) n\in O(n^2)\Longrightarrow n^2+n\in\Theta(n^2) n β O ( n 2 ) βΉ n 2 + n β Ξ ( n 2 )
π± Theorem: For k > 0 k>0 k > 0
k β
n a β Ξ ( n a ) k\cdot n^a\in \Theta(n^a) k β
n a β Ξ ( n a )
π± Theorem: For k > 0 k>0 k > 0 and 0 β€ a β€ b 0\le a\le b 0 β€ a β€ b
k β
n a β O ( n b ) k\cdot n^a\in O(n^b) k β
n a β O ( n b )
π± Theorem: For any functions f f f and g g g
f β O ( g ) βΊ g β Ξ© ( f ) f\in O(g)\Longleftrightarrow g\in\Omega(f) f β O ( g ) βΊ g β Ξ© ( f )
π± Theorem: For any functions f f f and g g g
f β Ξ ( g ) βΊ f β O ( g ) β§ f β Ξ© ( g ) f\in\Theta(g)\Longleftrightarrow f\in O(g)\wedge f\in\Omega (g) f β Ξ ( g ) βΊ f β O ( g ) β§ f β Ξ© ( g )
2.0 - Comparing Functions
π± A function f f f is asymptotically non-negative if:
β n 0 β ( β n β₯ n 0 β f ( n ) β₯ 0 ) \exists n_0\bullet (\forall n \ge n_0 \bullet f(n)\ge 0) β n 0 β β ( β n β₯ n 0 β β f ( n ) β₯ 0 )
π± If f f f and g g g are asymptotically non-negative functions, and
lim β‘ n β β f ( n ) g ( n ) = c β₯ 0 Β thenΒ f β O ( g ) = c > 0 Β thenΒ f β Ξ ( g ) = β Β thenΒ g β O ( f ) \begin{aligned} \lim_{n\rightarrow\infty} \frac{f(n)}{g(n)}&=c\ge0 \text{ then } f\in O(g)\\ &=c>0 \text{ then } f\in\Theta(g)\\ &=\infty\text{ then } g\in O(f) \end{aligned} n β β lim β g ( n ) f ( n ) β β = c β₯ 0 Β thenΒ f β O ( g ) = c > 0 Β thenΒ f β Ξ ( g ) = β Β thenΒ g β O ( f ) β
where c c c is a real-valued constant
However, we cannot compare all functions using the asymptotic notation technique.
For example, the following functions cannot be compared using asymptotic notation
n Β andΒ n 1 + sin β‘ n n \text{ and } n^{1+\sin n} n Β andΒ n 1 + s i n n
Plot of f ( n ) = n f(n)=n f ( n ) = n (red) and g ( n ) = n 1 + sin β‘ n g(n)=n^ {1+\sin n} g ( n ) = n 1 + s i n n
3.0 - Polynomials
p ( n ) = β k = 0 d a k n k = a 0 n 0 + a 1 n 1 + β― + a d n d
p(n)=\sum^d_{k=0} a_k n^k=a_0n^0+a_1n^1+\cdots+a_dn^d
p ( n ) = k = 0 β d β a k β n k = a 0 β n 0 + a 1 β n 1 + β― + a d β n d
π± Theorem: If a d > 0 a_d>0 a d β > 0 ,
p ( n ) β Ξ ( n d ) p(n)\in\Theta(n^d) p ( n ) β Ξ ( n d )
lim β‘ n β β p ( n ) n d = lim β‘ n β β β k = 0 d a k n k n d = lim β‘ n β β a d n d n d + β k = 0 d β 1 a k n k n d = lim β‘ n β β a d + β k = 0 d β 1 a k n d β k = a d
\small\begin{aligned}
&\lim_{n\rightarrow\infty} \frac{p(n)}{n^d}\\
=& \lim_{n\rightarrow\infty} \sum^d_{k=0} \frac{a_k n^k}{n_d}\\
=& \lim_{n\rightarrow\infty} \frac{a_dn^d}{n^d} + \sum^{d-1}_{k=0} \frac{a_k n^k}{n^d}\\
=& \lim_{n\rightarrow\infty} a_d + \sum^{d-1}_{k=0}\frac{a_k}{n^{d-k}}\\
=& a_d
\end{aligned}
= = = = β n β β lim β n d p ( n ) β n β β lim β k = 0 β d β n d β a k β n k β n β β lim β n d a d β n d β + k = 0 β d β 1 β n d a k β n k β n β β lim β a d β + k = 0 β d β 1 β n d β k a k β β a d β β
Since the limit gives a d a_d a d β , which the theorem assumes is greater than zero, we know that p ( n ) β Ξ ( n d ) p(n)\in \Theta(n^d) p ( n ) β Ξ ( n d )
Additionally,
π± For a > 1 a>1 a > 1 and n β₯ 0 , n\ge0, n β₯ 0 ,
n d β O ( a n ) {\color{lightblue}n^d}\in O({\color{lightgreen}a^n}) n d β O ( a n )
lim β‘ n β β n d a d lim β‘ n β β d n d β 1 a n ln β‘ a lim β‘ n β β d ( d β 1 ) n d β 2 a n ( ln β‘ a ) 2 Β Β Β Β Β Β Β Β Β Β Β ByΒ LβHopitalβs lim β‘ n β β d ( d β 1 ) ( d β 2 ) β― 1 n 0 a n ( ln β‘ a ) d lim β‘ n β β d ! a n ( ln β‘ a ) d
\begin{aligned}
&\lim_{n\rightarrow\infty} \frac{\color{lightblue}n^d}{\color{lightgreen}a^d}\\
&\lim_{n\rightarrow\infty} \frac{dn^{d-1}}{a^n \ln a}\\
&\lim_{n\rightarrow\infty} \frac{d(d-1)n^{d-2}}{a^n(\ln a)^2} \ \ \ \ \ \ \ \ \ \ \ \text{By L'Hopital's}\\
&\lim_{n\rightarrow\infty} \frac{d(d-1)(d-2)\cdots 1 n^0}{a^n(\ln a)^d}\\
&\lim_{n\rightarrow\infty} \frac{d!}{a^n (\ln a)^d}
\end{aligned}
β n β β lim β a d n d β n β β lim β a n ln a d n d β 1 β n β β lim β a n ( ln a ) 2 d ( d β 1 ) n d β 2 β Β Β Β Β Β Β Β Β Β Β Β ByΒ LβHopitalβs n β β lim β a n ( ln a ) d d ( d β 1 ) ( d β 2 ) β― 1 n 0 β n β β lim β a n ( ln a ) d d ! β β
As d ! d! d ! and ( ln β‘ a ) d (\ln a)^d ( ln a ) d are constants, and a n β β a^n\rightarrow\infty a n β β , the limit is 0. Therefore, this has a tight-o bound.
4.0 - Mathematical Background
4.1 - Finite Summations
π± Given a sequence β¨ a 1 , a 2 , β― β , a n β© \langle a_1, a_2, \cdots, a_n\rangle β¨ a 1 β , a 2 β , β― , a n β β© , the finite summation is given as:
β k = 1 n a k = a 1 + a 2 + β― + a n (1) \sum^n_{k=1} a_k=a_1+a_2+\cdots+a_n\tag{1} k = 1 β n β a k β = a 1 β + a 2 β + β― + a n β ( 1 )
Additionally, we have the property that the value of a summation over an empty range is 0
β k = 1 0 a k = 0 Β Β Β Β Β (byΒ definition) (2)
\sum^0_{k=1}a_k=0\text{\ \ \ \ \ (by definition)} \tag{2}
k = 1 β 0 β a k β = 0 Β Β Β Β Β (byΒ definition) ( 2 )
Finite sums may be added in any order (commutativity)
For n n n nonintegral, could use floor β n β \lfloor n \rfloor β n β or ceiling β n β \lceil n\rceil β n β .
Nonintegral
Not of, being, or related to a mathematical integer
4.2 - Infinite Summations
π± The infinite summation a 1 + a 2 + β― a_1+a_2+\cdots a 1 β + a 2 β + β― is represented as the limit of a finite summation:
β k = 1 β = lim β‘ n β β β k = 1 n a k (3) \sum^\infty_{k=1}=\lim_{n\rightarrow\infty} \sum^n_{k=1} a_k\tag{3} k = 1 β β β = n β β lim β k = 1 β n β a k β ( 3 )
The limit does not need to be well-=behaved
Diverges (limit does not exist) β k = 1 β ( β 1 ) n \sum^\infty_{k=1} (-1)^n β k = 1 β β ( β 1 ) n
Converges
Absolutely convergent (any order) - converges if you take the absolute value of each value in the sum.
That is β k = 1 β β£ a k β£ \sum^\infty_{k=1} |a_k | β k = 1 β β β£ a k β β£ converges.
4.3 - Linearity
β k = 1 n ( c a k + b k ) = c β k = 1 n a k + β k = 1 n b k (4)
\sum^n_{k=1} (ca_k+b_k)=c\sum^n_{k=1}a_k+\sum^n_{k=1} b_k \tag{4}
k = 1 β n β ( c a k β + b k β ) = c k = 1 β n β a k β + k = 1 β n β b k β ( 4 )
This also holds true for infinite sums, β k = 1 β \sum^\infty_{k=1} β k = 1 β β
4.4 - Arithmetic Series
β k = 1 n k = n ( n + 1 ) 2 (5)
\sum^n_{k=1}k=\frac{n(n+1)}{2}\tag{5}
k = 1 β n β k = 2 n ( n + 1 ) β ( 5 )
4.5 - Geometric Series
4.5.1 - Finite Geometric Series
β k = 0 n x k = 1 + x + x 2 + x 3 + β― + x n = x n + 1 β 1 x β 1 Β Β Β Β Β Β forΒ x β 1 (6)
\begin{aligned}
\sum^n_{k=0}x^k&=1+x+x^2+x^3+\cdots+x^n \tag{6}\\
&=\frac{x^{n+1}-1}{x-1} \ \ \ \ \ \ \text{for } x \ne 1
\end{aligned}
k = 0 β n β x k β = 1 + x + x 2 + x 3 + β― + x n = x β 1 x n + 1 β 1 β Β Β Β Β Β Β forΒ x ξ = 1 β ( 6 )
4.5.2 - Infinite Geometric Series
Derived from the above formula, but as n β 0 n\rightarrow 0 n β 0 , so all thatβs left is the 1 1 1 in the numerator
β k = 0 β x k = 1 1 β x Β Β Β Β Β Β Β forΒ β£ x β£ < 1 (7)
\sum^\infty_{k=0}x^k=\frac{1}{1-x}\ \ \ \ \ \ \ \text{for } |x|<1\tag{7}
k = 0 β β β x k = 1 β x 1 β Β Β Β Β Β Β Β forΒ β£ x β£ < 1 ( 7 )
4.6 - Harmonic Series
H n = 1 + 1 2 + 1 3 + β― + 1 n = β k = 1 n 1 k (8)
\begin{aligned}
H_n&=1 + \frac{1}{2}+\frac13+\cdots+\frac1n
&=\sum^n_{k=1} \frac1k \tag{8}
\end{aligned}
H n β β = 1 + 2 1 β + 3 1 β + β― + n 1 β β = k = 1 β n β k 1 β β ( 8 )
H n = ln β‘ n + Ξ³ β Ξ³ = 0.577... H_n=\ln n + \gamma\Rightarrow \gamma=0.577... H n β = ln n + Ξ³ β Ξ³ = 0.577...
4.7 - Tight Upper Bound
π± Little-o notation represents the tight asymptotic bound on a function.
o ( g ( n ) ) = { f ( n ) : β c > 0 , β n 0 > 0 β£ 0 β€ f ( n ) < c β
g ( n ) , β n β₯ 0 } o(g(n))=\{f(n):\forall c >0, \exists n_0>0 | 0\le f(n)<c\cdot g(n), \forall n \ge 0\} o ( g ( n )) = { f ( n ) : β c > 0 , β n 0 β > 0β£0 β€ f ( n ) < c β
g ( n ) , β n β₯ 0 }
Note that this function requires both functions f f f and g g g to be asymptotically non-negative.
We can use the little-o definition with limits:
f ( n ) β o ( g ( n ) ) Β Β ifΒ Β lim β‘ n β β f ( n ) g ( n ) = 0 (9)
f(n)\in o(g(n)) \ \ \text{if}\ \ \lim_{n\rightarrow\infty}\frac{f(n)}{g(n)}=0\tag{9}
f ( n ) β o ( g ( n )) Β Β if Β Β n β β lim β g ( n ) f ( n ) β = 0 ( 9 )
and f ( n ) f(n) f ( n ) is asymptotically non-negative.
4.8 - LβHopitalβs Rule
π± How do you evaluate the limit lim β‘ n β β f ( n ) g ( n ) \lim_{n\rightarrow\infty} \frac{f(n)}{g(n)} lim n β β β g ( n ) f ( n ) β if it looks hard?
Consider lim β‘ n β a f ( n ) g ( n ) \lim_{n\rightarrow a}\frac{f(n)}{g(n)} lim n β a β g ( n ) f ( n ) β when either:
lim β‘ n β a f ( n ) = 0 = lim β‘ n β a g ( n )
\lim_{n\rightarrow a} f(n)=0=\lim_{n\rightarrow a}g(n)
n β a lim β f ( n ) = 0 = n β a lim β g ( n )
or when
lim β‘ n β a f ( n ) = Β± β = lim β‘ n β a g ( n )
\lim_{n\rightarrow a} f(n)=\pm\infty=\lim_{n\rightarrow a} g(n)
n β a lim β f ( n ) = Β± β = n β a lim β g ( n )
We can use LβHopitalβs rule, giving:
lim β‘ n β a f ( n ) g ( n ) = lim β‘ n β a d d x f ( n ) d d x g ( n ) (10)
\lim_{n\rightarrow a} \frac{f(n)}{g(n)}=\lim_{n\rightarrow a} \frac{\frac{d}{dx} f(n)}{\frac{d}{dx} g(n)}\tag{10}
n β a lim β g ( n ) f ( n ) β = n β a lim β d x d β g ( n ) d x d β f ( n ) β ( 10 )
4.9 - Telescoping Series
β k = 1 n ( a k β a k β 1 ) = ( a 1 β a 0 ) + ( a 2 β a 1 ) + β― + ( a n β a n β 1 ) = a n β a 0 (11)
\begin{aligned}
\sum^n_{k=1}(a_k-a_{k-1})&=(a_1-a_0) + (a_2-a_1)+\cdots+(a_n-a_{n-1})\\
&=a_n-a_0 \tag{11}
\end{aligned}
k = 1 β n β ( a k β β a k β 1 β ) β = ( a 1 β β a 0 β ) + ( a 2 β β a 1 β ) + β― + ( a n β β a n β 1 β ) = a n β β a 0 β β ( 11 )
β k = 0 n β 1 ( a k β a k + 1 ) = a 0 β a n (12)
\sum^{n-1}_{k=0}(a_k-a_{k+1})=a_0-a_n \tag{12}
k = 0 β n β 1 β ( a k β β a k + 1 β ) = a 0 β β a n β ( 12 )
Example:
β k = 1 n β 1 1 k ( k + 1 ) = β k = 1 n β 1 ( 1 k β 1 k + 1 ) = 1 β 1 n
\sum^{n-1}_{k=1}\frac{1}{k(k+1)}=\sum^{n-1}_{k=1}(\frac1k-\frac1{k+1})=1-\frac1n
k = 1 β n β 1 β k ( k + 1 ) 1 β = k = 1 β n β 1 β ( k 1 β β k + 1 1 β ) = 1 β n 1 β
We know this because 1 k ( k + 1 ) = 1 k β 1 k + 1 \frac1{k(k+1)}=\frac 1k-\frac 1{k+1} k ( k + 1 ) 1 β = k 1 β β k + 1 1 β
4.10 - Differentiation
Example: β k = 0 β k x k \sum^\infty_{k=0} kx^k β k = 0 β β k x k where β£ x β£ < 1 |x|<1 β£ x β£ < 1 , we know:
β k = 0 β = 1 1 β x Β Β Β Β Β ifΒ β£ x β£ < 1
\sum^\infty_{k=0}=\frac{1}{1-x}\ \ \ \ \ \text{if } |x|<1
k = 0 β β β = 1 β x 1 β Β Β Β Β Β ifΒ β£ x β£ < 1
Differentiation both sides with respect to x x x gives:
β k = 0 β x k = 1 ( 1 β x ) 2
\sum^\infty_{k=0} x^k = \frac{1}{(1-x)^2}
k = 0 β β β x k = ( 1 β x ) 2 1 β
This gives:
β k = 0 β k x k = x ( β k = 0 β k x k β 1 ) = x ( 1 β x ) 2
\sum^\infty_{k=0} kx^k=x(\sum^\infty_{k=0} kx^{k-1})=\frac{x}{(1-x)^2}
k = 0 β β β k x k = x ( k = 0 β β β k x k β 1 ) = ( 1 β x ) 2 x β
4.11 - Algebraic Manipulation
Example s = β i = 1 β i 2 i s=\sum^\infty_{i=1} \frac{i}{2^i} s = β i = 1 β β 2 i i β
s = 1 2 + 2 2 2 + 3 2 3 + β― 2 s = 1 + 2 2 + 3 2 2 + β― 2 s β s = 1 + 1 2 + 1 2 2 + β― + = β k = 0 β 1 2 k = 1 1 β 1 2 = 2
\begin{aligned}
s&=\frac12+\frac{2}{2^2}+\frac{3}{2^3}+\cdots\\
2s&=1+\frac22+\frac{3}{2^2}+\cdots\\
2s-s&=1+\frac12+\frac{1}{2^2}+\cdots+\\
&=\sum^\infty_{k=0}\frac1{2^k}=\frac{1}{1-\frac{1}{2}}=2
\end{aligned}
s 2 s 2 s β s β = 2 1 β + 2 2 2 β + 2 3 3 β + β― = 1 + 2 2 β + 2 2 3 β + β― = 1 + 2 1 β + 2 2 1 β + β― + = k = 0 β β β 2 k 1 β = 1 β 2 1 β 1 β = 2 β
so s = 2 s=2 s = 2
4.12 - Products
Definitions:
β k = 1 n a k = a 1 a 2 β― a n
\prod^n_{k=1} a_k=a_1 a_2\cdots a_n
k = 1 β n β a k β = a 1 β a 2 β β― a n β
Note that by definition, products over empty ranges have a value of 1.
β k = 1 0 a k = 1
\prod^0_{k=1} a_k=1
k = 1 β 0 β a k β = 1
Products can be converted to sums using logarithms
lg β‘ β k = 1 n a k = β k = 1 n lg β‘ a k
\lg \prod^n_{k=1}a_k=\sum^n_{k=1} \lg a_k
lg k = 1 β n β a k β = k = 1 β n β lg a k β
4.13 - Logarithms
Remember that log β‘ x = log β‘ 2 x \log x=\log_2x log x = log 2 β x and ln β‘ x = log β‘ e x \ln x=\log_e x ln x = log e β x
4.14 - Bounding Sums - Upper Bounds
β k = 1 n a k β€ n a max
\sum^n_{k=1} a_k\le na_{\text{max}}
k = 1 β n β a k β β€ n a max β
For example:
β k = 1 n k β€ β k = 1 n n = n 2
\sum^n_{k=1}k\le\sum^n_{k=1}n=n^2
k = 1 β n β k β€ k = 1 β n β n = n 2
If we know that a k + 1 a k β€ r , β k β₯ 0 \frac{a_{k+1}}{a_k}\le r, \forall k \ge 0 a k β a k + 1 β β β€ r , β k β₯ 0 with r < 1 r<1 r < 1 as a constant (i.e. geometric series) then:
β k = 0 n β€ β k = 0 β a 0 r k = a 0 β k = 0 n r k β€ a 0 1 β r
\sum^n_{k=0}\le \sum^\infty_{k=0} a_0 r^k = a_0\sum^n_{k=0} r^k\le \frac {a^0}{1-r}
k = 0 β n β β€ k = 0 β β β a 0 β r k = a 0 β k = 0 β n β r k β€ 1 β r a 0 β
4.14 - Bounding Sums - Lower Bounds
β k = 1 n a k β€ n a min
\sum^n_{k=1} a_k\le na_{\text{min}}
k = 1 β n β a k β β€ n a min β
For example:
β k = 1 n k β₯ β k = 1 n 1 = n
\sum^n_{k=1} k \ge \sum^n_{k=1}1=n
k = 1 β n β k β₯ k = 1 β n β 1 = n
This is a linear bound, which is poor - Split the sum
β k = 1 n k = β k = 1 n / 2 k + β k = n 2 + 1 n k β₯ β k = 1 n 2 0 + β k = n 2 + 1 n n 2 β₯ ( n 2 ) 2 = n 2 4
\sum^n_{k=1}k=\sum^{n/2}_{k=1}k+\sum^n_{k=\frac n2+1}k\ge \sum^\frac n2_{k=1} 0+\sum^n_{k=\frac n2 + 1} \frac n2 \ge (\frac n2)^2=\frac{n^2}4
k = 1 β n β k = k = 1 β n /2 β k + k = 2 n β + 1 β n β k β₯ k = 1 β 2 n β β 0 + k = 2 n β + 1 β n β 2 n β β₯ ( 2 n β ) 2 = 4 n 2 β
This is a quadratic bound - Ξ ( n 2 ) \Theta(n^2) Ξ ( n 2 )
4.15 - Bounding Products - Upper and Lower Bounds
Give an upper and lower bound for the product n ! n! n !
n ! = 1 Γ 2 Γ β― Γ 3 Γ ( n β 1 ) Γ n = β k = 1 n k
n!=1\times 2\times \cdots \times 3\times (n-1)\times n=\prod^n_{k=1}k
n ! = 1 Γ 2 Γ β― Γ 3 Γ ( n β 1 ) Γ n = k = 1 β n β k
An upper bound for this product is:
n ! = β k = 1 n k β€ β k = 1 n n = n n
n!=\prod^n_{k=1}k\le\prod^n_{k=1}n=n^n
n ! = k = 1 β n β k β€ k = 1 β n β n = n n
A (trivial) lower bound for this product is:
n ! = β k = 1 n k β₯ β k = 1 n 1 = 1
n!=\prod^n_{k=1}k\ge \prod^n_{k=1}1=1
n ! = k = 1 β n β k β₯ k = 1 β n β 1 = 1
A tight lower bound for this product is
n ! = β k = 1 n 2 k Γ β k = n 2 + 1 n k β₯ β k = 1 n 2 1 Γ β k = n 2 + 1 n n 2 = ( n 2 ) n 2
\begin{aligned}
n!&=\prod^\frac n2_{k=1}k\times\prod^n_{k=\frac n2 + 1} k\\
&\ge \prod^\frac n2 _{k=1} 1 \times \prod ^n _{k=\frac n2 + 1} \frac n2 = (\frac n2)^ \frac n2
\end{aligned}
n ! β = k = 1 β 2 n β β k Γ k = 2 n β + 1 β n β k β₯ k = 1 β 2 n β β 1 Γ k = 2 n β + 1 β n β 2 n β = ( 2 n β ) 2 n β β
Note that Stirlingβs approximation gives:
n ! = 2 Ο n ( n e ) n ( 1 + Ξ ( 1 n ) )
n!=\sqrt{2\pi n} (\frac ne)^n (1+\Theta(\frac 1n))
n ! = 2 Οn β ( e n β ) n ( 1 + Ξ ( n 1 β ))
4.16 - Splitting Sums is a Powerful Technique
Consider using the splitting sums technique to compute the upper bound of the harmonic series:
Consider H n = β k = 1 n 1 k H_n=\sum^n_{k=1} \frac 1k H n β = β k = 1 n β k 1 β
Split the range into β lg β‘ n β \lfloor \lg n\rfloor β lg n β pieces, with each piece summing β€ 1 \le 1 β€ 1
( 1 ) + ( 1 / 2 + 1 / 3 ) + ( 1 / 4 + 1 / 5 + 1 / 6 + 1 / 7 ) + β―
(1)+(1/2+1/3)+(1/4+1/5+1/6+1/7)+\cdots
( 1 ) + ( 1/2 + 1/3 ) + ( 1/4 + 1/5 + 1/6 + 1/7 ) + β―
β k = 1 n 1 k β€ β i = 0 β lg β‘ n β ( β j = 0 2 i β 1 1 2 i + j ) β€ β i = 0 β lg β‘ n β ( β j = 0 2 i β 1 1 2 i ) β€ β i = 0 β lg β‘ n β 1 β€ 1 + lg β‘ n
\sum^n_{k=1}\frac 1k\le\sum^{\lfloor \lg n\rfloor}_{i=0} (\sum^{2^i-1}_{j=0} \frac 1{2^i + j})\le\sum^{\lfloor \lg n\rfloor}_{i=0}(\sum^{2^i-1}_{j=0} \frac 1 {2^i})\le \sum^{\lfloor \lg n \rfloor}_{i=0} 1 \le 1 + \lg n
k = 1 β n β k 1 β β€ i = 0 β β l g n β β ( j = 0 β 2 i β 1 β 2 i + j 1 β ) β€ i = 0 β β l g n β β ( j = 0 β 2 i β 1 β 2 i 1 β ) β€ i = 0 β β l g n β β 1 β€ 1 + lg n
4.17 - Approximation by Integrals
Consider β k = m n f ( k ) \sum^n_{k=m} f(k) β k = m n β f ( k ) where f ( k ) f(k) f ( k ) is monotonically increasing:
β« m β 1 n f ( x ) Β d x β€ β k = m n f ( k ) β€ β« m n + 1 f ( x ) Β d x
\int^n_{m-1} f(x)\ dx\le\sum^n_{k=m} f(k) \le \int^{n+1}_m f(x)\ dx
β« m β 1 n β f ( x ) Β d x β€ k = m β n β f ( k ) β€ β« m n + 1 β f ( x ) Β d x
There is a similar proof for monotonically decreasing functions:
β« m n + 1 f ( x ) Β d x β€ β k = m n f ( k ) β€ β« m β 1 n f ( x ) Β d x
\int^{n+1}_m f(x)\ dx \le \sum^n_{k=m} f(k) \le \int^n_{m-1} f(x)\ dx
β« m n + 1 β f ( x ) Β d x β€ k = m β n β f ( k ) β€ β« m β 1 n β f ( x ) Β d x
Thus H n β₯ β« 1 n + 1 1 x d x = ln β‘ ( n + 1 ) H_n\ge \int^{n+1}_1 \frac 1x dx = \ln (n + 1) H n β β₯ β« 1 n + 1 β x 1 β d x = ln ( n + 1 ) and β k = 2 n 1 k β€ β« 1 n 1 x d x = ln β‘ n \sum^n_{k=2} \frac 1k \le \int ^n_1 \frac 1x dx=\ln n β k = 2 n β k 1 β β€ β« 1 n β x 1 β d x = ln n so H n β€ ln β‘ n + 1 H_n\le \ln n +1 H n β β€ ln n + 1