Download the PDF Star on GitHub Buy me a coffee

8  Sets and Functions

As we saw before, sets are a collection of objects. We have encountered prominent examples like N\color{red}{\mathbb{N}}, the set of counting or natural numbers, Z\color{blue}{\mathbb{Z}}, the set of integers, positive and negative, and Q\color{purple}{\mathbb{Q}}, the rational numbers.

We also made up other examples, such as MM, a set of mammals, and SS, the set of the natural satellites of Earth.

M={🐨,🐢,🐼,🦊,🐰}M=\left\{\text{\style{font-size:1em}{🐨}}, \text{\style{font-size:1em}{🐢}}, \text{\style{font-size:1em}{🐼}}, \text{\style{font-size:1em}{🦊}}, \text{\style{font-size:1em}{🐰}} \right\}

S={πŸŒ•}.S = \left\{\text{\style{font-size:1em}{πŸŒ•}}\right\}.

These sets can also be represented with Euler-Venn diagrams.

In this chapter, we will learn how to define relationships between sets, including those between a set and itself. We will also introduce the concept of a function, a specific type of relationship between sets.

8.1 Relationships between sets

Given two sets, AA and BB, we can define a mapping, or relationship, that maps or projects elements of AA onto elements of BB.

For instance, suppose that AA is a set of children, such as you and your friends. Set BB is a set of their moms. We can define the relationship β€œbeing the mom of” πŸ‘©β€πŸΌ that maps every child in AA onto his/her mom in BB.

Caution What can you infer from this mapping?

A function is a rule that maps the elements of one set onto the elements of another. In the following example, the function ff maps an animal’s image to its English name.

We call the set of Animals the domain of the function ff. The function f:Animals→Namesf: \text{Animals} \to \text{Names} is the rule that allows us to map an animal image to its English name. For example:

f(🐰)=Rabbitf(\text{\style{font-size:1em}{🐰}}) = \text{Rabbit}

We say that Rabbit is the image of 🐰.

Caution Are all mappings between two sets functions?

No. A relationship is only a function if every element in the first set is mapped to exactly one image in the second set.

The previous example is a function because every animal in the set Animals is mapped to exactly one Name.

However, imagine that we discover a new animal for which we have no English name yet. The following mapping is not a function because at least one element in the domain does not have a known name. The requirement is that every element has exactly one.

This is not a function because one of the animals is unnamed.

Similarly, if an animal has two names, That relationship is also not a function because every element in the domain must have exactly 11 image.

It’s also not a function because one of the animals has more than one name.

8.2 Exaples of functions

The function g:L→Gg: L \to G maps the Latin alphabet onto the Greek alphabet.

The function h:Kids→Foodh: \text{Kids} \to \text{Food} maps a set of kids to their favorite food.

Finally, a function can also map a set to itself. For example, consider the function f:Z→Zf: \mathbb{Z} \to \mathbb{Z}, which maps every integer to its square.

f(x)=x2,for every x∈Zf(x) = x^2, \quad \text{for every } x \in \mathbb{Z}

A more trivial example is the identify function f:Z→Zf: \mathbb{Z} \to \mathbb{Z}

f(x) = x

which maps every integer to itself.

Exercises

The following examples show a mapping that connects cities in Switzerland to cities in Italy. Determine whether this mapping is a function and explain your answer.

Caution Is the previous example a function?

Why?

Caution Is the previous example a function?

Why?

Caution Is the previous example a function?

Why?

Let the mapping c:Star→Constellationc: \text{Star} \to \text{Constellation} be the mapping of a star to the constellation to which it belongs. Draw the mapping between the sets Star and Constellation, and explain whether this mapping is a function.

It is possible to represent numerical relationships, such as the function f:Z→Zf:\mathbb{Z} \to \mathbb{Z}, defined as f(x)=x2f(x) = x^2, which maps every integer to its square, on a Cartesian plane.

Take every pair of elements: an element in AA and its image in BB, and locate them on the Cartesian plane as follows: the element in AA is the x-coordinate, and the element in BB is the y-coordinate.

In the following figure, I added the first three pairs: (βˆ’4,16)(-4, 16), (βˆ’3,9)(-3, 9), and (βˆ’2,4)(-2, 4). Add the rest, and then connect those points with a line in the same order. First, connect (βˆ’4,16)(-4, 16) to (βˆ’3,9)(-3, 9), then (βˆ’3,9)(-3, 9) to (βˆ’2,4)(-2, 4), and so on.

8.3 Inverse of a function

We encountered in the examples a function g:L→Gg: L \to G that maps Latin letters into Greek ones.

Imagine that we want to do the opposite, namely mapping Greek letters into Latin ones.

To to this, we need to reverse the mapping. We need a new function, let’s call it hh, that maps Greek into Latin, h:Gβ†’Lh: G \to L.

In a way, this function h:Gβ†’Lh: G \to L undoes what the function f:Lβ†’Gf: L \to G does, and we call hh the inverse function of ff. We denote the inverse as h=fβˆ’1h = f^{-1}.

Caution Question

Is it always possible to find an inverse?

Let’s consider another example to answer this question. As you saw in the exercises, the following mapping f:Sβ†’If: S \to I is a function because every element in SS has exactly one image in II. In other words, every city in Switzerland is connected to at most one city in Italy.

Unfortunately, the holidays are over, and we have to travel back from Italy to Switzerland. We need a function that goes in the opposite direction. This function is called the inverse of ff, and we use the symbol fβˆ’1f^{-1} for it.

We need a new function g:Iβ†’S=fβˆ’1g:I\to S = f^{-1}, that undoes f:Sβ†’If: S\to I.

Caution Is this mapping a function?

The departure set, or domain, is Italy, or II.

  • Does every element in II have an image in SS? Does a train leave from every city in Italy?
  • Does every element in II have a unique image in SS? Is each city in Italy connected to exactly one city in Swizerland?

We see that the answer to both questions is no. There are no trains leaving from Rome and Napoli, and Milano is connected to more than one city in Switzerland. The mapping g:I→Sg: I\to S is not a function. Therefore, the function f:S→If: S \to I is not invertible.

For a function to be invertible, an additional condition is needed.

TipInvertible functions

A function between two sets AA and BB, f:A→Bf:A\to B, is invertible if every element in BB is the image of exactly one element in AA. In other words, the function must implement a one-to-one correspondence between the two sets. This means that the inverse mapping, f′:B→Af': B \to A, is also a function.

As we saw with the example of mapping Latin letters to Greek letters, this condition is met and the function is therefore invertible.

We can fix the function f:S→If: S\to I to be invertible.

This new function is invertible, meaning that we can always return home from Italy by taking the train in the opposite direction.

Caution Question

How did we fix this function?

If we take a train from Zurich, we know that we will arrive at f(Zurich), which is Milan. To return to Zurich, we need to take a train to fβˆ’1(Milan)f^{-1}(\text{Milan}), which is Zurich. If we take a train from Zurich, we know we will arrive at f(Zurich)=Milanof(\text{Zurich}) = \text{Milano}. To return to Zurich, we need to take a train to fβˆ’1(Milano)=Zurichf^{-1}(\text{Milano})=\text{Zurich}.

Exercises

Try reasoning about the inverse function of each of the following functions.

f(x)=2+xf(x)=2x\begin{align*} f(x) &= 2 + x \\ f(x) &= 2x \\ \end{align*}

8.4 Composition of functions

We saw the example of the function f:Aβ†’Bf:A \to B, which is defined as β€œbeing the mom of” πŸ‘©β€πŸΌ, and maps an element in AA (a child) onto his/her mom.

Now, if we introduce a new set, CC, consisting of the mother’s fathers, we can define a new function g:Bβ†’Cg: B \to C as the function β€œbeing the father of” πŸ‘¨β€πŸ« that maps an element in BB to her father in CC.

We can compose the two functions, meaning we can apply them one after the other.

The composition of the functions is denoted by [g∘f](x)=g(f(x))[g\circ f](x) = g(f(x)).

This means that we first apply f:A→Bf:A\to B, which sends elements in AA to their moms. For example, it sends Jonas→Gabriele˙\text{Jonas} \to \text{Gabrielė}, because f(Jonas)=Gabriele˙f(\text{Jonas}) = \text{Gabrielė}. Then, g:B→Cg:B\to C sends elements in BB to their fathers. For example, it sends Gabriele˙→Gediminas\text{Gabrielė} \to \text{Gediminas}, because g(Gabriele˙)=Gediminasg(\text{Gabrielė}) = \text{Gediminas}.

Caution Question

What relationship does the new function g(f(x))g(f(x)) represent?

As a final example, consider the function f:Z→Zf: \mathbb{Z} \to \mathbb{Z} defined as f(x)=2xf(x) = 2x, which sends an element to its double, and g:Z→Zg: \mathbb{Z} \to \mathbb{Z}, defined as g(x)=x+1g(x) = x + 1, which increments a number by 11.

Here are some examples:

f(3)=2Γ—3=6f(βˆ’2)=2Γ—βˆ’2=4f(1)=2Γ—1=2g(1)=1+1=2g(0)=0+1=1g(βˆ’1)=βˆ’1+1=0\begin{align*} f({\color{red}{3}}) &= 2\times {\color{red}{3}} &= 6\\ f({\color{red}{-2}}) &= 2\times {\color{red}{-2}} &= 4\\ f({\color{red}{1}}) &= 2\times {\color{red}{1}} &= 2\\ g({\color{red}{1}}) &= {\color{red}{1}} + 1 &= 2\\ g({\color{red}{0}}) &= {\color{red}{0}} + 1 &= 1\\ g({\color{red}{-1}}) &= {\color{red}{-1}} + 1 &= 0\\ \end{align*}

The composition [f∘g](x)=f(g(x))[f\circ g](x) = f(g(x)) will look like this:

[f∘g](3)=f(g(3))=2Γ—(3+1)=8[f∘g](βˆ’1)=f(g(βˆ’1))=2Γ—(βˆ’1+1)=0[f∘g](1)=f(g(1))=2Γ—(1+1)=0\begin{align*} [f\circ g](3) &= f(g(3)) &= 2\times (3 + 1) &= 8\\ [f\circ g](-1) &= f(g(-1)) &= 2\times (-1 + 1) &= 0\\ [f\circ g](1) &= f(g(1)) &= 2\times (1 + 1) &= 0\\ \end{align*}

The composition [g∘f](x)=g(f(x))[g\circ f](x) = g(f(x)) (they are not commutative) will look like this:

[g∘f](3)=g(f(3))=(2Γ—3)+1=7[g∘f](βˆ’1)=g(f(βˆ’1))=(2Γ—βˆ’1)+1=βˆ’1[g∘f](1)=g(f(1))=(2Γ—1)+1=3\begin{align*} [g\circ f](3) &= g(f(3)) &= (2\times 3) + 1 &= 7\\ [g\circ f](-1) &= g(f(-1)) &= (2\times -1) + 1 &= -1\\ [g\circ f](1) &= g(f(1)) &= (2\times 1) + 1 &= 3\\ \end{align*}

8.5 Permutations and Symmetries

Imagine that you have a set of unique game cards representing the values 0,1,2,30, 1, 2, 3. If you shuffle the cards, they may end up in a different order. For example, they could end up in the order 2,1,0,32, 1, 0, 3. We call every reordering of the cards a permutation.

A permutation can be seen as a functionβ€”specifically, a one-to-one correspondence, also called a β€œbijection,” or, in other words, an invertible function that maps a set onto itself.

For example, if we have the set Z4={0,1,2,3}\mathbb{Z}_4 = \{0, 1, 2, 3\}, an invertible function f:Z4β†’Z4f:\mathbb{Z}_4 \to \mathbb{Z}_4 that reorders the values is called a permutation.

8.6 Symmetries of a Square

Let’s do some bricolage! Print this page, then cut out the colored squares. Then, glue them together so that the colors match. It’s helpful to print two sets so you can make comparisons. Leave the white square on the page.

We will now consider shape-preserving or symmetric transformations of this colorful paper square. In other words, this means any rotation or flipping of the square that allows you to superimpose it on the white square on the page without it falling off.

NoteParent/Educator Tip

Explain why rotating the square by 4545 degrees results in a square that doesn’t fit the original or coincide with the fixed white square left on the page.

TipSymmetry

Symmetry, from the ancient Greek word συμμΡτρία, is one of the most profound and pervasive concepts in nature and mathematics. It governs our perception of beauty, dictates how energy is conserved, and underpins our understanding of music, physics, chemistry, and the world itself. Symmetry is beautiful and important. In a sense, group theory is the mathematical study of symmetry.

Below are examples of symmetric and asymmetric figures. Source: Wikimedia.

Print this page and cut out the images. Then, fold each image along the vertical, straight line. What is the difference between symmetric and asymmetric figures?

Rotations

One such transformation, for example, is obtained by rotating the square by a quarter (14\frac{1}{4}) turn (9090 degrees).

NoteParent/Educator Tip

Here, I am using a passive convention, which means that when we rotate 9090 degrees, for example, the set of numbers {1,2,3,4}\{1, 2, 3, 4\} is sent to the set of numbers {4,1,2,3}\{4, 1, 2, 3\}. In other words, 11 is mapped to the number that replaces it after the square is rotated while keeping the frame of reference constant. I adopted this convention to make the colors work. It differs from the active convention used in textbooks such as Charles Pinter’s wonderful book on abstract algebra, in which rotating by 9090 degrees clockwise sends the set of numbers {1,2,3,4}\{1, 2, 3, 4\} to the set of numbers {2,3,4,1}\{2, 3, 4, 1\}. In this case, the corner numbers remain fixed, and 11 occupies the position previously occupied by 22.

The two approaches should be equivalent, even if some of the rotations are reverted.

These symmetry-preserving transformations can be thought of as functions that map the set of corners of the square, S={1,2,3,4}S = \{1, 2, 3, 4\}, to itself. It is a permutation, R:S→SR:S\to S.

Rotating the square by one-quarter turn can be seen as a function, R1:S→SR_1:S\to S, that sends the original order, 1,2,3,4{1,2,3,4}, to 4,1,2,3{4,1,2,3}.

After applying the rotation R1R_1, 44 is in the position that 11 was in before, 11 is in the position that 22 was in before, and so on.

Symmetry is also preserved if we rotate the square by either half (180180 degrees) or three-quarters (270270 degrees). For example, rotating the square 180180 degrees can be seen as a function, R2:S→SR_2: S \to S, that maps the original order, {1,2,3,4}\{1, 2, 3, 4\}, to {3,4,1,2}\{3, 4, 1, 2\}.

Flips

In addition to rotating the square, we can also flip it around the vertical, horizontal, or diagonal axes. This flipping preserves symmetry, meaning you can still superimpose it on the white square above. Try it yourself!

Again, flipping the square along one of its axes can be thought of as a function, R:S→SR: S \to S, or a permutation.

For example, flipping the square along the axis AA results in:

This corresponds to the following mapping:

Another example of a flip is the one around the DD axis.

This corresponds to the following mapping:

Here is a summary of the symmetries of our colorful square.

f:S→Sf: S\to S Description
R0R_0 Identity: do nothing.
R1R_1 Rotate by 1/41/4 of a turn, 9090 degrees.
R2R_2 Rotate by 1/21/2 of a turn, 180180 degrees.
R3R_3 Rotate by 1/41/4 of a turn, 270270 degrees.
R4R_4 Flip about axis AA
R5R_5 Flip about axis BB
R6R_6 Flip about axis CC
R7R_7 Flip about axis DD

Since these transformations are invertible functions, they can be composed. Composition simply means performing one operation after another.

For example, take the paper square and apply the transformation.

[R4∘R1](x)=R4(R1(x))[R_4 \circ R_1](x) = R_4(R_1(x))

First, we apply R1R_1, which rotates the square by 1/41/4. Then, we apply R4R_4, which flips about the axis AA, to the result.

Caution Question

What does it mean that R4∘R1=R7R_4 \circ R_1 = R_7?

It means that applying R4∘R1R_4\circ R_1, i.e., first rotating by 9090 degrees and then flipping about axis AA, is equivalent to applying R7R_7, which flips the square about axis DD.

Try to convince yourself.

Group of symmetries

The symmetries of the square, SG={R0,R1,β‹―R7}S_G = \{R_0, R_1, \cdots R_7\}, forms a group under the operation of function composition, ∘\color{red}{\circ}. Remember our checklist? Let’s take a look at the Cayley table of the group.

  • βœ… Closure and associativity: The composition of two elements of SGS_G is also in SGS_G. For example, as we saw above and can verify in the table, R4∘R1=R7∈SGR_4 \circ R_1 = R_7 \in S_G.

  • βœ… Existence of an identity element: There is a neutral function, R0R_0, that sends a permutation to itself. This is illustrated by the highlighted row and column in the following figure.

  • βœ… Existence of an inverse: Every element in SGS_G can be mapped to the identity element, R0R_0, using composition with another element.

For instance all the flipping operations R4β‹―R7R_4 \cdots R_7 are their own inverse. The inverse of R3R_3 is R1R_1 because R3∘R1=R0R_3 \circ R_1 = R_0, as illustrated in the following figure.

TipDihedral group

This group of symmetries is called the dihedral group of order 88 and is denoted D4D_4. For any polygon of nn sides, the dihedral group with 2n2n elements is denoted DnD_n or D2nD_{2n}.

Caution Why is called diehedral?

I’ll leave this one as an exercise for you to do some research on.

Exercises

Caution Question

Why don’t we list rotations that are multiples of one turn, such as 11 or 22 or 1010 turns?

Complete the following mappings.

  • R3R_3, rotage by 270270 degrees.

  • R5R_5: flip about axis BB.

Use your paper square to compute the following operations. Use the Cayley table above to verify.