Reading preferences
Optional display controls need JavaScript. All reading content and navigation work without it.
How to use Read
This page follows the source chapter in ordinary reading order. Equations remain native MathML so compatible screen readers and braille systems can navigate their internal structure. Each small source link returns to the exact source line.
Basics
Definition: Function
A function source 29 is a mapping of each element of source 30 to an element of source 30.
We call source 32 the domain of source 32 and source 32 the codomain of source 33. The elements of source 33 are called inputs or arguments of source 34, and the element of source 34 that is paired with an argument source 34 by source 35 is called the value of source 35 for argument source 35, written source 36.
The range source 38 of source 38 is the subset of the codomain consisting of the values of source 39 for some argument; source 39.
The diagram in Figure: Function from a three-element domain to a four-element codomain may help to think about functions. The ellipse on the left represents the function's domain; the ellipse on the right represents the function's codomain; and an arrow points from an argument in the domain to the corresponding value in the codomain.
Three domain elements each have exactly one outgoing arrow. All three arrows end at the same codomain element, leaving three codomain elements unused.
- Domain: three elements.
- Codomain: four elements.
- Mapping: three arrows, one from each domain element; one codomain element receives all three arrows and the other three receive none.
Example: Multiplication on natural numbers
Multiplication takes pairs of natural numbers as inputs and maps them to natural numbers as outputs, so goes from source 59 (the domain) to source 60 (the codomain). As it turns out, the range is also source 61, since every source 61 is source 61.
Example: Multiplication and square-root mappings
Multiplication is a function because it pairs each input—each pair of natural numbers—with a single output: source 66. By contrast, mapping a natural number source 67 to a real source 67 such that source 68 is not functional, since each positive integer source 68 has two square roots: source 69 and source 69. We can make it functional by only returning the positive square root: source 70.
Example: Student grades and parents
The relation that pairs each student in a class with their final grade is a function—no student can get two different final grades in the same class. The relation that pairs each student in a class with their parents is not a function: students can have zero, or two, or more parents.
Example: Successor function and its range
Let source 93 be defined such that source 93. This is a definition that specifies source 94 as a function which takes in natural numbers and outputs natural numbers. It tells us that, given a natural number source 96, source 96 will output its successor source 96. In this case, the codomain source 97 is not the range of source 97, since the natural number source 98 is not the successor of any natural number. The range of source 99 is the set of all positive integers, source 99.
Example: Extensionally equal successor functions
Let source 103 be defined such that source 103. This tells us that source 104 is a function which takes in natural numbers and outputs natural numbers. Given a natural number source 105, source 105 will output the predecessor of the successor of the successor of source 106, i.e., source 107.
Example: Function defined by even and odd cases
We can also define functions by cases. For instance, we could define source 125 by source 126 Since every natural number is either even or odd, the output of this function will always be a natural number. Just remember that if you define a function by cases, every possible input must fall into exactly one case. In some cases, this will require a proof that the cases are exhaustive and exclusive.
Kinds of Functions
Definition: Surjective function
A function source 30 is surjective iff source 30 is also the range of source 31, i.e., for every source 31 there is at least one source 32 such that source 32, or in symbols: source 33 We call such a function a surjection from source 36 to source 36.
Definition: Injective function
A function source 65 is injective iff for each source 66 there is at most one source 66 such that source 66. We call such a function a injection from source 67 to source 67.
Example: Injective and surjective combinations
The constant function source 77 given by source 77 is neither injective, nor surjective.
The identity function source 80 given by source 80 is both injective and surjective.
The successor function source 83 given by source 83 is injective but not surjective.
The function source 86 defined by: source 87 is surjective, but not injective.
Definition: Bijection
A function source 113 is bijective iff it is both surjective and injective. We call such a function a bijection from source 115 to source 115 (or between source 115 and source 115).
Functions as Relations
Definition: Graph of a function
Let source 24 be a function. The graph of source 25 is the relation source 25 defined by source 27
Proposition: Relations that are function graphs
Let source 43 be such that:
Then source 49 is the graph of the function source 49 defined by source 50 iff source 50.
Proof
Suppose there is a source 54 such that source 54. If there were another source 54 such that source 55, the condition on source 55 would be violated. Hence, if there is a source 56 such that source 56, this source 56 is unique, and so source 56 is well-defined. Obviously, source 57.
End of proof.
Definition: Function restriction and image
Let source 79 be a function with source 79.
The restriction of source 81 to source 81 is the function source 82 defined by source 83 for all source 83. In other words, source 84.
The application of source 87 to source 87 is source 87. We also call this the image of source 88 under source 89.
Inverses of Functions
Definition: Inverse function
A function source 28 is an inverse of a function source 28 if source 29 and source 29 for all source 29 and source 30.
If source 33 has an inverse source 33, we often write source 33 instead of source 33.
Proposition: Injective functions have left inverses
If source 63 is injective, then there is a left inverse source 64 of source 64 so that source 64 for all source 64.
Proof
Suppose that source 69 is injective. Consider a source 69. If source 70, there is an source 70 so that source 70. Because source 71 is injective, there is only one such source 71. Then we can define: source 72, i.e., source 72 is “the” source 72 such that source 72. If source 73, we can map it to any source 73. So, we can pick an source 74 and define source 74 by: source 75 It is defined for all source 81, since for each such source 81 there is exactly one source 82 such that source 82. By definition, if source 83, then source 83, i.e., source 83.
End of proof.
Exercise: A left inverse implies injectivity
Show that if source 87 has a left inverse source 87, then source 87 is injective.
Proposition: Surjective functions have right inverses
If source 92 is surjective, then there is a right inverse source 93 of source 93 so that source 93 for all source 94.
Proof
Suppose that source 98 is surjective. Consider a source 98. Since source 99 is surjective, there is an source 99 with source 99. Then we can define: source 100, i.e., for each source 100 we choose some source 101 so that source 101; since source 101 is surjective there is always at least one to choose from. Note: Since source 102 is surjective, for every source 103 the set source 103 is nonempty. Our definition of source 104 requires that we choose a single source 104 from each of these sets. That this is always possible is actually not obvious—the possibility of making these choices is simply assumed as an axiom. In other words, this proposition assumes the so-called Axiom of Choice, an issue we will revisit in the Choice chapter. However, in many specific cases, e.g., when source 109 or is finite, or when source 109 is bijective, the Axiom of Choice is not required. (In the particular case when source 110 is bijective, for each source 110 the set source 111 has exactly one element, so that there is no choice to make.) By definition, if source 112, then source 113, i.e., for any source 113, source 113.
End of proof.
Exercise: A right inverse implies surjectivity
Show that if source 117 has a right inverse source 117, then source 117 is surjective.
Proposition: Bijective functions have inverses
If source 128 is bijective, there is a function source 129 so that for all source 129, source 130 and for all source 130, source 130.
Proof
Exercise.
End of proof.
Exercise: Construct the inverse of a bijection
Prove Proposition: Bijective functions have inverses. You have to define source 139, show that it is a function, and show that it is an inverse of source 140, i.e., source 140 and source 140 for all source 141 and source 141.
Proposition: Left and right inverses coincide
Show that if source 155 has a left inverse source 155 and a right inverse source 156, then source 156.
Proof
Exercise.
End of proof.
Exercise: Prove left and right inverses coincide
Proposition: Inverses are unique
Every function source 168 has at most one inverse.
Proof
Suppose source 172 and source 172 are both inverses of source 172. Then in particular source 173 is a left inverse of source 173 and source 173 is a right inverse. By Proposition: Left and right inverses coincide, source 174.
End of proof.
Composition of Functions
Definition: Composition
Let source 40 and source 40 be functions. The composition of source 41 with source 41 is source 41, where source 42.
Example: Composing successor and doubling
Consider the functions source 46, and source 46. Since source 47, for each input source 47 you must first take its successor, then multiply the result by two. So their composition is given by source 49.
Exercise: Composition preserves injectivity
Show that if source 53 and source 53 are both injective, then source 54 is injective.
Exercise: Composition preserves surjectivity
Show that if source 58 and source 58 are both surjective, then source 59 is surjective.
Exercise: Graph of a composite function
Suppose source 63 and source 63. Show that the graph of source 64 is source 64.
Partial Functions
Definition: Partial function and its domain
A partial function source 21 is a mapping which assigns to every element of source 22 at most one element of source 22. If source 23 assigns an element of source 23 to source 23, we say source 23 is defined, and otherwise undefined. If source 24 is defined, we write source 25, otherwise source 25. The domain of a partial function source 26 is the subset of source 26 where it is defined, i.e., source 27.
Example: Total functions as partial functions
Every function source 31 is also a partial function. Partial functions that are defined everywhere on source 32—i.e., what we so far have simply called a function—are also called total functions.
Example: Reciprocal as a partial function
The partial function source 38 given by source 38 is undefined for source 39, and defined everywhere else.
Exercise: Partial inverse of a partial function
Given source 43, define the partial function source 43 by: for any source 44, if there is a unique source 44 such that source 45, then source 45; otherwise source 45. Show that if source 46 is injective, then source 46 for all source 46, and source 47 for all source 47.
Definition: Graph of a partial function
Let source 51 be a partial function. The graph of source 51 is the relation source 52 defined by source 53
Proposition: Single-valued relations define partial functions
Suppose source 59 has the property that whenever source 59 and source 60 then source 60. Then source 60 is the graph of the partial function source 61 defined by: if there is a source 61 such that source 62, then source 62, otherwise source 62. If source 62 is also serial, i.e., for each source 63 there is a source 63 such that source 64, then source 64 is total.
Proof
Suppose there is a source 68 such that source 68. If there were another source 68 such that source 69, the condition on source 69 would be violated. Hence, if there is a source 70 such that source 70, that source 70 is unique, and so source 71 is well-defined. Obviously, source 71 and source 71 is total if source 72 is serial.
End of proof.