Notice that in the grades example, A had two elements map to it, while F had none. We can classify functions based on such situations.
Injectivity
A function f is said to be injective or one-to-one if (f(x)=f(y))→(x=y) for all x and y in the domain of f. The function is said to be an injection.
Recall that, by contraposition, (f(x)=f(y))→(x=y) if and only if (x≠y)→(f(x)≠f(y)).
Basically, this means that each element of the range has exactly one pre-image. Equivalently, each element of the codomain has at most one pre-image. In a function diagram, this means there is at most one incoming arrow to every element on the right hand side.
To show a function is injective:
- assume f(x)=f(y) and show that x=y, or
- assume x≠y and show that f(x)≠f(y)
To show a function is not injective, give an x and y such that x≠y but f(x)=f(y).
Here are some examples:
-
The function on the left is injective, but the function on the right is not:
- f:Z→Z defined by f(x)=3x+2 is injective. To see this, assume f(x)=f(y). Then: 3x+2=3y+23x=3yx=y
- The previous proof falls apart for f(x)=x2: x2=y2√x2=√y2±x=±y which is not the same thing as x=y! Indeed, f(x)=x2 is not injective since f(1)=1=f(−1) and 1≠−1.
Surjectivity
A function f:A→B is said to be surjective or onto if for every element b∈B, there is an element a∈A such that f(a)=b. The function is said to be a surjection.
Basically, this means that every element of the codomain has a pre-image. Equivalently, the codomain and range are the same. In a function diagram, this means there is at least one incoming arrow to every element on the right hand side.
To show a function is surjective, start with an arbitrary element b∈B and show what the preimage of b could be: show an a∈A such that f(a)=b. To show a function is not surjective, give a b such that f(a)≠b for any a∈A.
Here are some examples:-
The function on the left is surjective, but the function on the right is not:
- f:Z→Z defined by f(x)=x2 is not surjective, since there is no x such that x2=−1 where x is an integer.
- f:R→R defined by f(x)=3x+2 is surjective. To see this, suppose we have image 3x+2=y. To determine which pre-image gives this, observe that 3x+2=y is the same as 3x=y−2, which is the same as x=(y−2)/3. So, to get an output of y, give input (y−2)/3.
Notice that:
- injective ↔ at most one image
- surjective ↔ at least one image
If a function is both injective and surjective, then each element of the domain is mapped to a unique element of the codomain (range). A function that is both injective and surjective is bijective. Such a function is called a bijection.
To show a function is bijective, show:
- it is injective (using the above techniques)
- it is surjective (using the above techniques)
Remember to show both parts, since functions can be any combination of injective and surjective. For example, from left-to-right, the following functions are injective but not surjective, surjective but not injective, injective and surjective, and neither injective nor surjective:
Inverse of a Function
If a function f is bijective, then f is invertible. Its inverse is denoted f−1 and assigns to b∈B the unique element a∈A such that f(a)=b: that is, f−1(b)=a↔f(a)=b.
Inverses are not defined for functions that are not bijections.
- if f is not injective, then some b has two pre-images. Thus, f−1(b) would have more than one value and therefore f−1 would not be a function
- if f is not surjective, then some b has no pre-image. Thus, f−1(b) would have no value and therefore f−1 would not be a function
The inverse can be found by reversing the arrows in the diagram, or by isolating the other variable in the formula. Note that the inverse of f:A→B is f−1:B→A.
Here are some examples of functions and their inverses:
-
Consider the following function:
The function is injective and surjective and therefore bijective and invertible. We have f−1(1)=c,f−1(2)=a,f−1(3)=b. - f:Z→Z defined by f(x)=3x+2 is bijective as we have already seen and is thus invertible. We know that 3x+2=y↔3x=y−2↔x=y−23. Therefore, f−1(x)=x−13. (Note: it doesn't matter what variable you use, as long as you are consistent!)
- f:Z→Z defined by f(x)=x2 is not invertible since it is not surjective.
Composition of Functions
Given two functions f and g, we can use the output of one as the input to the other to create a new function f(g(x)). In this function, we evaluate g with input x and give the result to f to compute the final output.
Let f:B→C and g:A→B. The composition of f and g is denoted f∘g (read "f follows g") and is defined as (f∘g)(x)=f(g(x)). Note: for f∘g to be defined, the range of g must be a subset of the domain of f.
Graphically, we have:
Here are some examples:
-
Define g:{a,b,c}→{a,b,c} and f:{a,b,c}→{1,2,3} in the following way:
- g(a)=b,g(b)=c,g(c)=a
- f(a)=3,f(b)=2,f(c)=1
- (f∘g)(a)=f(g(a))=f(b)=2
- (f∘g)(b)=f(g(b))=f(c)=1
- (f∘g)(c)=f(g(c))=f(a)=3
- Define f:Z→Z and g:Z→Z by f(x)=2x+3 and g(x)=3x+2. Then: (f∘g)(x)=f(g(x))=f(3x+2)=2(3x+2)+3=6x+4+3=6x+7 and (g∘f)(x)=g(f(x))=g(2x+3)=3(2x+3)+2=6x+9+2=6x+11 In general, f∘g≠g∘f!
One important case is composing a function with its inverse: Suppose f(a)=b. Then f−1(b)=a, and:
- (f−1∘f)(a)=f−1(f(a))=f−1(b)=a
- (f∘f−1)(b)=f(f−1(b))=f(a)=b