420 likes | 492 Views
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 only one y in R. D is called the domain of the function and R is called the range of the function.
E N D
Chapter Four Functions
Section 4.1 • A function from a set D to set R (f: DR) 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.
Functions • Functions are represented by cloud diagrams. f(x) f(t) X t
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)}
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?
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?
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.
Functions • A function can have 2 or 3 variables or more. f(x,y)= xy+x^2 G(x,y,z)= x+2y+z
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: 2 3 4 1 a b c d
Ex: Is the following one-to-one? Why? 2 3 4 1 a b c d
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: 2 3 1 a b c d
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: 4 1 2 3 a b c d
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
The image of a function • The set of range values actually related to some domain elements is called the image of a function.
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.
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
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
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: si=i^2, i>=1
Sequences, n-tuples and sums • (1,2,4,9,16) is a 5-tuple. • Order is important.
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
Gauss’s Formula • ∑ i (i=1, n) = n(n+1)/2 Proof given in class.
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
Summing Finite Sequences • Ex: solve ∑(3i-1)(i=1,10)
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 • X2+y2 =1 • Y=X2 • Y=X3 • Y=x • Y=2x Graphs drawn in class
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.
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
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) = y3+1 g(x)= x 1/3 3- f(x)= x3+1 g(x)= (x-1)1/3
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 grams (gm)
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.
Inverse • Ex: G(x) = x3 -1 Find the inverse and its domain
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=x3 and its graph Ex: F(x) = 2x is to one from R to R+ Find the inverse and its graph
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
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
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)= x2 g(x)= x3 Show that f(x) = O(g(x))
Growth Rate of Functions • Consider F(n) = 3n2+2n G(n)= n2 Show that f(n)= O(g(n))
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))
Growth Rate of Functions Ex: f(x)= 10x G(x)= x2 H(x)=x3 Is f(x) = O(g(x))? Is G(x)=O(h(x))? Is G(x)=O(f(x))?
Growth Rate of Functions • Ex: F(x)=2x G(x)=4x
Growth Rate of Functions • Theorem For any real number r, x= O(2x) and 1- 2x is not O(xr) 2- logx = O(xr) 3- xr is not O(logx)
Growth Rate of Functions • Ex: F(x)= xx G(x)= x2x
Growth Rate of Functions 1- constants 2- log(log(x)) 3- log(x) 4- (log(x))n 5- (x)1/k 6- x 7- x2 8- xn 9- 2x 10- x!
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(x2) and which of them are of order x2? • f(x) = 2x(x)1/2 • f(x)= x2+(x)1/2 • F(x)=x3+(x)1/2 • F(x)=(x3+1)/x