Mathematical Preliminaries
Logarithm
A logarithm of base b for value y is the power to which b must be raised to get y .
If log b y x , then b x y and blogb y y .
25 32 , so log 2 32 5 .
103 1000 , so log 10 1000 3 .
Two typical uses of logarithms:
What is the minimum number of bits needed to represent n unique addresses?
log 2 n
log 2 n
1
1.58
2
3.58
n
2
3
4
12
log 2 n
Addresses
1
0,1
2
00,01,10,11
2
00,01,10,11
4
0000,0001,0010,0011,
0100,0101,0110,0111,
100010001,101010011,
1100,1101,1110,1111
How many times can an array of size n be split in half until only one element remains in the
sub-array?
log 2 n
2
1
3
3
2
4
5
3
6
3
7
2
8
3
1
This is the idea behind the binary search!
Logarithms have the following properties (assume m, n, and r are any positive values
and a and b are any positive integers).
log mn log m log n
m
log log m log n
n
log n r r log n
log a n
log b n
log b a
Exponents on logarithms can be confusing.
log 2 n 2 2 log 2 n
log 2 n 2 is usually written
log 22 n
Summations
A summation is the sum of some function over a range of parameter values.
n
f i f 1 f 2 f 3 f n
i 1
A closed-form solution is an equation that directly computes the summation.
n(n 1) n 2
i 1 2 3 n
2
2
i 1
n
n
i 2 12 22 32 n2
i 1
2n3 3n 2 n n3
6
3
log n times
n n n n n log n
log n
i 1
Recurrences
A recurrence relation defines a function by means of an expression that includes one or
more “smaller” instances of itself.
T(n) = 2T(n-1) - T(n-2)
T(1) = 3
T(2) = 10
The definition for a recurrence relation contains two parts
The general definition
The base case(s)
Often used to model the cost of recursive functions
int factorial(int n)
{
if (n <= 1) return 1;
return n * factorial(n - 1);
}
The number of multiplications required for an input of size n is zero when n=0 or n=1 (the
base cases) and 1 + the cost of factorial(n-1) when n>1.
T(0) = 0
T(1) = 0
T(n) = T(n-1) + 1
To obtain the closed form solution, expand the right hand side of the definition (remember:
valid only for n>1).
T(n) = T(n-1) + 1
T(n) = (T(n-2) + 1) + 1
= T(n-1) + 2
T(n) = ((T(n-3) + 1) + 1) + 1
= T(n-3) + 3
...
Let’s try some values for n.
T(2) = T(2-1) + 1
T(3) = T(3-2) + 2
T(4) = T(4-3) + 3
...
The general form appears to be:
n 1
T(n) = T(n-(n-1)) +
1
i 1
n 1
T(n) = T(n-n+1) +
1
i 1
T(n) = T(1) + (n - 1)
T(n) = n - 1
Proof Techniques
Proof by Counterexample
The simplest way to disprove a theorem or statement is to find a counterexample (this
may not be easy).
No number of examples supporting a theorem are sufficient to prove that the theorem is
correct.
Proof by Contradiction
Method
Assume that the theorem is false.
Find a logical contradiction stemming from this assumption.
If the logic used to find the contradiction is correct, then the only way to resolve the
contradiction is to conclude that the theorem must be true.
Theorem
There is no largest integer.
Proof
Assume there is a largest integer, call it B.
Now consider C=B+1.
C is an integer since it is the sum of two integers.
Also, C>B, which means B is not the largest.
Here we have a contradiction to our assumption. Our only flaw in reasoning is that we
assumed the theorem was false. Thus, the theorem must be true.
Proof by Induction
Method
Base Case: Show the theorem holds up to some small value of n = c.
Induction Hypothesis: Assume that the theorem is true for all cases up to some limit n = k.
Induction Step: Show that the theorem is true for n = k + 1.
Given the inductive reasoning and the base case, we can conclude that the theorem is
true up to n = c + 1, and therefore up to n = c + 2, etc. for all possible n.
Theorem
The sum of the first n positive integers is
n(n 1)
2
Proof
Let Sn be the sum of the first n positive integers.
Let n 1 , S1
11 1 2
1
2
2
Since 1 is the sum of the first number, the theorem holds for the base case. The induction
hypothesis is that the sum of the first n 1 positive integers is:
Sn 1
n 1n 1 1 n 1n
2
2
Since we assume the induction hypothesis is true,
Sn Sn 1 n
Sn
n 1n n
Sn
n 2 n 2n
2
2
Sn
n2 n
2
Sn
nn 1
2
2
and the theorem is proved
© Copyright 2026 Paperzz