400 likes | 409 Views
Explore different types of real-valued functions and their graphs, including linear, quadratic, cubic, power, square root, cube root, fourth root, and logarithmic functions.
E N D
Section 9.1 Real-Valued Functions of a Real Variable and Their Graphs
Let f be a real valued function of a real variable. The graph of f is the set of all points (x,y) in the Cartesian coordinate plane with the property that x is in the domain of f and y = f(x) For application in computer science, we are almost invariably concerned with situations where x and a are nonnegative.
Power Functions xa, a 1 • The higher the power of x, the faster the function grows. • xa grows faster than xb if a > b.
Power Functions xa, 0 < a < 1 • The lower the power of x, the more slowly the function grows. • xa grows more slowly than xb if a < b. • This is the same rule as before, stated in the contrapositive.
x3 x2 x x Power Functions
2x 3x x x2 Multiples of Functions
Multiples of Functions • Notice that x2 eventually exceeds any constant multiple of x. • Generally, if f(x) grows faster than g(x), then f(x) also grows faster than cg(x), for any real number c. • In other words, we think of g(x) and cg(x) as growing at the “same rate.” • If the growth rate of one function is a constant time the growth rate of another then they’re said to’ve the same growth rate
Growth of the Logarithmic Function • The logarithmic functions grow more and more slowly as x gets larger and larger.
x1/2 log2 x x1/3 f(x) = log2x vs. g(x) = x1/n
Logarithmic Functions vs. Power Functions • The logarithmic functions grow more slowly than any power function xa, 0 < a < 1.
x x log2 x f(x) = x vs. g(x) = x log2x
f(x) vs. f(x) log2x • The growth rate of log x is between the growth rates of 1 and x. • Therefore, the growth rate of f(x) log x is between the growth rates of f(x) and xf(x).
x2 x2 log2 x x x log2 x f(x) vs. f(x) log2x
Growth of the Exponential Function • The exponential functions grow faster and faster as x gets larger and larger. • Every exponential function grows faster than every power function.
2x f(x) = 2x vs. Power Functions (Small Values of x)
2x x3 f(x) = 2x vs. Power Functions (Large Values of x)
Section 9.2 O-Notation
“Big-Oh” Notation: O(f) • Let g : RR be a function. • A function f : RR is “of order g,” written “f(x) is O(g(x)),” if there exist constants M, x0R such that f(x)Mg(x) for all xx0.
Growth Rates • If f(x) is O(g(x)), then the growth rate of f is no greater than the growth rate of g. • If f(x) is O(g(x)) and g(x) is O(f(x)), then f and g have the same growth rate.
Estimating Run Times • Suppose a program has growth rate O(f), for a specific function f(x). • Then the run time is of the form t = cf(x) for some real number c. • Suppose the program runs in t0 seconds when the input size is x0. Then c = t0/f(x0).
Estimating Run Times • Thus, the run time is given by t = (t0/f(x0)) f(x) = t0 (f(x)/f(x0)).
Comparison of Growth Rates • Consider programs with growth rates of O(1), O(log x), O(x), O(x log x), and O(x2). • Assume that each program runs in 1 second when the input size is 100. • Calculate the run times for input sizes 102, 103, 104, 105, 106, and 107.
Comparison with O(2n) • Now consider a program with growth rate O(2x). • Assume that the program runs in 1 second when the input size is 100. • Calculate the run times for input sizes 100, 110, 120, 130, 140, and 150.
Comparison with O(n!) • Now consider a program with growth rate O(x!). • Assume that the program runs in 1 second when the input size is 100. • Calculate the run times for input sizes 100, 101, 102, 103, 104, and 105.
Comparing Orders • Let f and g be two functions. • Define O(f) O(g) to mean that f is O(g). • Define O(f) = O(g) to mean that f is O(g) and g is O(f). • Define O(f) < O(g) to mean that f is O(g), but g is not O(f).
Comparing Orders • Theorem: • O(xa) < O(xb) if 0 < a < b. • O(logax) = O(logbx) for all a, b > 1. • O(1) < O(log x) < O(xa) for all a > 0. • O(ax) < O(bx) if 1 < a < b. • O(xa) < O(bx) for all a > 0, b > 1. • O(ax) < O(x!) for all a > 1.
Comparing Orders • Theorem: For all functions f(x), g(x), and h(x), if O(f) < O(g), then O(fh) < O(gh).
Feasible vs. Infeasible • Algorithms with polynomial growth rates or less are considered feasible. • Algorithms with growth rates greater than polynomial are considered infeasible. • Of course, all algorithms are feasible for small input sizes. • It is feasible to factor small integers (< 50 digits). • It is infeasible to factor large integers (> 200 digits).