Relations
"Is a parent of." "Is greater than." "Maps to." Every one of these everyday links between two collections of things has a precise mathematical shape: a relation is nothing but a chosen set of ordered pairs, one entry taken from each collection. Before you can define a function — a rule assigning exactly one output to each input — you need the more general language of relations, and that language starts with the ordered pair and the Cartesian product. This article builds that language from scratch: what an ordered pair is and when two of them are equal, how the Cartesian product collects every possible pairing of two sets, how a relation is simply a subset of that product, and how domain, co-domain, and range describe which pairs actually occur. Two worked examples, one in roster form and one from a rule, fix the ideas.
A relation from set to set is any subset of the Cartesian product , so it is completely described by which ordered pairs it contains.
The core idea
Ordered pairs. An ordered pair has a fixed first component and second component , and the order is part of its identity: two ordered pairs are equal exactly when both components match.
where: are the first components and are the second components. In particular unless — this is what separates an ordered pair from a two-element set, where always.
Cartesian product. For sets and , the Cartesian product collects every possible ordered pairing of an element of with an element of :
where: ranges over all of and ranges over all of , independently, so every combination appears exactly once. When and are finite, the size of the product follows a simple counting rule, , proved below. The same idea extends to three sets: is the set of ordered triples , and is the set of all ordered triples of real numbers — the coordinate space used for points in three dimensions.
Relations. A relation from to is simply a subset of the Cartesian product:
where: every element of is itself an ordered pair with , . If , we say " is related to " and write . A relation can be presented in roster form (a list of pairs), by a set-builder rule (a condition the pairs must satisfy), as an arrow diagram between two sets, or as a graph of points in the plane — all four are the same underlying set of pairs, just displayed differently. Three sets travel with every relation:
- The domain is the set of first components that actually occur in — the inputs that are used.
- The co-domain is the set itself, fixed in advance when is defined, whether or not every element of is used.
- The range is the set of second components that actually occur in — always a subset of the co-domain, but not necessarily all of it.
The goal here is to show why always holds for finite sets, not just to state it, so that the rule can be trusted for any pair of finite sets rather than memorised as a formula that happens to work in small examples.
Step 1. Fix the first component. Suppose and . Pick any single element . Pairing this one fixed with each element of in turn produces exactly distinct ordered pairs — one pair for every , and no two of these pairs can coincide because their second components differ.
Step 2. Repeat for every choice of first element. There are possible choices of (all of ), and Step 1 shows each choice contributes its own block of exactly pairs. These blocks never overlap: a pair from the block built on and a pair from the block built on differ in their first component, so they cannot be the same pair.
Step 3. Add the blocks. The full set is the union of these non-overlapping blocks, each of size , so
Step 4. Sanity-check on a small case. With () and (), the rule predicts , matching the 6 pairs listed by direct enumeration in the worked example below.
Worked example
Problem. , . Find and , then let and find , its domain, co-domain, and range.
Step 1. List every ordered pair with first entry from and second entry from :
By the counting rule, , which matches the 6 pairs listed.
Step 2. Test each pair of against the condition : satisfies it since ; satisfies it since ; fails since ; satisfies it since ; fails since ; satisfies it since .
Step 3. Collect the pairs that pass:
Step 4. Read off domain, co-domain, and range. The domain is the set of distinct first entries in : . The co-domain is the target set itself: . The range is the set of distinct second entries in : . Here the range happens to equal the co-domain, though that is not required in general.
Competitive stretch
A second relation on is defined by . Evaluating at each given gives , , , , , so . The domain is , but the range collapses repeated values into — even though and each arise from two different -values, each appears only once in the range because the range is a set.
Common traps
- Confusing an ordered pair with a two-element set: , since order matters for pairs — — but not for sets, since .
- Listing repeated values in the range: the range is a set, so a second component that occurs twice, as in the competitive stretch above, is written once, not twice.
- Assuming range equals co-domain automatically: the co-domain is chosen in advance as the whole target set , while the range depends only on which pairs actually belong to ; range is always a subset of co-domain but need not be all of it.
- Miscounting by adding instead of multiplying: the counting rule is , never .
Ask the tutor: Want to practise turning a word description straight into a relation and pinning down its domain and range?
Why does order matter in an ordered pair but not in a set?
An ordered pair is built to record which element came from which set — the first slot is reserved for the element of , the second for the element of , so swapping them changes the meaning entirely, like swapping latitude and longitude. A set has no slots at all, just membership, so and describe the exact same collection. Keeping this distinction straight is exactly why in general.
Is every relation also a function?
No. A relation is any subset of at all — it can leave some elements of unused, and it can pair one element of with several different elements of . A function is a much more restrictive relation: every element of the domain set must appear as a first component exactly once, giving one and only one output. So every function is a relation, but most relations are not functions — the formal test for this comes later in the "Functions" sub-topic.
How is the co-domain different from the range if they can look the same in examples?
The co-domain is a choice you make when defining the relation — you fix a target set before deciding which pairs go into . The range is a consequence — it is whatever second components happen to show up once is actually written down. They can coincide, as in the first worked example, purely by chance of which pairs satisfied the condition; nothing forces them to. Always check the range by listing the pairs, never by assuming it matches the stated co-domain.