1 / 40

Real-Valued Functions and Their Graphs: A Computer Science Perspective

Explore different types of real-valued functions and their graphs, including linear, quadratic, cubic, power, square root, cube root, fourth root, and logarithmic functions.

hastingsl
Download Presentation

Real-Valued Functions and Their Graphs: A Computer Science Perspective

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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. 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. x3 x2 x x Power Functions

  12. 2x 3x x x2 Multiples of Functions

  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) = log2x

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

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

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

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

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

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

  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. 2x f(x) = 2x vs. Power Functions (Small Values of x)

  24. 2x x3 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

  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

  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)

  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!)

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

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

More Related