If A and B are sets, then a function f from A to B, written , is a rule that associates to each element x in A a unique element denoted f(x) in B. The element f(x) is called the image of x (under f), and x is called a preimage of f(x) (under f). If , then A is called the domain of f, B is called the codomain of f, and the set is called the range of f. Note that the range of f is a subset of B. If , we denote by f(S) the set of all images of elements of S. Likewise, if , we denote by the set of all preimages of elements in T. Finally, two functions and are equal, written , if for all .
Suppose that . Let be the function that assigns to each element x in A the element in R; that is, f is defined by . Then A is the domain of f, R is the codomain of f, and [1, 101] is the range of f. Since , the image of 2 is 5, and 2 is a preimage of 5. Notice that is another preimage of 5. Moreover, if and , then and .
As Example 1 shows, the preimage of an element in the range need not be unique. Functions such that each element of the range has a unique preimage are called one-to-one; that is is one-to-one if implies or, equivalently, if implies .
If is a function with range B, that is, if , then f is called onto. So f is onto if and only if the range of f equals the codomain of f.
Let be a function and . Then a function , called the restriction of f to S, can be formed by defining for each .
The next example illustrates these concepts.
Let be defined by . This function is onto, but not one-to-one since . Note that if , then is both onto and one-to-one. Finally, if , then is one-to-one, but not onto.
Let A, B, and C be sets and and be functions. By following f with g, we obtain a function called the composite of g and f. Thus for all . For example, let , and . Then , whereas . Hence, . Functional composition is associative, however; that is, if is another function, then .
A function is said to be invertible if there exists a function such that for all and for all . If such a function g exists, then it is unique and is called the inverse of f. We denote the inverse of f (when it exists) by . It can be shown that f is invertible if and only if f is both one-to-one and onto.
The function defined by is one-to-one and onto; hence f is invertible. The inverse of f is the function defined by .
The following facts about invertible functions are easily proved.
If is invertible, then is invertible, and .
If and are invertible, then is invertible, and .