Topics Intro to Functions 7 1 More functions

  • Slides: 13
Download presentation
Topics • Intro. to Functions (7. 1) • More functions (9. 1) • Efficiency

Topics • Intro. to Functions (7. 1) • More functions (9. 1) • Efficiency of algorithms/functions (9. 2) 1

Original author of the slides: Vadim Bulitko University of Alberta http: //www. cs. ualberta.

Original author of the slides: Vadim Bulitko University of Alberta http: //www. cs. ualberta. ca/~bulitko/W 04 Modified by T. Andrew Yang (yang@uhcl. edu) 2

Definition • Intuition: a function takes input and produces one output: – f(x) =

Definition • Intuition: a function takes input and produces one output: – f(x) = x 2 – f(x) = sin(x) • Formalism: – Domain type: Df – Range type: Rf – [Mapping] Graph: • Gf = { <x, f(x)> | x Df, f(x) Rf} Df x Rf – For every x Df there is at most one pair <x, f(x)> Gf • Graphs of sample functions: – Let D = {1, 2, 3, 4, 5}. f(x) = x 2, x D. – f(x) = 1/x, x R. 3

Example: f(x) = x 2 4

Example: f(x) = x 2 4

Functional Property For every x there is at most one y such that y=f(x)

Functional Property For every x there is at most one y such that y=f(x) [y=1/x] There is an x such that more than one y satisfy y=f(x) [x 2+y 2=25] Example: x=0, y 1=5, y 2=-5 5

Domain & Range 6

Domain & Range 6

Questions? 7

Questions? 7

Graphs of Real-Valued Functions of a Real Variable • A real-valued function of a

Graphs of Real-Valued Functions of a Real Variable • A real-valued function of a real variable is a function from one set of real numbers to another. • 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). • Exercises: Show the graphs of the following functions. – – – f(x) = a, where a is a number. f(x) = ax, where a is a number. f(x) = x 2 f(x) = x 1/2 f(x) = log bx, where b is a number. 8

Multiple of f by M • Let f be a real-valued function of a

Multiple of f by M • Let f be a real-valued function of a real variable, and let M be any real number. • M f, called the multiple of f by M (or M times f), is the real-valued function with the same domain as f and (M f) (x) = M f(x), for all x in the domain of f. • See Example 9. 1. 4 (p. 514 -515) • Show the graphs of the following functions: f(x) = x f(x) = 2 x f(x) = x 2 f(x) = 3 x 2 9

Tool: http: //www. lukewallin. co. uk/graph/newsuite. htm 10

Tool: http: //www. lukewallin. co. uk/graph/newsuite. htm 10

Increasing vs Decreasing functions • Let f be a real-valued function defined on a

Increasing vs Decreasing functions • Let f be a real-valued function defined on a set of real numbers, and suppose the domain of f contains a set S. • f is increasing on the set S iff for all x 1 and x 2 in S, x 1 < x 2 f(x 1) < f(x 2). • f is decreasing on the set S iff for all x 1 and x 2 in S, x 1 < x 2 f(x 1) > f(x 2). • See Figure 9. 1. 5 (p. 516) for examples of increasing and decreasing functions. • Examples of increasing or decreasing functions? 11

Exercises p. 517: 2, 3, 4, 5, 6, 7, 14, 15, 16 21, 22

Exercises p. 517: 2, 3, 4, 5, 6, 7, 14, 15, 16 21, 22 12

Questions? 13

Questions? 13