Presentation is loading. Please wait.

Presentation is loading. Please wait.

Real-Valued Functions of a Real Variable and Their Graphs

Similar presentations


Presentation on theme: "Real-Valued Functions of a Real Variable and Their Graphs"— Presentation transcript:

1 Real-Valued Functions of a Real Variable and Their Graphs
Section 9.1 Real-Valued Functions of a Real Variable and Their Graphs

2 Let f be a real valued function of a real variable
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.

3 The Linear Function f(x) = x

4 The Quadratic Function f(x) = x2

5 The Cubic Function f(x) = x3

6 Power Functions xa, a  1 The higher the power of x, the faster the function grows. xa grows faster than xb if a > b.

7 The Square-Root Function

8 The Cube-Root Function

9 The Fourth-Root Function

10 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.

11 Power Functions x3 x2 x x

12 Multiples of Functions
x2 3x 2x x

13 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

14 The Logarithmic Function f(x) = log2 x

15 Growth of the Logarithmic Function
The logarithmic functions grow more and more slowly as x gets larger and larger.

16 f(x) = log2 x vs. g(x) = x1/n x1/2 log2 x x1/3

17 Logarithmic Functions vs. Power Functions
The logarithmic functions grow more slowly than any power function xa, 0 < a < 1.

18 f(x) = x vs. g(x) = x log2 x x log2 x x

19 f(x) vs. f(x) log2 x 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 x f(x).

20 f(x) vs. f(x) log2 x x2 log2 x x2 x log2 x x

21 The Exponential Function f(x) = 2x

22 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.

23 f(x) = 2x vs. Power Functions (Small Values of x)

24 f(x) = 2x vs. Power Functions (Large Values of x)

25 Section 9.2 O-Notation

26 “Big-Oh” Notation: O(f)
Let g : R  R be a function. A function f : R  R is “of order g,” written “f(x) is O(g(x)),” if there exist constants M, x0  R such that f(x)  Mg(x) for all x  x0.

27 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.

28 Common Growth Rates Growth Rate Example O(1) Access an array element
O(log2 x) Binary search O(x) Sequential search O(x log2 x) Quick sort O(x2) Bubble sort O(2x) Factor an integer O(x!) Traveling salesman problem

29 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).

30 Estimating Run Times Thus, the run time is given by
t = (t0/f(x0))  f(x) = t0  (f(x)/f(x0)).

31 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.

32 Comparison of Growth Rates
x O(1) O(log x) O(x) O(x log x) O(x2) 102 1 sec 103 1.5 sec 10 sec 15 sec 17 min 104 2 sec 1.7 min 3.3 min 2.8 hrs 105 2.5 sec 42 min 11 days 106 3 sec 8.3 hrs 3.2 yrs 107 3.5 sec 1.2 days 4.1 days 320 yrs

33 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.

34 Comparison with O(2n) x O(x2) O(2x) 100 1 sec 110 1.2 sec 17 min 120
12 days 130 1.7 sec 34 yrs 140 2.0 sec 35,000 yrs 150 2.3 sec 36,000,000 yrs

35 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.

36 Comparison with (n!) x O(2x) O(x!) 100 1 sec 101 2 sec 1.7 min 102
2.9 hrs 103 8 sec 12 days 104 16 sec 3.5 yrs 105 32 sec 367 yrs

37 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).

38 Comparing Orders Theorem: O(xa) < O(xb) if 0 < a < b.
O(loga x) = O(logb x) 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.

39 Comparing Orders Theorem: For all functions f(x), g(x), and h(x), if
O(f) < O(g), then O(f  h) < O(g  h).

40 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).


Download ppt "Real-Valued Functions of a Real Variable and Their Graphs"

Similar presentations


Ads by Google