Cartesian products and relations: record which pairs are allowed
Build ordered pairs, interpret a relation as a subset of a product, and compose relations carefully.
On this page
The question for today
What you’ll understand
- Construct a Cartesian product without losing order.
- Represent a binary relation as selected ordered pairs.
- Distinguish a relation, a function, and a composition of relations.
A scheduling table records which teacher can teach which course. The teacher alone does not determine the information, and neither does the course alone: an allowed pair does. Cartesian products name all pairs that could be considered, while a relation selects the pairs actually permitted. This viewpoint unifies comparison rules, database tables, graph edges, and functions without pretending that every relationship assigns a unique output.
Order belongs to the object
An ordered pair has a first coordinate and a second coordinate. Two pairs are equal precisely when their corresponding coordinates agree. Therefore exchanging the coordinates usually changes the pair, even though exchanging entries inside an ordinary two-element set does not change that set. If one coordinate names a teacher and the other a course, reversing them also changes the type of question being asked. Types help catch errors before a calculation starts.
The Cartesian product contains every allowed first coordinate paired with every allowed second coordinate. For finite factors its size is the product of their sizes because each first coordinate admits the full list of second coordinates. If either factor is empty, no pair can be formed and the product is empty. A product of three factors similarly records three positions, although one must specify whether nested pairs or triples are being used formally.
A relation selects pairs
A binary relation from A to B is any subset of their Cartesian product. Writing aRb abbreviates saying that the ordered pair belongs to the selected subset. A comparison relation on integers may select pairs whose first entry is smaller; a permission relation may select user-resource pairs that allow access. Neither relation is required to give exactly one second entry for each first entry. Some entries may have no partner or many partners.
A function is the special case where every element of the declared domain has exactly one output in the codomain. Merely drawing arrows does not establish that condition; inspect both existence and uniqueness. A table with two rows sharing an input but different outputs represents a relation, not a function on that input domain. A table omitting an input is also not a total function on that domain, although it could define a function on a smaller domain.
Composition follows a shared middle coordinate
To compose a relation from A to B with one from B to C, look for a middle object in B that connects both stages. The composite relates an initial a to a final c whenever at least one such middle object exists. Multiple witnesses still produce just one pair in the composite set. This differs from counting paths: two distinct intermediate routes can establish the same yes-or-no relationship.
The inverse relation reverses every pair and swaps the domain and codomain roles. It always exists as a relation, even when it is not a function. For example, reversing the graph of squaring over real inputs gives two outputs for most positive inputs and none for negative inputs. The distinction explains why solving an equation backwards may require a restriction of domain rather than an informal instruction to undo the formula.
Work it through
Connect teachers to rooms
Let R = {(Ada, algebra), (Ada, calculus), (Ben, calculus)} and S = {(algebra, room1), (calculus, room1), (calculus, room2)}. Find S composed with R.
For Ada, the algebra route reaches room1, while the calculus route reaches room1 and room2. Record (Ada,room1) and (Ada,room2), counting the repeated room1 pair only once.
For Ben, the only intermediate course is calculus, which reaches both rooms. Record (Ben,room1) and (Ben,room2).
Check that every recorded pair has a witness course, and that neither course has a room outside the two listed. The composite contains exactly four pairs.
The composite is {(Ada,room1), (Ada,room2), (Ben,room1), (Ben,room2)}. It is not a function from teachers to rooms.
The living notebook
Explore the model
Interactive lab · vectors
Ordered coordinates are not an unordered pair
Change angle and magnitude to inspect a vector's ordered x and y components. Predict what exchanging the components would do to its location. The lab draws one Euclidean vector and its projections, not a permission graph or an arbitrary relation; its purpose here is to make coordinate positions concrete.
- x component
- 1.393
- y component
- 0.975
- Magnitude
- 1.7
Playback traces a fixed vector and its projections. Angle and magnitude set the geometry; the moving marker does not change them. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA Cartesian product records roles in fixed positions, even when both coordinates are numbers.
Pause & reason
Check your understanding
Your turn
Try it yourself
For A = {0,1} and B = {a,b,c}, how many pairs are in A × B? How many relations from A to B are possible, and why?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
After listing possible pairs, choose independently whether each pair belongs to the relation.
Compare with the solution
There are six pairs: each of two first coordinates can accompany each of three second coordinates. A relation is any subset of those six pairs. Each pair has two membership choices, producing 2 to the sixth power, or 64 relations. Only nine are functions from A to B, because each of the two inputs must choose exactly one of three outputs.
Keep the idea
Take it with you
- A Cartesian product contains ordered possibilities; a relation selects some of them.
- A function adds the requirement of exactly one output for every input.
- Relation composition requires a shared intermediate witness, not a unique path.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.