Upload
amia-hogan
View
231
Download
3
Embed Size (px)
Citation preview
CHAPTER 7 Functions
FunctionsReading: Epp Chp 7.1, 7.2, 7.4
Overview
Functions– Definition– Visualization Tool– Examples– Notation– Identity Function
Definitions– Domain, codomain,
range– Image, inverse image– Let f:A B and let S
A and T B.• S InvImgf(Imgf(S))• Imgf(InvImgf(T)) T
Operations on Functions– Set related (,,):
1. If fg is a function, then f = g
2. If fg is a function, then f = g
3. If fg is a function, then fg=
– Inverse One-to-one and Onto
Functions
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
A function is a relation. It’s just a special kind of relation – a relation with 2 restrictions.
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
1. Every element in A must be associated with AT LEAST one element in B.
Extract the meaning from the logical expression.
A BR
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
2. An element in A can only be associated with AT MOST one element in B.
Extract the meaning from the logical expression.
A BR
1. Definition: Function
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
1 and 2 taken together: Every element in A can only be associated with EXACTLY ONE element in B.
Extract the meaning from the logical expression.
A BR
2. Visualisation Tool: Arrow Diagram
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
A Bf
Not a function
2. Visualisation Tool: Arrow Diagram
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Yes, it’s a function.
A Bf
2. Visualisation Tool: Arrow Diagram
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Not a function
A Bf
3. Examples
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Example 1:
Is R a function?
No. (Cond 1)
No. (Cond 2)
Yes.
R = {(1,2)}
R A x BA
{1,2,3}
B
{1,2,3}
R = {(1,2),(2,3),(1,3)}{1,2,3} {1,2,3}
R = {(1,1),(2,1),(3,1)}{1,2,3} {1,2,3}
{1,2,3,4} {1,2,3} R = {(1,1),(2,2),(3,3)} No. (Cond 1)
{1,2,3} {1,2,3,4} R = {(1,1),(2,2),(3,3)} Yes.
3. Examples
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Example 2: Let R Q x Z such that…
(i) x R y iff x = y.
Q: Is R a function?
A: No (1st Condition: ½ maps to nothing)
Q Z
½ ?
(ii) (a/b) R c iff a.b = c.
Q: Is R a function?
A: Yes
3. Examples
Given a relation R from a set A to a set B, R is a function iff1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1 = y2.
Example 3: Let R Z x Z such that…
(i) x R y iff y = x2.
Q: Is R a function?
A: Yes.
(ii) x R y iff x = y2.
Q: Is R a function?
A: No. (1st and 2nd Condition violated)
Z Z
3 ?
1 1
-1
3. Examples
Functions in real life:1. Hamming distance function.
2. Encoding/decoding functions.
3. Boolean functions.
4. A program is a function.
Eg. 3: F Z x {0,1}, a F b iff (a is even b=1) (a is odd b=0)
4. Notation
We usually use “f,g,h,F,G,H” to denote functions. If the relation f A x B is a function, we write it as:
f : A B If there is a way to compute yB from any given
xA, we usually write ‘f(x)’ in place of ‘y’.
We will write it as:Eg. 1: F Z x Z , x F y iff y = x2. ‘F’ is a function.
F : Z Z, F(x) = x2
We will write it as:Eg. 2: F Z x Z , x F y iff y = x2 + 2x + 1
F : Z Z, F(x) = x2 + 2x + 1
F : Z {0,1}, F(x) =
1, if x is even
0, otherwise
4. Notation
We usually use “f,g,h,F,G,H” to denote functions. If the relation f A x B is a function, we write it as:
f : A B If there is a way to compute yB from any given
xA, we usually write ‘f(x)’ in place of ‘y’.
Therefore, the definitions instead of…
1. xA, yB, x R y
2. xA, y1,y2B, x R y1 x R y2 y1=y2.
1. xA, yB, y = f(x)
2. xA, y1,y2B, y1=f(x) y2=f(x) y1=y2.
… can be also expressed as…
5. The identity function.
The identity function on any given set, is a function that maps every element to itself.
idA : A A, xA, idA(x) = x
Overview
Functions– Definition– Visualization Tool– Examples– Notation– Identity Function
Definitions– Domain, codomain,
range– Image, inverse image– Let f:A B and let S A
and T B.• S InvImgf(Imgf(S))
• Imgf(InvImgf(T)) T
Operations on Functions– Set related (,,):
1. If fg is a function, then f = g
2. If fg is a function, then f = g
3. If fg is a function, then fg=
– Inverse One-to-one and Onto
Functions
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
A Bf
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
A Bf
Domain(f)
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
A Bf
Codomain(f)
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
A Bf
Range(f)
NOTE:
range(f) codomain(f)
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
Example 1: f : Z Z+, f(x) = |2x|
a. domain(f) = Z
b. codomain(f) = Z+
c. range(f) = positive even numbers: {2x | x Z+}
6. Definition: domain, codomain, range
Given a function: f : A B,– The set A is known as the domain of f.– The set B is known as the codomain of f.– The set { yB | xA, y=f(x)} is known as the
range of f.
Example 2:
Let f : Z Z, f(x) = 2x + 1; g : Z Z, g(x) = 2x - 1
Then range(f) = range(g).
Range(f) = 2x+1 = 2(x+1) – 1 = Range(g)
xZ, f(x) = g(x+1)
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)}
A Bf
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)}
S
Image of S
NOTE: Imgf(S) range(f) codomain(f)
A Bf
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)} Given a function: f : A B, and T B
– The inverse image of T is defined as:
InvImgf(T) = { xA | yT, y=f(x)}
Inverse image of T
TA B
f
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)} Given a function: f : A B, and T B
– The inverse image of T is defined as:
InvImgf(T) = { xA | yT, y=f(x)}
Example: f : Z Z+, f(x) = |x|
a. Imgf({10,-20}) = {10,20}
b. InvImgf({10,20}) = {10, 20, -10, -20}
7. Definition: Image, Inverse Image.
Given a function: f : A B, and S A– The image of S is defined as:
Imgf(S) = { yB | xS, y=f(x)}or
yImgf(S) iff xS and y=f(x)
Given a function: f : A B, and T B– The inverse image of T is defined as:
InvImgf(T) = { xA | yT, y=f(x)}or
xInvImgf(T) iff yT and y=f(x)
Axiomatic definition
7.1 Theorem: Image, Inverse Image.
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
A Bf
Proof of (1): (Use diagrams to help visualise!)
7.1 Theorem: Image, Inverse Image.
A Bf
S
Proof of (1): (Use diagrams to help visualize!)
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
7.1 Theorem: Image, Inverse Image.
A Bf
S
Proof of (1):
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
Assume xS
Therefore xInvImgf(Imgf(S))
Then yB such that y = f(x) (Since f is a function)
Therefore yImgf(S) (Defn: yImgf(S) iff xS and y=f(x))
xy
Therefore yImgf(S) and y = f(x)
Imgf(S)
7.1 Theorem: Image, Inverse Image.
A Bf
Imgf(S)
Proof of (1):
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
Assume xS
Therefore xInvImgf(Imgf(S))
Then yB such that y = f(x) (Since f is a function)
Therefore yImgf(S) (Defn: yImgf(S) iff xS and y=f(x))
Therefore yImgf(S) and y = f(x)
(Defn:xInvImgf(T) iff
yT and y=f(x))
xy
7.1 Theorem: Image, Inverse Image.
…Proof of (2) left as an exercise…
(Again, the skill that you must pick up is that you must use diagrams wherever
possible, to help visualize the problem and use it to help you reason about proofs)
Given any function: f : A B, S A, T B1. S InvImgf(Imgf(S))
2. Imgf(InvImgf(T)) T
Overview
Functions– Definition– Visualization Tool– Examples– Notation– Identity Function
Definitions– Domain, codomain,
range– Image, inverse image– Let f:A B and let S A
and T B.• S InvImgf(Imgf(S))
• Imgf(InvImgf(T)) T
Operations on Functions– Set related (,,):
1. If fg is a function, then f = g
2. If fg is a function, then f = g
3. If fg is a function, then fg=
– Inverse One-to-one and Onto
Functions
8. Operations on Functions.
A function is a (special) relation. A relation is a set (of ordered pairs). Therefore, all definitions and operations
on sets and relations are extended over to functions.
8.1 Equality of Functions
Given 2 functions, f : A B, g : A B,
f = g iff f g and g f Or, in cases where y can be computed directly
from x:
f = g iff
xA, y1=f(x) y2=g(x) y1=y2
Which is equivalent to:
f = g iff xA, f(x) = g(x)
8.2 Union, Intersection, Difference
Given 2 functions, f : A B, g : A B, f g, f g, fg are defined as accordingly in set theory (since functions are sets).…Or, in cases where y can be computed directly from x:– (fg)(x) = y iff y = f(x) or y g(x)
– (fg)(x) = y iff y = f(x) and y g(x)
– (fg)(x) = y iff y = f(x) and y g(x)
NOTE: f g, f g, fg need not necessarily be functions. At most, one can only conclude that f g, f g, fg are relations. In order to assert that they are functions, one must prove that the 2 conditions necessary for functions are true.
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (1): (Direct proof: f = g iff xA, f(x) = g(x)
A Bf
x
A Bg
x
A Bf g
x
y1
y2
y2
y1But fg is a function!
Defn:y1= (fg)(x) and y2= (fg)(x) then y1=y2.
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (1): (Direct proof: f = g iff xA, f(x) = g(x)Let xA.
Since f is a function, then y1B, y1= f(x), (x,y1)f
Since g is a function, then y2B, y2= g(x), (x,y2)g
Therefore (x,y1) f g and (x,y2) f g.
i.e. y1f g)(x) and y2 f g)(x)
But since fg is a function, then y1=y2 .
Therefore f(x) = g(x) (By definition of function equality)
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (3): (By contradiction)
A Bf g
x y
A B f
x y
A B g
x y
A B f-g
x
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (3): (By contradiction)
Assume that f g
Then by definition, (x,y) f g
That means that (x,y) f and (x,y) g
That means that (x,y) (f – g).
But f – g is a function! xA, yB, y = (f – g)(x). So there must be a (x,y) (f – g) =>
Contradiction!
Therefore f g .
8.2 Union, Intersection, Difference
Theorem: Given 2 functions f and g from A to B,1. If f g is a function, then f = g2. If f g is a function, then f = g3. If fg is a function, then f g =
Proof of (2) left as an exercise
Similar to Proof of (1).
8.3 Definition: Inverse of a function
Given a function, f : A B, the inverse of a function is defined in the same way as that of a relation:
f-1 = { (y,x) | (x,y) f }
NOTE: f-1 need not necessarily be a function. It is first and foremost, a relation. In order to assert that they are functions, one must prove that the 2 conditions necessary for functions are true. So
f-1 B x A
If f-1 is a function, then we write:
f-1 : B A
… and then say that:
f(x) = y iff f-1(y) = x
8.3 Definition: Inverse of a function
Find the inverse of the function f(x) = (1+x)/(1-x).
Ans:– Let y = (1+x)/(1-x). Express x in terms of y.
– Therefore: y – yx = 1 + x
– Therefore: y – 1 = yx + x
– Therefore: x(y+1) = y–1
– Therefore: x = (y–1)/(y+1)
– Therefore: f-1(y) = (y–1)/(y+1)
– i.e. f-1(x) = (x–1)/(x+1)
Overview
Functions– Definition– Visualization Tool– Examples– Notation– Identity Function
Definitions– Domain, codomain,
range– Image, inverse image– Let f:A B and let S A
and T B.• S InvImgf(Imgf(S))
• Imgf(InvImgf(T)) T
Operations on Functions– Set related (,,):
1. If fg is a function, then f = g
2. If fg is a function, then f = g
3. If fg is a function, then fg=
– Inverse One-to-one and Onto
Functions
Definition A function f: X → Y is one-to-one (also called injective) if and only if, for any x1, x2 X,
if f(x1) = f (x2), then x1 = x2. (Alternatively, by contraposition, if x1 x2, then f(x1) f(x2), i.e. the images of distinct elements in X are always distinct elements in Y.)
Definition A function f: X → Y is onto (also called surjective) if and only if for all y Y, there exists x X such that y = f(x). (Alternatively, every element in Y is the image of at least one element in X.)
Now let’s consider some earlier examples in light of these definitions.
One-to-One and Onto Functions
Consider the following previously-discussed functions:
1. Let X = Y = {1, 2, 3} and f: X → Y be given by f(x) = x.Then f is both one-to-one and onto, i.e. distinct elements in
X are always “mapped” to distinct elements in Y, and every element in Y is the image of an element (itself) in X.
2. Let X = {-2, -1, 0, 1, 2}, Y = {0, 1, 2, 3, 4} and f: X → Y be given by f(x) = x2. Then f is not one-to-one, since (for example) f(-2) = f(2) = 4. Also, f is not onto, since (for example) y = 3 is not the image of any x X.
3. In the arrow diagram at right,h is not one-to-one, since h(x1) = h(x3) = y3.Likewise, h is not onto, sincey2 is not the image of any element in X.
hX → Y
x1 y1
x2 y2
x3 y3
One-to-One and Onto Functions (cont’d)
r(x) = |x| r: R → R neither 1 – 1 nor onto
s(n) = (-1)n+1/n
s: Z+ → Q 1 – 1 but not onto
t(n) = n(mod 2)
t: Z → {0, 1} onto but not 1 - 1
u(x) = x1/2
u: R+ → R+
both 1 – 1 and onto
One-to-One and Onto Functions (cont’d)
Definition A function f: X → Y is a one-to-one correspondence (also called a bijection) if and only if f is both one-to-one and onto.
Of the previous examples, only 1 function is a one-to-one correspondence: u: R+ → R+ where u(x) = x1/2.
Two primary applications for one-to-one correspondences:1. They are used to prove that two sets have the same number of elements, i.e. if a 1 – 1 correspondence exists between two sets, they have the same cardinality.2. One-to-one correspondences are the only functions for which inverse functions exist.
One-to-One Correspondencesand Inverse Functions
Example Show that the odd integers have the same cardinality as the integers Z.Let O = {2k + 1 | k Z} be the set of odd integers. Define a function f: Z → O by f(k) = 2k + 1. Every member of O is therefore the image of an element in Z, i.e. f is onto. Assume f(k1) = f(k2), i.e. 2k1 + 1 = 2k2 + 1. But then k1 = k2, i.e. f is one-to-one. It follows that f is a one-to-one correspondence, and hence
n(O) = n(Z) = 0א .
One-to-One Correspondencesand Inverse Functions (cont’d)
Example Find the inverse function for f: Z → O where
f(k) = 2k + 1.The given function has just been shown to be a one-to-one correspondence. It follows that, for any n O such thatn = f(k) = 2k + 1, then k = (n – 1)/2, i.e. the required inverse function is f -1: O → Z, where f -1(n) = (n – 1)/2 = k.
f 2k+1=n f -1 (n–1)/2=k
f -1 (n–1)/2=k f 2k+1=n
One-to-One Correspondencesand Inverse Functions (cont’d)