Processing math: 27%
Math Background
Topics
- We will frequently use the math on this page
- You will want to be familiar with it
- Topics include
- Exponentiation
- Logarithms
- [Mostly SKIP] Combinatorics: permutations, combinations, number of subsets
- Summations
- Floor and ceiling
- Functions
- Miscellaneous:
- Notation and convention
- Positive and non-negative
- Theorems and Lemmas (iff)
- [SKIP] Inductive proofs
EXPONENTIATION
Exponentiation: Definition
- Addition, multiplication, exponentiation:
- Multiplication is repeated addition
- Exponentiation is repeated multiplication
- Example:
- 2 * 3 = 2 + 2 + 2
- 2 3 = 2 * 2 * 2
- Questions???
Up Arrow: A Digression
- Addition: a+n=a+1+⋯+1⏟n times=succ(succ(…succ(a)))⏟n times
- Multiplication: a×n=a+a+⋯+a⏟n times
- Exponentiation: an=a×a×⋯×a⏟n times
- Tetration na=aa…a
- Tetration: 32=222
- Knuth Up Arrow:
- 2↑2=2×2=22=4
- 2↑3=2×2×2=23 = 8
- 2↑4=2×2×2×2=24=16
- 2↑↑2=2↑2=22=4
- 2↑↑3=2↑2↑2=222=2↑(2↑2)=2↑4=16
- 2↑↑4=2↑2↑2↑2=2222=2↑(2↑(2↑2))=2↑(2↑4)=2↑16=65,536
- 2↑↑↑2=2↑↑2=2↑2=4
- 2↑↑↑3=2↑↑(2↑↑2)=2↑↑4=65,536
- 2↑↑↑4=2↑↑(2↑↑(2↑↑2))=2↑↑(2↑↑4)=2↑↑65,536=22265,536 times=???
- 2↑↑↑↑2=2↑↑↑2=2↑↑2=2↑2=4
- 2↑↑↑↑3=2↑↑↑(2↑↑↑2)=2↑↑↑4=22265,536 times
- 2↑↑↑↑4=2↑↑↑(2↑↑↑(2↑↑↑2))=2↑↑↑(2↑↑↑4)=2↑↑↑(22265,536 times)
- 2↑↑↑3=2↑↑4
- 2↑↑↑↑3=2↑↑↑4
- 2↑mn =2↑m−1(2↑n(n−1))
Exponentiation: Properties of Powers
- Properties follow from the definition:
- babc = ba + c
- b0 = 1 [WHY?]
- ba/bc = ba - c
- 1 / bc = b-c [WHY?]
- (ba)c = bac = (bc)a
- Examples:
- 22 * 230 = 232
- 210 / 24 = 210-4 = 26 = ?
- 2-3 = 1 / 23 = 1 / 8
- (23)4 = 23*4 = 212
= 22 * 210 = 4 * 1024 = 4096
- (23)4
= 84 = 82 * 2
= (82)2
= 642
= 4096
Buzz Numbers
- 210 = 1024 ≈ 1000 = 103
- 220 = (210)2 = 1024 2
≈ 1000 2 = (103) 2=106 =
1,000,000
- 230 = ... ≈ ...
- 232 = ... ≈ ...
LOGORITHMS
Logarithm: Definition
- logbx is defined as the power to which the base, b,
must be raised to produce x
- So, blogbx=x
- Assume b > 0
- Assume x > 0
Examples
- log2 8 = ?
- log2 4 = ?
- log2 2 = ?
- log2 1 = ?
- log2 1024 = ?
- log10 1000 = ?
Logarithm: More Background
Properties of Logarithms
- Properties follow from the definition:
- logb 1 = 0, for any b
- logb b = 1, for any b
- logb (b x) = x
- b logb x = x
- logb xy = logb x + logb y
- logb xy = y logb x
- logb x/y = logb x - logb y
Examples of Properties
- 2 log2 7 = 7
- log2 (4 * 8) = log2 4 + log2 8 = 2 + 3 = 5
- log2 (4 * 8) = log2 32 = 5
- log2 (16 / 2) = log2 16 - log2 2 = 4 - 1 = 3
- log2 (16 / 2) = log2 8 = 3
- log2 (16 5) = 5 * log2 16 = 5 * 4 = 20
- log2 (16 5) = (log2 (24)5 = lg 24*5 =
log2 220 = 20
More Properties of Logarithms
- These also follow from the definition, but are not so obvious:
- loga x * logb a = logb x
- Intuition: Consider log8 64
- How to prove?
- loga x = logb x / logb a [Why?]
- loga x = logb x * loga b [Why?]
- loga b = (1 / logb a) [Why?]
- a logb x = x logb a
- This allows us to change n lg x to x lg n
- How can we prove it?
- Examples:
- log 4 64 * log2 4 = 3 * 2 = 6 = log2 64
- log 8 64 * log2 8 = 2 * 3 = 6 = log2 64
- log 4 64 = log2 64 / log2 4 = 6 / 2 = 3
- log 4 64 = log2 64 / log2 8 = 6 / 3 = 2
- log 4 32 = lg 32 / lg 4 = 5 / 2 = 2.5
- 4^2.5 = 4^2 * 4^0.5 = 16 * 2
- 8 lg 4 = 4 lg 8 = 4 3 = 64 = 82
Notation: Lg, Log, and Ln
- In this course, log2 is most common [Why?]
- We write lg x to mean log2 x
- lg 4 = 2
- lg 8 = 3
- 2 lg 7 = 7
- lg (4 * 8) = lg 4 + lg 8 = 2 + 3 = 5
- Other notations:
- log x means log10 x
- Common log
- (Or, we don't care about the base)
- ln x means loge x
Logarithm Intuition
Another way to think about logarithms.
- Definition: logbx is the power to which we raise b to get x
- Intuition: logbx is the number of times x can be
divided by b before reaching 1
- Examples:
- log10 1000 = 3
- log2 1024 = 10
- log2 4 = 2
- log2 8 = 3
Properties of Logarithms Revisited
- Re-examine properties in light of intuition
- logb 1 = 0, for any b
- logb b = 1, for any b
- logb (b x) = x
- b logb x = x
- logb xy = logb x + logb y
- logb xy = y logb x
- logb x/y = logb x - logb y
- loga x * logb a = logb x
- loga x = logb x / logb a [Why?]
- loga x = logb x * loga b [Why?]
- loga b = (1 / logb a) [Why?]
- a logb x = x logb a
Approximations
What if the power is not an integer?
- log2 4 = 2.000
- log2 7 ≈ 2.807
- log2 8 = 3.000
- Intuition: If x is an integer power of b, it's exactly the number of times to divide,
otherwise approximately
Logarithms and Negative Powers
- log2 1/8 = -3
- lg (1 / 8) = lg 1 - lg 8 = 0 - 3 = -3
- Intuition makes most sense for x ≥ 1, but easily fits negative powers
Does the Base Matter - All Logs are the Same
- Does it matter what base we use when working with logs?
- Yes, if we need a precise answer:
- lg 1024 = 10
- log 1024 ≈ 3
- No, if we don't care about constants:
- loga x = logb x / logb a
- logb a is a constant
- Thus, lg n = k log n,
where k = 1 / log 2 ≈ 3.33
- Thus: Big O of all algorithms with log performance is the same, regardless of
base
- Example: Algorithms that divide input in halves and in thirds
both have log behavior and differ only by a constant
More Examples of Powers and Logs
- Properties of powers and logs (repeated from above)
- babc = ba + c
- ba/bc = ba - c
- b-a = 1 / ba
- (ba)c = bac = (bc)a
- logb 1 = 0, for any b
- logb b = 1, for any b
- logb (b x) = x
- b logb x = x
- logb xy = y logb x
- logb xy = logb x + logy b
- logb x/y = logb x - logy b
- a logb x = x logb a
- loga x = logb x / logb a
- Solve the following:
- lg(n/4)
- lg(sqrt(n))
- lg 2n
- 2lg n
- 22 lg n
- lg(4n log n)
Natural Log
- Why use e as a base for natural log?
- Answer: e and ln have many nice properties
- Useful property: ln x = area under curve 1/x between 1 and x
- We can approximate the area under curve from 1 to x with
rectangles with base 1
- This allows us to approximate 1 + 1/2 + 1/3 + ... + 1/n, which has no
closed form
- 1 + 1/2 + 1/3 + ... + 1/n ≈ ln n
- Useful result (unproved):
- [1/2 + 1/3 + ... + 1/(n-1)] + 1/n < ln n <
1 + [1/2 + 1/3 + ... + 1/(n-1)]
- Bottom Line: sometimes we will use ln n as an approximation for
n∑i=11i
COMBINATORICS - MOSTLY SKIP
Permutations
- Definition: ordering of a set of objects
- In practice: how many ways can you order n objects?
- Example - permutations of abc: abc, acb, bac, bca, cab, cba
- Number of permutation of n objects: P(n)=n!
- Why?
- Reasoning: n choices for first object, n−1 for second, ..., 1 for last
SKIP THE REST
Combinations
- c(n,k) is the number of ways of choosing k objects from n objects when
order does not matter
- The text describes c(n,k) as the number of k-combinations of an n-element set
- Also written as \binom n k
- Spoken as "n choose k"
- \displaystyle c(n, k) = \frac{n!}{(k!(n-k)!)} = \frac{n*(n-1)*(n-2)*...*(n-k+1)} {k!}
- Reasoning:
- n choices for first object, n-1 for second, n-(k-1) for last.
- Divide by k! because order doesn't matter and each group of k
elements could have been chosen in k ways
- Binomial Theorem: \displaystyle (a+b)^n = \sum_{k=0}^{n} c(n, k)a^k b^{n-k}
Subsets
- Number of subsets of an n-element set: 2n
- Students from 420: What is the set of these subsets called?
Summations
Important Summation Formula
- \displaystyle \sum_{i=l}^{h}1 = \underbrace{1 + 1 + \dots + 1}_{u-l+1 \text{ times}} = h-l+1
- \displaystyle \sum_{i=1}^{n}1 = n
- \displaystyle \sum_{i=1}^{n}i = 1 + 2 + \dots + n = \frac{n(n+1)}{2} \approx \frac{n^2}{2}
- \displaystyle \sum_{i=1}^{n}i^2 = 1 + 4 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6} \approx
\frac{n^3}{3}
- \displaystyle \sum_{i=1}^{n}i^k = 1 + 2^k + \dots + n^k \approx
\frac{n^{k+1}}{k+1}
- \displaystyle \sum_{i=0}^{n}a^i = 1 + a + a^2 + \dots + a^n =
\frac{a^{n+1}-1}{a-1} (a ≠ 1)
- \displaystyle \sum_{i=0}^{n}2^k = 2^{n+1}-1
- \displaystyle \sum_{i=1}^{n}i2^i = 1\times 2 + 2\times 2^2 + \dots + n 2^n = (n-1)2^{n+1}+2
- \displaystyle \sum_{i=1}^{n}1/i = 1/1 + 1/2 + \dots + 1/n ≈ \ln n + \gamma
, where \gamma = 0.5722\dots
(Euler's constant)
- See above under natural log for intuition on why this is true
- \displaystyle \sum_{i=1}^{n}\textrm{lg }i \approx n \lg n
- Most important: 1, 2, 5
- Next most important: 4, 7, 8
Manipulating Summation Formula
- \displaystyle \sum_{i=1}^{n}ca_i = c\sum_{i=1}^{n}a_i
- \displaystyle \sum_{i=1}^{n}(a_i \pm b_i) = \sum_{i=1}^{n}a_i \pm \sum_{i=1}^{n}b_i
- \displaystyle \sum_{i=l}^{u}a_i = \sum_{i=l}^{m}a_i + \sum_{i=m+1}^{u}a_i
- \displaystyle \sum_{i=l}^{u}(a_i - a_{i-1}) = a_u - a_{l-1}
Approximation of a Sum by a Definite Integral
See the text (Appendix A)
Floor and Ceiling Functions
Floor
- Floor(x) = the largest integer that is ≤ x
- floor(x) is written as \lfloor x \rfloor
- On a number line, floor(x) is the first integer at or left
of x (ie towards -\infty)
- for positive x, floor(x) truncates the fractional part of x
Ceiling
- Ceiling(x) = the smallest integer that is ≥ x
- ceiling(x) is written as ⌈x⌉
- On a number line, floor(x) is the first integer at or right
of x (ie toward \infty)
- for negative x, floor(x) truncates the fractional part of x
Properties of Floor and Ceiling
- x - 1 \lt \lfloor x \rfloor \le x \le \lceil x \rceil \lt x + 1
- \lfloor x + n \rfloor = \lfloor x \rfloor + n for real x and integer n
- \lceil x + n \rceil = \lceil x \rceil + n for real x and integer n
- \lfloor n/2 \rfloor + \lceil n/2 \rceil = n
- \lceil \lg(n+1) \rceil = \lfloor \lg n \rfloor + 1
- Any positive number n can be halved (integer division)
⌊lg n⌋ times
before reaching 1
- Any positive number, n, that is a integer power of 2
can be halved exactly lg n times
before reaching 1
Miscellaneous
Notation for Powers [NIB]
- We (sometimes) write x^y to denote x^y and x^{yz} to denote
x^{yz}
Postive and Non-negative
- Positive numbers are greater than 0
- Non-negative numbers are greater than or equal 0
Theorems and Lemmas
- p if and only if q means [(if p then q) and (if q then p)]
- In symbols: p ⇔ q means [(p ⇒ q) ∧ (q ⇒ p)]
- p if and only if q is sometimes written as p iff q
- p ⇒ q is NOT equivalent to !p ⇒ !q
- p ⇒ q is equivalent to !q ⇒ !p
- Example: p(x) = x > 2, q(x) = x^2 > 4
Conventions
- lg has high precedence: lg n+1 means (lg n) + 1, not lg(n+1)
- lg lg n means lg (lg n)
- 2lgn = n
- lg 2n = n
Inductive Proofs (ie Mathematical
Induction) - SKIP
Inductive Proofs (ie Mathematical Induction)
- Technique for proving a property is true for an infinite set of integers
- Usually the positive or negative integers
- Based on fundamental this property of integers:
if 1 and 2 below are true, then 3 is true:
- Property p(i) is true for i=1 [or some other initial value]
- For any n ≥ 1, if Property p(i) is true of i=n then p(i)
is true for i=n+1,
- that is, if p(n) is true, then p(n+1) is also true
- Property p(i) holds for all integers i ≥ 1 [or other initial value]
Basis, Induction Hypothesis, Inductive Step
- Inductive proofs use the following terms for their parts:
- Basis: 1. above
- Inductive Hypothesis (IH): in 2. above, assuming that p(n) is true
- Inductive Step (IS): in 2. above, proving that p(n) implies p(n+1)
Induction Example
- Prove 1+2+\dots+n = n(n+1) / 2, for all n ≥ 1
- Property p(i) is 1+2+...+i = i(i+1) / 2
- Prove p(i) is true for all n ≥ 1
- Basis - p(0): 1 = 1(1+1)/2 1(2)/2 = 2/2 = 1
- IH: Assume p(n): 1+2+...+n = n(n+1)/2, for some n ≥ 1
- IS: Show that IH implies p(n+1): that is, the IH implies
1+2+...+(n+1) = (n+1)((n+1)+1)/2
\begin{align*}
1+2+...+(n+1) & = 1+2+...+n+(n+1) \\
& = n(n+1)/2 + n+1\textrm{, by IH} \\
& = [n(n+1) + 2(n+1)] / 2 \\
& = [(n+1)(n+2)] / 2 \\
& = [(n+1)((n+1)+1)] / 2
\end{align*}
- Therefore, by the basis and IS, p(k) is true for all k ≥ 1
- Can we prove p(k) for k ≥ 0? Change p(k) to 0+1+...+k=k(k+1)/2
Induction: Final Points
- Sometimes there are other ways to prove
- Example A.4: \Sigma_{i=0}^{n} r^i = \frac{r^{n+1} - 1} {r-1}
- Sometimes a slightly different IH is used:
- Assume p(k) holds for ALL k ≤ n (not just for k=n)