Functions
(Content adapted from Critchlow & Eck)
Both the real world and the world of mathematics are full of what are called, in mathematics, "functional relationships." A functional relationship is a relationship between two sets, which associates exactly one element from the second set to each element of the first set.
For example, each item for sale in a store has a price. The first set in this relationship is the set of items in the store. For each item in the store, there is an associated price, so the second set in the relationship is the set of possible prices. The relationship is a functional relationship because each item has a price. That is, the question "What is the price of this item?" has a single, definite answer for each item in the store.
Similarly, the question "Who is the (biological) mother of this person?" has a single, definite answer for each person. So, the relationship "mother of" defines a functional relationship. In this case, the two sets in the relationship are the same set, namely the set of people.1 On the other hand, the relationship "child of" is not a functional relationship. The question "Who is the child of this person?" does not have a single, definite answer for each person. A given person might not have any child at all. And a given person might have more than one child. Either of these cases—a person with no child or a person with more than one child—is enough to show that the relationship "child of" is not a functional relationship.
Or consider an ordinary map, such as a map of New York State or a street map of Rome. The whole point of the map, if it is accurate, is that there is a functional relationship between points on the map and points on the surface of the Earth. Perhaps because of this example, a functional relationship is sometimes called a mapping.
There are also many natural examples of functional relationships in mathematics. For example, every rectangle has an associated area. This fact expresses a functional relationship between the set of rectangles and the set of numbers. Every natural number has a square, . The relationship "square of" is a functional relationship from the set of natural numbers to itself.
In mathematics, of course, we need to work with functional relationships in the abstract. To do this, we introduce the idea of function. You should think of a function as a mathematical object that expresses a functional relationship between two sets. The notation expresses the fact that is a function from the set to the set . That is, is a name for a mathematical object that expresses a functional relationship from the set to the set . The notation is read as " is a function from to " or more simply as " maps to ."
If and if , the fact that is a functional relationship from to means that associates some element of to . That element is denoted . That is, for each , and is the single, definite answer to the question "What element of is associated to by the function ?" The fact that is a function from to means that this question has a single, well-defined answer. Given , is called the value of the function at .
For example, if is the set of items for sale in a given store and is the set of possible prices, then there is function which is defined by the fact that for each , is the price of the item . Similarly, if is the set of people, then there is a function such that for each person , is the mother of . And if is the set of natural numbers, then the formula specifies a function . It is in the form of formulas such as or that most people first encounter functions. But you should note that a formula by itself is not a function, although it might well specify a function between two given sets of numbers. Functions are much more general than formulas, and they apply to all kinds of sets, not just to sets of numbers.
Composition
Suppose that and are functions. Given , there is an associated element . Since is a function from to , and since , associates some element of to . That element is . Starting with an element of , we have produced an associated element of . This means that we have defined a new function from the set to the set . This function is called the composition of with , and it is denoted by . That is, if and are functions, then is the function which is defined by
for each . For example, suppose that is the function that associates to each item in a store the price of the item, and suppose that is a function that associates the amount of tax on a price to each possible price. The composition, , is the function that associates to each item the amount of tax on that item. Or suppose that and are the functions defined by the formulas and , for each . Then is a function from to , and for , . In this case, we also have the function , which satisfies . Note in particular that and are not the same function. The operation is not commutative.
If is a set and , then , the composition of with itself, is defined. For example, using the function from the preceding example, is the function from to given by the formula . If is the function from the set of people to itself which associates to each person that person's mother, then is the function that associates to each person that person's maternal grandmother.
Pairs
If and are entities, then denotes the ordered pair containing and . The ordered pair differs from the set because a set is not ordered. That is, and denote the same set, but if , then and are different ordered pairs. More generally, two ordered pairs and are equal if and only if both and . If is an ordered pair, then and are referred to as the coordinates of the ordered pair. In particular, is the first coordinate and is the second coordinate.
If and are sets, then we can form the set which is defined by
This set is called the cross product or Cartesian product of the sets and . The set contains every ordered pair whose first coordinate is an element of and whose second coordinate is an element of . For example, if and , then . It is possible to extend this idea to the cross product of more than two sets. The cross product of the three sets , , and is denoted . It consists of all ordered triples where , , and . The definition for four or more sets is similar. The general term for a member of a cross product is tuple or, more specifically, ordered n-tuple. For example, is an ordered 5-tuple.
Given a function , consider the set . This set of ordered pairs consists of all pairs such that and is the element of that is associated to by the function . The set is called the graph of the function . Since is a function, each element occurs once and only once as a first coordinate among the ordered pairs in the graph of . Given , we can determine by finding that ordered pair and looking at the second coordinate. In fact, it is convenient to consider the function and its graph to be the same thing, and to use this as our official mathematical definition.2
Let and be sets. A function from to is a subset of which has the property that for each , the set contains one and only one ordered pair whose first coordinate is . If is that ordered pair, then is called the value of the function at and is denoted . If , then we also say that the function maps to . The fact that is a function from to is indicated by the notation .
For example, if and , then the set is a function from to , and is a function from to . On the other hand, is not a function from to , since it does not specify any value for 3. And is not a function from to because it specifies two different values, 1 and 2, associated with the same element, , of .
Even though the technical definition of a function is a set of ordered pairs, it's usually better to think of a function from to as something that associates some element of to every element of . The set of ordered pairs is one way of expressing this association. If the association is expressed in some other way, it's easy to write down the set of ordered pairs. For example, the function which is specified by the formula can be written as the set of ordered pairs .
Additional Concepts
Suppose that is a function from the set to the set . We say that is the domain of the function and that is the range of the function. We define the image of the function to be the set . Put more simply, the image of is the set . That is, the image is the set of all values, , of the function, for all . (You should note that in some cases—particularly in calculus courses—the term "range" is used to refer to what I am calling the image.) For example, for the function that is specified by , both the domain and the range are , and the image is the set , or .
Note that the image of a function is a subset of its range. It can be a proper subset, as in the above example, but it is also possible for the image of a function to be equal to the range. In that case, the function is said to be onto. Sometimes, the fancier term surjective is used instead. Formally, a function is said to be onto (or surjective) if every element of is equal to for some element of . In terms of logic, is onto if and only if
For example, let and , and consider the function from to specified by the set of ordered pairs . This function is onto because its image, , is equal to the range, . However, the function from to given by is not onto, because its image, , is a proper subset of its range, . As a further example, consider the function from to given by . To show that is onto, we need to pick an arbitrary in the range and show that there is some number in the domain such that . So let be an arbitrary integer; we want to find an such that . Clearly this equation will be true when . So every element is the image of the number , and is therefore onto. Note that if had been specified to have domain , then would not be onto, as for some the number is not in the domain (for example, the integer is not in the image of , since is not in .)
If and if , then is associated to only one element of . This is part of the definition of a function. However, no such restriction holds for elements of . If , it is possible for to be associated to zero, one, two, three, …, or even to an infinite number of elements of . In the case where each element of the range is associated to at most one element of the domain, the function is said to be one-to-one. Sometimes, the term injective is used instead. The function is one-to-one (or injective) if for any two distinct elements and in the domain of , and are also distinct. In terms of logic, is one-to-one if and only if
Since a proposition is equivalent to its contrapositive, we can write this condition equivalently as
Sometimes, it is easier to work with the definition of one-to-one when it is expressed in this form. The function that associates every person to his or her mother is not one-to-one because it is possible for two different people to have the same mother. The function specified by is one-to-one. However, we can define a function by the same formula: , for . The function is not one-to-one since two different integers can have the same square. For example, .
A function that is both one-to-one and onto is said to be bijective. The function that associates each point in a map of New York State to a point in the state itself is presumably bijective. For each point on the map, there is a corresponding point in the state, and vice versa. If we specify the function from the set to the set as the set of ordered pairs , then is a bijective function. Or consider the function from to given by . We have already shown that is onto. We can show that it is also one-to-one: pick an arbitrary and in and assume that . This means that , and adding 52 to both sides of the equation gives . Since and were arbitrary, we have proved , that is, that is one-to-one. Altogether, then, is a bijection.
First-Class Functions
One difficulty that people sometimes have with mathematics is its generality. A set is a collection of entities, but an "entity" can be anything at all, including other sets. Once we have defined ordered pairs, we can use ordered pairs as elements of sets. We could also make ordered pairs of sets. Now that we have defined functions, every function is itself an entity. This means that we can have sets that contain functions. We can even have a function whose domain and range are sets of functions. Similarly, the domain or range of a function might be a set of sets, or a set of ordered pairs. Computer scientists have a good name for this. They would say that sets, ordered pairs, and functions are first-class objects. Once a set, ordered pair, or function has been defined, it can be used just like any other entity. If they were not first-class objects, there could be restrictions on the way they can be used. For example, it might not be possible to use functions as members of sets. (This would make them "second class.")
For example, suppose that , , and are sets. Then since is a set, we might have a function . If , then the value of at would be denoted . In practice, though, one set of parentheses is usually dropped, and the value of at is denoted . As a particular example, we might define a function with the formula . Similarly, we might define a function by .
Suppose that and are sets. There are, in general, many functions that map to . We can gather all those functions into a set. This set, whose elements are all the functions from to , is denoted . (We'll see later why this notation is reasonable.) Using this notation, saying is exactly the same as saying . Both of these notations assert that is a function from to . Of course, we can also form an unlimited number of other sets, such as the power set , the cross product , or the set , which contains all the functions from the set to the set . And of course, any of these sets can be the domain or range of a function. An example of this is the function defined by the formula . Let's see if we can make sense of this notation. Since the domain of is , an element in the domain is an ordered pair in which the first coordinate is a function from to and the second coordinate is an element of . Thus, is defined for a function and an element . Given such an and , the notation specifies an element of , so the definition of as makes sense. The function is called the "evaluation function" since it captures the idea of evaluating a function at an element of its domain.
Exercises
Let and let . Find the sets and .
Answer
Let be the set . Let be the function from to given by the set of ordered pairs , and let be the function given by the set of ordered pairs . Find the set of ordered pairs for the composition .
Answer
, , , and , so the ordered pairs are .
Let and let . Find all possible functions from to . Give each function as a set of ordered pairs. (Hint: Every such function corresponds to one of the subsets of .)
Answer
Given a subset , the characteristic function of is the function from to defined by . Conversely, given a function from to , we may find a subset of whose characteristic function is by taking the set of elements of that are mapped to 1 by (this is known as the inverse image, ). Here are the subsets along with their corresponding characteristic functions:
Consider the functions from to which are defined by the following formulas. Decide whether each function is onto and whether it is one-to-one; prove your answers.
Answer
is one-to-one, because if , then , hence . is not onto, because the image of is only the even integers.
Answer
is both one-to-one and onto; given any , there is exactly one (namely, ) such that .
Answer
is neither one-to-one nor onto. In particular, , and there is no such that .
- , if is even, and , if is odd
Answer
is onto, because given any we may see that . is not one-to-one, because .
Prove that composition of functions is an associative operation. That is, prove that for functions , , and , the compositions and are equal.
Answer
It is enough to observe that, for any , the compositions and both evaluate to .
Suppose that and are functions and that is one-to-one.
- Prove that is one-to-one. (Hint: use a proof by contradiction.)
Answer
Suppose we had distinct elements and in such that . Then we would also have that , so would agree on and . But is one-to-one, so that is a contradiction. Therefore, there must not be such elements in , hence is one-to-one.
- Find a specific example that shows that is not necessarily one-to-one.
Answer
Consider functions on the integers (), and let and if is even, if is odd. Then is the identity function, which is one-to-one, but is clearly not one-to-one.
- Prove that is one-to-one. (Hint: use a proof by contradiction.)
Suppose that and , and suppose that the composition is an onto function.
- Prove that is an onto function.
Answer
Given any , the fact that is onto means that we can find a such that . But that means that we have an element of , namely , which maps onto . Since we can do this for any element of , the function is onto.
- Find a specific example that shows that is not necessarily onto.
Answer
Consider functions on the integers (), and let and if is even, if is odd. Then is the identity function, which is onto, but is clearly not onto.
- Prove that is an onto function.
- I'm avoiding here the question of Adam and Eve or of pre-human ape-like ancestors. (Take your pick.)↩
- This is a convenient definition for the mathematical world, but as is often the case in mathematics, it leaves out an awful lot of the real world. Functional relationships in the real world are meaningful, but we model them in mathematics with meaningless sets of ordered pairs. We do this for the usual reason: to have something precise and rigorous enough that we can make logical deductions and prove things about it.↩