RELATIONS AND FUNCTIONS
Chapter 1: Relations and Functions
Chapter 1
Relations and Functions
Big idea: a relation says which things are connected. A function is a relation with a promise: each input has exactly one output. That promise lets you predict, compare, and sometimes undo.
1.1 Introduction
A shop lists three phone models. Each model comes in some of three colours. If you write down "model 1 comes in colour 2", you have written one connection between two things. A list of such connections is called a relation. Relations are everywhere: a timetable links classes to rooms, a menu links dishes to prices, a map links towns to roads.
An ordered pair is two things written in a fixed order. The order matters: is not the same pair as . If and are sets, the Cartesian product is the set of all ordered pairs with the first item from and the second from .
Let be the phone models and the colours (1 = black, 2 = silver, 3 = blue). Then has pairs. In general, if has items and has items, then has pairs.
A relation from to is any subset of . Suppose the shop sells model 1 in black and silver, model 2 only in silver, and model 3 in all three colours. Then
We write , or , when the pair is in the relation. Because has 9 pairs and each pair is either in or out of , there are possible relations from to .
A grid with phone model 1, 2, 3 along the horizontal axis and colour 1, 2, 3 up the vertical axis. Six dots are drawn: model 1 with colours 1 and 2, model 2 with colour 2, and model 3 with colours 1, 2 and 3.
Look at model 1 in the relation above. It has two colours, so if someone asks "what is the colour of model 1?" there is no single answer. A function removes this problem. It is a relation in which every input has exactly one output.
Now suppose each model has one default colour: model 1 is black, model 2 is silver, model 3 is black. This is . Every model appears exactly once as a first item, so is a function. We write , , .
In this chapter you will learn:
- the main types of relations: reflexive, symmetric, transitive, and the very useful equivalence relation;
- the main types of functions: one-one, onto, and bijective;
- composition: doing one function after another;
- inverse functions: when a function can be undone, and how to find the undo rule.
1.2 Types of Relations
From now on we study relations inside one set: a relation in a set is a subset of . This is how we compare things of the same kind: numbers with numbers, lines with lines, words with words.
- The empty relation has no pairs: . Nothing is related to anything.
- The universal relation has all pairs: . Everything is related to everything.
- Reflexive: every item is related to itself. for every .
- Symmetric: if is related to , then is related to . implies .
- Transitive: if is related to and is related to , then is related to . and imply .
Think of "is the same height as". Everyone is the same height as themselves (reflexive). If A is the same height as B, then B is the same height as A (symmetric). If A matches B and B matches C, then A matches C (transitive). Compare "is taller than": it is transitive, but it is not reflexive and not symmetric.
A relation that is reflexive, symmetric and transitive is called an equivalence relation. It says "these two items are the same in the way we care about". Same height, same colour, same remainder after dividing by 3: all of these are equivalence relations.
Take and test ten relations. The answers below were computed pair by pair.
| Relation | Rule for | Reflexive | Symmetric | Transitive |
|---|---|---|---|---|
| The empty relation | no pair at all | No | Yes | Yes |
| The universal relation | every pair | Yes | Yes | Yes |
| Equal | Yes | Yes | Yes | |
| Less than | No | No | Yes | |
| Less than or equal | Yes | No | Yes | |
| Divides | divides | Yes | No | Yes |
| Differ by exactly 1 | No | Yes | No | |
| Differ by at most 1 | Yes | Yes | No | |
| Add up to 7 | No | Yes | No | |
| Same parity | is even | Yes | Yes | Yes |
- To prove a property for a rule on all numbers, take general items (, , ) and use the rule with algebra.
- To disprove a property, one counterexample is enough. Find one pair (or two linked pairs) where the rule fails.
Let be the relation on the set of integers given by when is a multiple of . Show that is an equivalence relation.
- Reflexive: , which is a multiple of . So .
- Symmetric: suppose for some integer . Then , which is also a multiple of . So .
- Transitive: suppose and . Adding, , a multiple of . So .
All three hold, so is an equivalence relation. As a check, the computer tested every pair of the integers from to and agreed: reflexive Yes, symmetric Yes, transitive Yes. (The proof above covers all integers. The test covers this sample.)
On let when (the product is zero or positive). It is reflexive, because . It is symmetric, because . But it is not transitive: because , and because . Yet , because . The number links numbers that should not be linked.
An equivalence relation sorts a set into groups. The equivalence class of , written , is the set of all items related to . Take and let when is a multiple of (same remainder when divided by ). The classes are
Every item is in exactly one class, and different classes never overlap. We say the classes partition the set. This is why equivalence relations matter: they turn "same in some way" into clean groups. Days of the week work like this: every day number has a remainder when divided by 7, and the same remainder means the same weekday.
Decide which of the three properties each relation has.
- On : .
- On : .
- On : when .
- On : when .
Answers
- Reflexive and transitive, but not symmetric.
- Symmetric, but not reflexive or transitive.
- Symmetric, but not reflexive or transitive.
- Reflexive and transitive, but not symmetric.
EXERCISE 1.1
- On , let . Which of the three properties does have? Is it an equivalence relation?
- On , let when . Test the three properties.
- On , let when divides . Test the three properties.
- On the integers from to , let when is a multiple of . Show that it is an equivalence relation and list the equivalence classes. What is the class of ?
- How many relations on a set of items are (a) reflexive, (b) symmetric, (c) equivalence relations?
- On the set of all straight lines in a plane, let " is perpendicular to " be the relation. Which properties does it have?
- On the words , let two words be related when they have the same number of letters. Show it is an equivalence relation and find the classes.
- On , let when . Is an equivalence relation? Find its classes.
- On the real numbers, let when is an integer. Show that is an equivalence relation. Which of , , , , are in the same class?
- How many equivalence relations on contain the pair ?
Answers
- Reflexive: are all in . Symmetric: and are both there. Transitive: no chain breaks the rule. So is reflexive, symmetric and transitive, so it is an equivalence relation.
- Not reflexive, because is not less than , so . Symmetric, because . Not transitive: and , but because .
- Reflexive (every number divides itself) and transitive (if divides and divides , then divides ). Not symmetric: but .
- The proof is the same as Example 1, with in place of . There are 5 classes: . The class of is .
- (a) . (b) . (c) . All three counts were found by testing every one of the relations.
- Symmetric only. A line is not perpendicular to itself, so it is not reflexive. If and , then and are parallel, not perpendicular, so it is not transitive.
- Each word has the same length as itself; "same length" can be read in either direction; and if and have the same length and and have the same length, then and do. So it is an equivalence relation. The classes are .
- Yes: equal squares is a form of "the same value", so all three properties hold. The classes are .
- Reflexive: is an integer. Symmetric: if is an integer, so is . Transitive: the sum of two integers is an integer. In the list, , and are in one class (they differ by whole numbers), and and are in another.
- . Either and form a class and is alone, or all three numbers are in one class.
1.3 Types of Functions
A function from a set to a set is written . The set is the domain (the allowed inputs). The set is the codomain (where outputs are allowed to live). The range is the set of outputs that actually happen, and it can be smaller than the codomain.
Example: let be . The domain and codomain are both . But no square is negative, so the range is only .
Two questions decide what kind of function we have. Both are about the outputs:
- One-one (injective): do different inputs always give different outputs? Nothing is shared.
- Onto (surjective): is every item of the codomain actually used as an output? Nothing is left out.
In symbols, is one-one when forces . And is onto when for every in the codomain there is some in the domain with . A function that is both is called bijective: a perfect pairing of the domain with the codomain.
Let the domain be and the codomain .
| Function | Pairs | One-one? | Onto? |
|---|---|---|---|
| Yes | Yes | ||
| No | No |
pairs everything perfectly, so it is bijective. In , the inputs and both go to (not one-one), and is never used (not onto).
- One-one: assume and show that . To show it is not one-one, find two different inputs with the same output.
- Onto: take any in the codomain and try to solve for . If you always find an in the domain, the function is onto. To show it is not onto, find one that no input can reach.
- Graph test: draw horizontal lines. If some horizontal line meets the graph twice, the function is not one-one. If some horizontal line in the codomain meets the graph never, it is not onto.
Show that , is bijective.
One-one. Suppose . Then , so , so .
Onto. Take any real . Solving gives , which is a real number. And . So every is reached.
Is , one-one? Is it onto?
Not one-one: and . Two different inputs share one output. Not onto: every square is or more, so no input gives . The graph shows both problems at once.
Graph of the parabola y equals x squared from x equals minus 3 to 3, with a horizontal dashed line at y equals 4 that meets the curve at two marked points, (minus 2, 4) and (2, 4).
Fixing it. Whether a function is one-one or onto depends on its domain and codomain, so we can repair it. Let , . Now each output comes from exactly one input, . So is bijective.
The function , is bijective. It rises all the way along the real line, so no output repeats (one-one). And every real has a real cube root, so every is reached (onto).
Show that , is bijective.
One-one. Suppose . Then . Cross-multiply: . Expand both sides: . Cancel and : , so , so .
Onto. Let . Solve : , so , so . This is defined because . And it is never (if it were, , which is impossible). So every is reached.
Graph of the function f of x equals the fraction (2x plus 1) over (x minus 3). It has two separate branches. The left branch lies below the horizontal dashed line y equals 2, and the right branch lies above it. A vertical dashed line at x equals 3 separates them.
Let the domain have items and the codomain items. Each input can go to any of outputs, so there are functions in all. For one-one functions, the first input has choices, the next has (it cannot repeat), and so on: functions. The table was found by listing every function by computer.
| Domain size | Codomain size | All functions | One-one | Onto | Bijective |
|---|---|---|---|---|---|
- If there is no one-one function: too many inputs for too few outputs (the "pigeonhole idea").
- If there is no onto function: too few inputs to reach every output.
- A bijection needs . When , the number of bijections is (the table shows ).
Domain . For each map, say if it is one-one, onto, both or neither.
- , codomain .
- , codomain .
- , codomain .
- Every input goes to , codomain .
Answers
- It is one-one and onto (bijective).
- It is onto but not one-one.
- It is one-one but not onto.
- It is neither one-one nor onto.
EXERCISE 1.2
- Domain , codomain : . Is it one-one? Onto? And the map from to with ?
- Show that , is bijective. Which input gives the output ?
- Show that , is neither one-one nor onto.
- Is , one-one? Onto? Change the domain and codomain to make it bijective.
- Show that , is bijective.
- Domain with items, codomain with items. How many functions are there? Then find: one-one functions from items to items; onto functions from items to items; bijections from items to items.
- Is , one-one? Onto?
- Is , one-one? Onto? (Here .)
- A thermometer converts Celsius to Fahrenheit with . Show that this is a bijection from to . What is for ? What is for ?
- Give an example of (a) a one-one function from to that is not onto, and (b) an onto function from to that is not one-one.
Answers
- The first map is one-one and onto (bijective). The second map is onto but not one-one: it reaches both and , but four inputs share two outputs.
- If then (one-one). For any , gives (onto). For : . Check: .
- Not one-one: and . Not onto: for every , so is never an output.
- Not one-one: . Not onto: , so is never an output. Take . Then each comes from exactly one input , and is bijective.
- One-one: gives , so . Onto: solving gives , defined for , and it is never (that would need ).
- functions. One-one from to : . Onto from to : (all functions, minus the that send everything to one item). Bijections of items: .
- One-one: gives . Not onto: is always even, so an odd number such as is never an output.
- One-one: gives . Not onto: the smallest output is , so is never reached.
- It is a straight line with non-zero slope, so it is one-one and onto (as in Example 1). . Solving gives .
- (a) : one-one, and is never used. (b) : every output is used, but and share the output . Both were confirmed by computer.
1.4 Composition of Functions and Invertible Function
Imagine a two-step machine. The first machine takes a number and doubles it, then adds . The second machine squares whatever it receives. If you put a number through both machines in order, you have built a new function. This is called the composition of and .
The composition, written (read " after ") means: apply first, then . In symbols, .
With and : . At , the first machine gives and the second gives . In the other order, , and at it gives .
For to make sense, every output of must be an allowed input of . In other words, the range of must fit inside the domain of .
Let be , and be . Follow each input through both steps:
So . Notice that is not one-one (both and go to ), and neither is .
- Composition of one-one functions is one-one. If , then being one-one gives , and then being one-one gives .
- Composition of onto functions is onto. Take any target . Because is onto, some has . Because is onto, some has . Then .
- So the composition of two bijections is a bijection. This was checked on the pair of functions and , giving .
Composition also has a tidy property: it is associative. . With , , , both ways give , which equals at . So we can write with no brackets.
Some functions can be undone. If turns into by "double and add ", the undo machine turns back into by "subtract and halve". We say is the inverse of when doing one and then the other gets you back where you started, in both orders:
- for every in the domain of (do , then undo it);
- for every in the domain of (undo, then do ).
We write the inverse as . A function that has an inverse is called invertible.
- Check that the function is a bijection between the given domain and codomain.
- Write .
- Solve this equation for , so that is written using .
- Rename: the result is . You may then call the variable again.
- State the domain and range of . They are the range and domain of , swapped.
Find the inverse of on . Write . Then , so . Hence .
For , swapping each pair gives .
In Example 4 of Section 1.3, solving gave . So the inverse of is , . Notice how the missing input and the missing output trade places.
The function , is a bijection. Solving with gives . So . For instance and .
Two curves and a dashed diagonal line y equals x. One curve is y equals x squared plus 2 for x from 0 to 3. The other is its inverse, y equals the square root of x minus 2, for x from 2 to 11. The two curves are mirror images of each other in the diagonal. The points (3, 11) and (11, 3) are marked.
To undo "put on socks, then put on shoes" you must take off the shoes first, then the socks. In symbols, if and are invertible,
Check with and . Then , whose inverse is . On the other side, and , so . They agree. In the wrong order, , which is different.
- Let and . Find and .
- Find the inverse of .
- Is , from to , invertible?
- Find the inverse of on .
Answers
- and .
- gives , so .
- No. It is not one-one ( and both go to ), and it is not onto ( is never used).
- gives , so .
Miscellaneous Examples
Take the ordered pairs with . Say when . Show that this is an equivalence relation and describe the classes.
Reflexive: . Symmetric: if then . Transitive: if and , multiply the first by and the second by and compare: , and cancelling gives . The computer also checked all pairs of pairs.
The rule says " and are equal fractions". The pairs fall into 11 classes, one for each different fraction. The class of is , because . The class of has 4 pairs: . So a fraction is an equivalence class of pairs.
How many onto functions are there from to ?
Start with all functions: . Remove those that miss at least one output. There are ways to miss one chosen output, each leaving functions, so subtract . But functions that miss two outputs (everything goes to one item) were subtracted twice. There are of them, so add back . Total: . Listing every function by computer also gives 36.
Show that , is a bijection and find its inverse.
Inside the interval. Since , we have .
One-one. If , then and have the same sign (or both are ). Squaring both sides, , so . With the same sign, .
Onto. For , put . Then , so and . This formula is also the inverse: .
Let for . Show that is the identity, so .
. For example and : the function swaps and .
How many relations on contain and , are reflexive and symmetric, but are not transitive?
Reflexive and symmetric relations containing and have the three pairs and the pair . The only free choices are the pair (both and , or neither) and the pair . That is relations. Two of them are equivalence relations: add neither of the links, or add both. If we add exactly one link (say but not ), transitivity breaks: and are there but is missing. So the answer is 2.
*Miscellaneous Exercise on Chapter 1*
- Show that , is a bijection and find .
- On the nine ordered pairs with , let when . Show that is an equivalence relation. How many classes are there, and what is the class of ?
- Let and . Find and and evaluate both at .
- How many functions from to itself are neither one-one nor onto?
- Show that , is neither one-one nor onto.
- On , let when is a multiple of or a multiple of . Is an equivalence relation?
- Show that , is a bijection and find its inverse.
- The function converts a temperature from kelvin to Celsius, and converts Celsius to Fahrenheit. Find the composite that converts kelvin to Fahrenheit, its inverse, and the Fahrenheit value of K.
Answers
- If then , so (one-one). For any , gives (onto). So .
- The rule says : the two pairs have the same "step" from the first number to the second. Same step is an equivalence relation. The steps are , so there are 5 classes. The class of is .
- , and . , and .
- There are functions. For a finite set mapped to itself, one-one and onto go together, so the 6 bijections are the ones that are both. The rest, 27 − 6 = 21, are neither.
- Not one-one: and (every negative number goes to ). Not onto: always, so is never an output.
- It is reflexive and symmetric, but not transitive. (difference ) and (difference ), yet and differ by , which is neither. So it is not an equivalence relation.
- Solving gives , so and . This is defined for every and never equals , so is onto. If , cross-multiplying gives , so is one-one. Hence .
- . Its inverse is . At : °F.
Summary
- Relation: a subset of . A relation in a set is a subset of .
- Empty relation: no pairs. Universal relation: all pairs.
- Reflexive: for every . Symmetric: implies . Transitive: and in imply .
- Equivalence relation: reflexive, symmetric and transitive. It splits the set into equivalence classes that do not overlap.
- Function : every input has exactly one output. Domain = inputs, codomain = allowed outputs, range = outputs that really happen.
- One-one: implies . Onto: every item of the codomain is an output. Bijective: both.
- Counting from an -set to an -set: functions; one-one; bijections only if , and then there are .
- Composition: . Apply first. It is associative but usually not commutative. Composition of one-one (onto) functions is one-one (onto).
- Invertible: has an inverse exactly when it is a bijection. Then and . The graph of is the mirror image of the graph of in the line .
- Inverse of a composition: . Undo in the reverse order.
*Historical Note*
The idea of a function grew slowly over about three hundred years. Each step made it wider than the one before.
- 1637: René Descartes used the word "function" for powers of a variable, such as and , while studying curves like the parabola and the hyperbola.
- 1667: James Gregory described a function as a quantity obtained from other quantities by algebraic steps, or by "any other operation".
- 1673 and 1714: Gottfried Wilhelm Leibniz (1646–1716) first used the word for quantities that change from point to point along a curve, such as a slope. Later he used it for any quantity that depends on a variable, and he was the first to say "function of ".
- 1718: Johann Bernoulli (1667–1748) wrote for a function of .
- 1734: Leonhard Euler (1707–1783) made letters such as , , and the normal way to name functions. The form that you use today comes from this period.
- 1837: Peter Gustav Lejeune Dirichlet (1805–1859) gave a very wide definition: a function is any rule that gives one for each . No formula is needed.
- Later: after Georg Cantor (1845–1918) built set theory, a function could be defined as a set of ordered pairs with the "one output for each input" property.
Look back at Section 1.1. The definition in this chapter, a function as a special set of ordered pairs, is the last step of this long story.