Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter Four Functions. Section 4.1 A function from a set D to set R (f: D  R) is a relation from D to R such that each x in D is related to one and.

Similar presentations


Presentation on theme: "Chapter Four Functions. Section 4.1 A function from a set D to set R (f: D  R) is a relation from D to R such that each x in D is related to one and."— Presentation transcript:

1 Chapter Four Functions

2 Section 4.1 A function from a set D to set R (f: D  R) is a relation from D to R such that each x in D is related to one and only one y in R. D is called the domain of the function and R is called the range of the function. Note: every function is a relation but not every relation is a function. Ex: The cost of gold is a function of its weight.

3 Functions Functions are represented by cloud diagrams. XtXt f(x) f(t)

4 Functions Ex1: If f(x)=x+2 is used as a formula that defines a function from {-1,0,1,2} to {1,2,3,4}, what relation defines f?? Solution: f = {(-1,1),(0,2),(1,3),(2,4)}

5 Functions Ex2: The relation R ={(a,2),(a,3),(b,4),(c,5)} is not a function from D={a,b,c} to R={2,3,4,5}, why?

6 Functions Ex3: The relation {(a,3),(c,2)} from the domain {a,b,c} to the range {2,3,4,5} is not a function. why?

7 Functions To determine if a relation is a function: 1- each element in the domain is related to an element in the range. 2- no element in the domain is related to more than one element in the range.

8 Functions A function can have 2 or 3 variables or more. f(x,y)= xy+x^2 G(x,y,z)= x+2y+z

9 One to one functions A function is one to one (or injection) if different elements of the domain are related to different elements of the range. Ex: c a 1 23 b 4 d

10 Is the following one-to-one? Why? 1 234 a bcd

11 Onto functions A function is called onto (surjection) if each element of the range is related to at least one element in the domain. Ex: 1 23 a bcd

12 Bijection functions A function is one to one and onto (bijection) or one to one correspondence if each element in the range is related to one and only one element of the domain. Ex: a bcd 123 4

13 Functions Ex4: Determine whether each if the following is a function, if so is it onto? Is it one to one? 1- D= {a,b,c,d} R={1,2,3,4} F= { (a,1),(a,2),(b,1), (c,2), (d,3)} 2- D= {-2,-1,0,1,2} R= {0,1,4} F(x)=x^2 3- D= {-2,-1,0,1,2} R= {0,1,2,3,4} F(x)=x^2 4- D= {0,1,2} R= {0,1,4} F(x)=x^2

14 The image of a function The set of range values actually related to some domain elements is called the image of a function.

15 Sequences, n-tuples and sums A function whose domain is a set of consecutive integers is called a sequence. Ex: If s (i)=i for each i>=0, then s is a sequence. Si is the ith term of the sequence.

16 Sequences, n-tuples and sums Ex5: Write the third term of the sequence Si= i(i-1)+1 for i>=1 Solution: s3=3(2)+1=7

17 Sequences, n-tuples and sums Ex6: Write the first 5 terms for the sequence si=i^2+2, for i>=0 Solution: S0= 2 S1= 3 S2=6 S3=11 S4=18

18 Sequences, n-tuples and sums Ex7: Find a formula for the ith term of the sequence 1,4,9,16,25. For what values of i is your formula valid? Solution: s i =i^2, i>=1

19 Sequences, n-tuples and sums (1,2,4,9,16) is a 5-tuple. Order is important.

20 Summing Finite Sequences ∑ ai (i=m, n) = am + am+1 + am+2 +…..+an Ex8: Find ∑ i^2 (i=1, 3). Solution: 1+4+9=14 Ex9: Find ∑ 2j-1 (j=0, 4). Solution: -1+1+3+5+7=15

21 Gauss’s Formula ∑ i (i=1, n) = n(n+1)/2 Proof given in class.

22 Summing Finite Sequences Theorem: - ∑(ai+bi) (i=m,n) = ∑ ai (i=m,n) + ∑ bi (i=m,n) - ∑cai (i=m,n)= c ∑ai (i=m,n) - ∑c (i=m,n)= c(n-m+1) Theorem: The sum of the arithmetic series ∑(a*i+b) (i=1,n) = an(n+1)/2+nb *proof given in class

23 Summing Finite Sequences Ex: solve ∑(3i-1)(i=1,10)

24 Section 4.2 Cartesian graphs The Cartesian graph of a relation R consists of all points (x,y) in the plane such that x is related to y by R ( that is, (x,y) ε R or xRy). Ex: Graph of - X 2 +y 2 =1 - Y=X 2 - Y=X 3 - Y=x - Y=2 x Graphs drawn in class

25 Functions Vertical lines are used to determine whether a certain relation is a function Horizontal lines are used to determine whether a function is one to one or onto. If all vertical lines cross the graph exactly once over a certain domain then the graph is a function on that domain If the horizontal lines cross the function’s graph more than once it is not one to one. If there are horizontal lines that do not cross the function’s graph on a certain range, the function is not onto on that range.

26 Composition and Inverse The composition of function f with a function g is the relation f g (f composed with g) that contains the pair (x,y) if and only if y=f(g(x)) (f of g of x) The image of g must be a subset of the domain of f in order for f g to be defined

27 Composition and Inverse Find f(g(x)) 1- f = { (1,-1), (2,-2),(3,-3),(4,-4),(5,-5)} g= { (1,3), (2,4), (3,5)} 2- f(y) = y 3 +1 g(x)= x 1/3 3- f(x)= x 3 +1 g(x)= (x-1) 1/3

28 Composition and Inverse Ex: 454g in 1 lb 16 oz in 1lb P(x)= x/16 G(x)= 454x Find the equation that converts from ounces (oz) to pounds (lb)

29 Inverses Whenever f and g are two functions such that f(g(x))=x and g(f(y))=y for each x in the domain of g and each y in the domain of f, we say that f and g are inverses of each other, f is the inverse of g and g is the inverse of f Theorem: A function g from D to R has an inverse if and only if g is one to one. The domain of g -1 is the image of g.

30 Inverse Ex: G(x) = x 3 -1 Find the inverse and its domain

31 Inverse Theorem: If g is one to one, the points on the graph of g -1 may be obtained by interchanging the x and y coordinates of the points on the graph of g. Ex: Find the inverse of y=x 3 and its graph Ex: F(x) = 2 x is to one from R to R + Find the inverse and its graph

32 Section 4.3 ( Growth Rate of Functions) Algorithm smallest Input: a list of numbers in any order Output: a list of the same numbers with the smallest first Steps: For i from 2 to n do: If (the number in position i < the number in position 1) Then exchange both numbers Example: apply algorithm on 5,2,1,3 and on 5,4,3,2 for the worst case - Find the total time taken by the algorithm

33 Quadratic time algorithms Selection Sort For(i=0; i<=n-2; i++) { L= min-position(iteration,n-1); Exchange (list [iteration], list [L]); } - Apply on 8,2,4,0,1,3 - Find the total time taken by the algorithm

34 Growth Rate of Functions We say that f is a big O of g, or f(x) = O(g(x)), If there is a constant c>0 and a number N such that for all x>N, f(x) <= c.g(x) Ex: f(x)= x 2 g(x)= x 3 Show that f(x) = O(g(x))

35 Growth Rate of Functions Consider F(n) = 3n 2 +2n G(n)= n 2 Show that f(n)= O(g(n))

36 Growth Rate of Functions If lim x  ∞ g(x)/f(x) = ∞ Then g(x) is not O(f(x)) If lim x  ∞ g(x)/f(x) = 0 Then g(x)=O(f(x)), but not vise versa If lim x  ∞ g(x)/f(x) = c, where c is constant ≠ 0 Then f(x)=O(g(x)) and g(x)=O(f(x))

37 Growth Rate of Functions Ex: f(x)= 10x G(x)= x 2 H(x)=x 3 Is f(x) = O(g(x))? Is G(x)=O(h(x))? Is G(x)=O(f(x))?

38 Growth Rate of Functions Ex: F(x)=2x G(x)=4x

39 Growth Rate of Functions Theorem For any real number r, x= O(2 x ) and 1- 2 x is not O(x r ) 2- logx = O(x r ) 3- x r is not O(logx)

40 Growth Rate of Functions Ex: F(x)= x x G(x)= x 2x

41 Growth Rate of Functions 1- constants 2- log(log(x)) 3- log(x) 4- (log(x)) n 5- (x) 1/k 6- x 7- x 2 8- x n 9- 2 x 10- x!

42 Theorem F(x) is of order g(x) means that f(x)= O(g(x)) and g(x)= O(f(x)) Ex: Which of the following functions are O(x 2 ) and which of them are of order x 2 ? - f(x) = 2x(x) 1/2 - f(x)= x 2 +(x) 1/2 - F(x)=x 3 +(x) 1/2 - F(x)=(x 3 +1)/x


Download ppt "Chapter Four Functions. Section 4.1 A function from a set D to set R (f: D  R) is a relation from D to R such that each x in D is related to one and."

Similar presentations


Ads by Google