CS 23022 Discrete Mathematical Structures
-
Upload
julian-rowe -
Category
Documents
-
view
36 -
download
1
description
Transcript of CS 23022 Discrete Mathematical Structures
CS 23022Discrete Mathematical Structures
Mehdi Ghayoumi
MSB rm 132
Ofc hr: Thur, 9:30-11:30a
Announcements
Homework 4 available. Due Mon 06/23, 8a.
Midterm : Next Mon 06/30/14, location 121.
Chapter 2.3 in Rosen and some other articles
And
Chapter 3 in Rosen
Familiar functionsPolynomials:
f(x) = a0xn + a1xn-1 + … + an-1x1 + anx0
constants (like 3, -20, or ½) variables (like x and y)
exponents (like the 2 in y2), but only 0, 1, 2, 3, ... etc. are allowed
A polynomial can have:
A polynomial can have constants, variables and exponents, but never division by a variable.
Familiar functions
Degree
Standard Form
Familiar functionsExponentials:
The exponential function with base b is defined by:
Familiar functionsNatural Exponential Function:
This function is simply a "version" of
where b >1.
Familiar functions
Inverse of f (x) = ex:
• set the equation equal to y• swap the x and y • solve for y by rewriting in log form• log base e is called the natural log, ln
Since f (x) = ex is a one-to-one function, we know that its inverse will also be a function.
But what is the equation of the inverse of f (x) = ex ?
To solve for an inverse algebraically:
Familiar functionsOther Exponential Inverses:
Y=2x or y= 0.5x
Familiar functionsLogarithms:
log2 x = y, where 2y = x.
In this course, log2 n is written lg n. If we write
log n, assume log2 n.
f(x) = loga(x)
a is any value greater than 0, except 1
Example: f(x) = log½(x) Example: f(x) = log2(x)
Familiar functions
loga(x) is the Inverse Function of ax (the Exponential Function)
Inverse
The Natural Logarithm Function
This is the "Natural" Logarithm Function:f(x) = loge(x)
Where e is "Eulers Number" = 2.718281828459 (and more ...)
Familiar functions
Ceiling:
f(x) = x the least integer y so that x y.
Ex: 1.2 = 2; -1.2 = -1; 1 = 1
Familiar functions
Floor:
f(x) = x the greatest integer y so that x y.
Ex: 1.8 = 1; -1.8 = -2; -5 = -5
Familiar functionsLinear Function
f(x) = mx + b
Square Function Cube Function
f(x) = x2 f(x) = x3
Familiar functionsSquare Root Function
f(x) = √x
Absolute Value Function
f(x) = |x|
Reciprocal Function
f(x) = 1/x
Familiar functionsLogarithmic Function
f(x) = ln(x)
Exponential Function
f(x) = ex
Familiar functionsDance Moves
Function typesDescribe these functions:
f(x)
x
Every unit increase in x results in the
same increase in f(x).
Linear functions
Function typesDescribe this function:
Very slow growing.
Logarithmic function
Function typesDescribe this function:
Very fast growing.
Exponential function
Function typesDescribe this function:
f(x)
x
Polynomial
Two example algorithms
Suppose we wish to find the maximum
number in a sequence of n numbers.
How long should we spend doing this?
We say the algorithm has
“order n” running time.
In this case our algorithm takes about n
time units.Suppose it takes 1 time unit to make a
comparison between two numbers.
Two example algorithmsI have a number between 0 and 63.
You ask a question, I’ll tell you yes or no.
How long will it take you to find my secret number?
Suppose it takes 1 time unit to answer a
query about my number.
In this case the algorithm takes about lg
n time units.
We say the algorithm has “order log n” running time.
Who wins the race?The following graph gives times for completing races
of length x, for 4 different competitors.
Who is the tortoise?
time
distance
Who is the hare?
How would you describe blue’s performance?
At each distance, who
wins?
Growth of functionsAlgorithm analysis is concerned with:
•Type of function that describes run time
(we ignore constant factors since different
machines have different speed/cycle)
•Large values of x
Growth of functionsImportant definition:
For functions f and g we write
f(x) = O(g(x))
to denote
c,k so that x>k, f(x) c·g(x)
We say “f(x) is big O of g(x)”
Recipe for proving f(x) = O(g(x)): find a c and k so that the
inequality holds.
Growth of functionsf(x) = O(g(x)) iff
c,k so that x>k, f(x) c·g(x)
x
f(x)
g(x)c·g(x)
k
We give an eventual upper bound on f(x)
Growth of functions (examples)f(x) = O(g(x))
Iff
c,k so that x>k, f(x) c·g(x)
3n = O(15n) since n>0, 3n 1·15n
There’s k There’s c
Growth of functions (examples)f(x) = O(g(x))
iff
c,k so that x>k, f(x) c·g(x)
15n = O(3n) since n>__, 15n __·3n 5 80 5
Growth of functions (examples)f(x) = O(g(x))
iff
c,k so that x>k, f(x) c·g(x)
x2 = O(x3) since x> __, x2 x3 1
Growth of functions (examples)f(x) = O(g(x))
iff
c,k so that x>k, f(x) c·g(x)
1000x2 = O(x2) since x> __, 1000x2 ____·x2 0 1000
Growth of functions (examples)
f(x) = O(x4).
Growth of functions (examples)
Prove that 5x + 100 = O(x/2)
Nothing works for k
Need x> ___, 5x + 100 ___ · x/2
Try c = 10 x> ___, 5x + 100 10 · x/2
k = 200, c = 11
Try c = 11
x> ___, 5x + 100 5x + x/2
x> ___, 100 x/2 200
Growth of functionsGuidelines:
In general, only the largest term in a sum matters.
a0xn + a1xn-1 + … + an-1x1 + anx0 = O(xn)
n5lg n = O(n6)
List of common functions in increasing O() order:
1 (lg n ) n (n lg n) n2 … 2n n!
Growth of functions (more examples)
Then
log n!log nn n log n,
log n!O(n log n)
nnnnnnnnnn 123)1(!
n!O(nn )
So
Growth of functions - a corollaryIf f1(x) = O(g1(x)) and f2(x)=O(g2(x)), then
f1(x) + f2(x) = O(max{g1(x),g2(x)})
This is just the case where g1(x) = g2(x) = g(x)
If f1(x) = O(g(x)) and f2(x)=O(g(x)), then
f1(x) + f2(x) = O(g(x)).