Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

1.2: Sets and set operations

Before studying vectors, we need some language for describing collections of objects. This foundation will be helpful both in Math 124 and in your future engineering coursework (and life beyond Michigan!).


Sets

We can also form sets of non-numerical objects, such as

B={red,green,blue}.B=\{\text{red},\text{green},\text{blue}\}.

Here, we’ve seen a set of numbers and another set of colors; in this course, we may work with sets of numbers, points, vectors, and matrices.

In the definition of a set above, we said a set must be “well-defined” and contain “distinct” objects. What do these terms mean?

  1. By well-defined, it means that there should be a clear way to check whether any object is in the set. If an object xx belongs to a set SS, we write xSx\in S. If it does not, we write xSx\notin S. For instance, blueB\text{blue} \in B and maize∉B\text{maize} \not \in B.

  2. By distinct, we mean that sets do not contain duplicates. {2,2,4,6,6}\{2, 2, 4, 6, 6\} is not a valid set. They also do not keep track of order:

{2,4,6}={6,4,2}.\{2,4,6\}=\{6,4,2\}.

Set-builder notation

Defining a set by listing every one of its elements called enumerative notation. Sometimes, we use ellipses (...) as a shortcut to writing out many elements, but it is only good practice to do this when it is clear what replaces the .... For example,

{2,4,6,8,...,20}\{2, 4, 6, 8, ..., 20\}

is clearly the set containing all multiples of 2, starting with 2 and ending with 20. This is still considered enumerative notation. {2,3,5,...,10}\{2, 3, 5, ..., 10\} is more ambiguous. Try your best to avoid writing ambiguous statements – math is meant to be precise!

Often, enumerative notation is impractical, especially for sets with infinitely many elements. Set-builder notation describes a set by stating a rule that all of its elements follow. Recall, we earlier defined the set A={2,4,6,8}A = \{2, 4, 6, 8\}. Now consider the set

C={6,12,18,24}.C=\{6,12,18,24\}.

The elements of CC are just the elements of AA, each multiplied by 3. Using set-builder notation,

C={3x:xA}.C=\{3x:x\in A\}.

The expression to the left of the colon describes what goes into the set; the condition to the right describes which values are allowed. (If you’re familiar with programming in Python – which you’re not expected to be! – this resembles the syntax for list comprehension. Don’t worry if this doesn’t mean anything to you.)

The general pattern for set-builder notation is

{what goes in the set:condition}.\{\text{what goes in the set}:\text{condition}\}.

Here are several other examples.

  1. Using the same example set CC from above,

    {x:xC,x>10}\{x: x \in C, x > 10\}

    is the set of elements of CC that are greater than 10. This is the new set {12,18,24}\{12, 18, 24\}. The comma (,,) after the colon in the notation means “and”.

  2. The set {10,20,30,...,100}\{10, 20, 30, ..., 100\} can be expressed in set-builder notation as

    {10x:xZ,1x10}.\{10x: x \in \mathbb{Z}, 1 \leq x \leq 10 \}.

    Z\mathbb{Z} is the set of all integers; we will discuss the set of integers (and other number sets) more in Chapter 1.3.

  3. The set

    {x:xZ,x0}\{x: x \in \mathbb{Z}, x \geq 0\}

    is the set of all non-negative integers.

  4. The set

    {(x,y):x2+y2=16,xR,yR}\{(x, y): x^2 + y^2 = 16, x \in \mathbb{R}, y \in \mathbb{R} \}

    is the set of all points on the circle with radius 4 centered at (0,0)(0, 0). R\mathbb{R} refers to the set of real numbers, which again will be discussed in Chapter 1.3. For now, think of the real numbers as the set of all numbers that exist on a number line.

You’ll notice that in many of these examples, the item before the colon :: was simply xx, and following the colon were multiple conditions on xx, one of which was the set we were selecting elements from to create our new set (e.g. CC, Z\mathbb{Z}, or R\mathbb{R}). There is a shorter notation that is often used for sets like these. Here are a few examples.

Long-formShortform
{x:xC,x>10}\{x: x \in C, x > 10\}{xC:x>10}\{ x \in C : x > 10 \}
{x:xZ,x0}\{x: x \in \mathbb{Z}, x \geq 0\}{xZ:x0}\{x \in \mathbb{Z}: x \geq 0\}
{(x,y):x2+y2=16,xR,yR}\{(x, y): x^2 + y^2 = 16, x \in \mathbb{R}, y \in \mathbb{R}\}{(x,y)R2:x2+y2=16}\{ (x, y) \in \mathbb{R}^2 : x^2 + y^2 = 16 \}

In the final example, R2\mathbb{R}^2 is the set of all points in two-dimensional space.

The shortform notation is very common. To summarize, the two key forms you may see are:

  1. {f(x):conditions on x}\{f(x): \text{conditions on } x \} (this is the first form we introduced above).

  2. {xS:conditions on x}\{x \in \mathbb{S}: \text{conditions on } x\}.


Subsets

For example, if A={1,5,7,9,12}A=\{1,5,7,9,12\} and B={7,12}B=\{7,12\}, then BAB\subseteq A. On the other hand, {5,6}A\{5,6\}\nsubseteq A because 6A6\notin A.

Two sets are equal precisely when they contain the same elements, or equivalently, they are both subsets of each other!

  • Every set is a subset of itself.

  • The empty set, \emptyset, is the set with no elements in it. It is a subset of every set.


Union and intersection

For example, if

A={1,5,7},B={2,3,7,8},A=\{1,5,7\}, \qquad B=\{2,3,7,8\},

then

AB={1,2,3,5,7,8},AB={7}.A\cup B=\{1,2,3,5,7,8\}, \qquad A\cap B=\{7\}.

Two sets are disjoint if AB=A\cap B=\emptyset.

For any set AA,

AA=A,A=A,AA=A,A=.A\cup A=A, \qquad A\cup\emptyset=A, \qquad A\cap A=A, \qquad A\cap\emptyset=\emptyset.

To give you a sense of how this relates to the ideas in Chapter 1.1, soon we’ll describe lines and planes as sets of points. The intersection of two lines, then, can be viewed as the intersection of two sets!


Cardinality

Repetition does not affect cardinality, because sets do not store duplicates!

{1,1,2,2,2,12,3,3,9}=5.|\{1,1,2,2,2,12,-3,-3,9\}|=5.

For now, we’ll only consider the cardinality of finite sets. Sets with infinitely many elements, like the set of integers Z\mathbb{Z}, do have some well-defined notion of cardinality, but we will save that discussion for a future theoretical mathematics or computer science course.

The principle of inclusion-exclusion

Given that we just discussed the union and intersection of two sets, a natural question is how AB|A \cup B| and AB|A \cap B| relate to A|A| and B|B|.

As a thought experiment, suppose AA and BB are two non-empty sets, and you are given that AB=A+B|A \cup B| = |A| + |B|. What does this tell you about AA and BB? (Pause and think for a moment before scrolling further.)

If AB=A+B|A \cup B| = |A| + |B|, it means that there are no overlapping elements between AA and BB! If there were overlapping elements, they each would have been counted for twice: once in A|A| and once in B|B|. But, since sets do not have duplicates, this would have overcounted those overlapping elements in AB|A \cup B|. Thus, if AB=A+B|A \cup B| = |A| + |B|, AA and BB are disjoint.

In the general case, when AA and BB are not necessarily disjoint, the principle of inclusion-exclusion tells us how to find AB|A \cup B|, the number of elements in the union of AA and BB:

AB=A+BAB.|A\cup B|=|A|+|B|-|A\cap B|.
Animated illustration of inclusion-exclusion for two sets.

Returning to our earlier example, if A={1,5,7}A=\{1,5,7\} and B={2,3,7,8}B=\{2,3,7,8\}, then

AB=3+41=6.|A\cup B|=3+4-1=6.

This formula is more useful in cases where the sets are much larger and we can’t eyeball their intersections and unions.

How does this extend to three sets?

Animated illustration of inclusion-exclusion for three sets.

Like before, we subtract all pairwise overlaps, but then elements in all three sets have been removed too many times, so we add the triple overlap back once.

ABC=A+B+CABACBC+ABC.\begin{aligned} |A\cup B\cup C| ={}&|A|+|B|+|C|\\ &-|A\cap B|-|A\cap C|-|B\cap C|\\ &+|A\cap B\cap C|. \end{aligned}