4.1 Functions, Composition, and Inverses
Chapter 3 taught us to read definitions literally and to prove that every required condition holds. We now apply that habit to a structure you have already met informally: an input goes into a process and an output comes out.
A calculator button, a program that converts a username to an account ID, and a rule that assigns each student a graduation year all behave like functions. The word “function,” however, has a precise meaning. We will build it from the sets and ordered pairs introduced in Chapter 1.
From ordered pairs to functions
Let and be sets. Recall that the Cartesian product
contains every ordered pair whose first entry comes from and whose second entry comes from .
A relation from to is any subset of . A function from to is a special relation that satisfies two rules:
1. every element of appears as the first entry of an ordered pair;
2. each element of is paired with exactly one element of .
We write
and read it as “ is a function from to .” The set is the domain and the set is the codomain. If belongs to the function, we usually write
The values that actually occur as outputs form the range:
The range is always a subset of the codomain, but it need not equal the codomain.
A finite example
Let
and define
Every member of has one output, so is a function. Its domain is , its codomain is , and
The unused codomain values and remain part of even though they are not in the range.
Now compare two broken relations:
is not a function from to because input has no output, while
is not a function because input has two outputs. Several inputs may share one output; one input may not split into several outputs.
Injective, surjective, and bijective functions
After checking that a mapping is a function, we can ask how its outputs cover the codomain.
A function is injective (one-to-one) when different inputs always have different outputs:
The contrapositive form is often easier to visualize:
An arrow diagram for an injective function never sends two domain elements into the same codomain element.
A function is surjective (onto) when every codomain element is reached:
Equivalently,
A function is bijective when it is both injective and surjective. Every codomain element then receives exactly one arrow.
For a finite function, use this audit:
| Question | If yes |
|---|---|
| Does every domain element have exactly one outgoing arrow? | it is a function |
| Do distinct domain elements avoid sharing an output? | it is injective |
| Does every codomain element receive an arrow? | it is surjective |
| Are both of the previous two property checks true? | it is bijective |
Be careful: injective and surjective depend on the stated domain and codomain. The rule is not injective as a function because . Restricting the domain to the nonnegative integers removes that collision.
Route packages through a mapping conveyor. You may redirect outputs, leave an input disconnected, or create a split. Live inspectors separate the basic function rule from injectivity, surjectivity, and bijectivity, so changing one arrow reveals exactly which definition changes.
Composition connects two functions
Suppose
Because the output of belongs to , it can become an input to . Their composition is the function
defined by
The rightmost function acts first. This order is not a typographical choice: an input must pass through before the result can enter .
Following one value through a pipeline
Let
For ,
so
As formulas,
Reversing the machines produces a different function:
For example,
Therefore composition is generally not commutative:
It may even be impossible to reverse the order when the output set of does not fit the input set of .
Identity and inverse functions
The identity function on a set returns each element unchanged:
It acts like a do-nothing machine:
for every .
An inverse function reverses a function. If has an inverse, it is written
and must satisfy both
Thus, for every and ,
The notation does not mean the reciprocal . The superscript says “undo the mapping.”
Why bijections are exactly the invertible functions
If is not injective, two inputs collide at one output. A reverse machine receiving that output cannot know which original input to return.
If is not surjective, some was never produced. A reverse function with domain would have no valid original input to assign to that .
A bijection has neither problem: each corresponds to exactly one . Therefore:
For example, define by
To find the inverse, set and solve for :
Replacing the temporary input letter by gives
Check both directions:
and
Send a token through two animated machines, swap their order, and then attempt a reverse journey. The lab makes intermediate values visible and deliberately introduces collisions or unreachable outputs so you can diagnose why an inverse fails.
Section bridge
A function is a relation with a strict “exactly one output per input” rule. The next section removes that restriction and studies general binary relations. Instead of asking only whether arrows define a function, we will inspect patterns such as loops, paired arrows, and multi-step paths.