Knowledge base · Maths in secondary schoolMaths in secondary school
Sets. Operations on sets
Number sets, the empty set, subsets, union, intersection, difference and complement - with Venn diagrams and step-by-step examples.
A class, a team, a sticker collection, a shopping list - in everyday life we talk about sets all the time, even if we rarely use the word. In maths sets are everywhere: the solutions of an equation, the domain of a function and the events in probability are all sets. In this lesson you will learn the language of sets: how to write them down, when two sets are equal, what a subset is and how to carry out operations on sets - union, intersection, difference and complement.
What is a set?
Most notions in maths are defined in terms of simpler ones. But you have to start somewhere. Notions that we do not define are called primitive notions - in geometry, for example, the point and the straight line are primitive.
A set and an element of a set are primitive notions: we do not define them, we explain them with examples.
A set is a collection of objects treated as a single whole. The objects it is made of are called its elements. For example, the students in your class, the letters of the word “mathematics” or the even numbers are all sets.
There is just one condition: for every object it must be possible to say clearly whether it belongs to the set or not. “The set of even numbers” is fine, because we know for every number whether it is even. “The set of hard problems” is not, because a problem that is hard for one person can be easy for another.
How do we write sets?
Sets are named with capital letters: A, B, C. Elements are written with small letters or numbers, and when we list them, we put them inside curly brackets { }:
Two rules apply when you list elements. The order does not matter, and each element counts only once, so we write it only once. The word “mathematics” has eleven letters, but the set of its letters has only eight elements: m, a, t, h, e, i, c, s.
What do the signs ∈ and ∉ mean?
We write that an element belongs to a set with the sign ∈, and that it does not belong with the sign ∉. For the set B = {1, 2, 3, 4}:
We read the first as “2 belongs to the set B” or “2 is an element of B”, and the second as “7 does not belong to the set B”.
To the left of the sign ∈ there is always an element, and to the right - a set.
What are the most important sets of numbers?
Some sets of numbers come up so often that they have their own symbols - letters with a double stroke:
- ℕ - the natural numbers: 0, 1, 2, 3, … In Polish schools zero is a natural number;
- ℤ - the integers: …, −2, −1, 0, 1, 2, …, that is, the natural numbers and their opposites;
- ℚ - the rational numbers, that is, numbers that can be written as a fraction p/q, where p and q are integers and q ≠ 0. For example, 1/2, −3 = −3/1 and 0.75 = 3/4 are rational;
- the irrational numbers - real numbers that cannot be written as such a fraction, for example √2 and π. Their decimal expansion is infinite and does not repeat;
- ℝ - the real numbers, that is, the rational and the irrational numbers together. These are all the numbers that correspond to points on the number line.
Where do these letters come from? ℕ and ℝ are the first letters of “natural” and “real”. ℤ comes from the German word Zahlen, meaning “numbers”, and ℚ from the word “quotient”: a rational number is the quotient of two integers.
With these symbols, statements about numbers become very short:
Which of the sets ℕ, ℤ, ℚ and ℝ does −5 belong to? What about 0.75? And √9?
Hint: Before you decide, write each number in its simplest form. The square root too.
Show the answerHide the answer
Answer
The number −5 is an integer but not a natural number, so it belongs to ℤ, ℚ and ℝ. The number 0.75 is 3/4 - rational but not an integer, so it belongs only to ℚ and ℝ. And √9 is simply 3, a natural number - it belongs to all four sets.
How can you describe a set?
The same set can be described in several ways. Take the set of positive even numbers less than 10. You can:
- describe it in words - as we just did;
- list its elements inside curly brackets;
- give a condition that its elements satisfy - more on that in a moment;
- draw it, writing its elements inside a circle.
Listing the elements works well when there are only a few of them. An infinite set can also be written this way if it is clear how the elements continue: ℕ = {0, 1, 2, 3, …}. When there are very many elements, or they cannot be put in a row, we give a condition instead.
How do you read a set described by a condition?
We read {x ∈ ℤ : −2 ≤ x < 3} as “the set of those integers x for which −2 ≤ x < 3”. Before the colon we say where the elements come from, and after it - the condition they must satisfy. Instead of a colon you can use a vertical bar: {x ∈ ℤ | −2 ≤ x < 3}.
The number −2 belongs to this set, because the inequality −2 ≤ x allows equality. The number 3 does not, because x < 3 is a strict inequality. With every description like this, check two things: which set x comes from, and whether the inequality is strict.
Watch out for zero
In Polish schools 0 is a natural number - and it is the one that is easiest to forget:
incorrect
correct
List the elements of the sets D and E.
Hint: For D, remember zero and check whether 4 satisfies the condition. For E, both inequalities are strict.
Show the answerHide the answer
Answer
D contains zero and the number 4, because x ≤ 4 allows equality. E contains neither −2 nor 2, because both inequalities are strict - that leaves −1, 0 and 1.
When is a set finite, and when is it empty?
A set is finite when its elements can be counted - the number of elements is some natural number. The set P = {2, 4, 6, 8} has four elements. A set is infinite when it has infinitely many elements. That is true of ℕ, ℤ, ℚ and ℝ, but also, for example, of the set of even numbers.
The set that has no elements at all is called the empty set and is written ∅.
For example, the set of natural numbers less than zero and the set of real numbers whose square is negative are both empty. They are two descriptions of the same set - there is only one empty set. It is also a finite set: it has 0 elements.
The empty set is not {0}
The set {0} is not empty - it has one element, the number zero. The empty set has none:
incorrect
correct
When are two sets equal?
The sets A and B are equal when they have exactly the same elements: every element of A belongs to B and every element of B belongs to A. We then write A = B.
All that matters is what belongs to the set - not the order of the elements and not the way the set is written. The set of solutions of the equation x² = 4 and the set {−2, 2} are the same set, even though they are described quite differently. The same goes here:
For two sets not to be equal, one element that belongs to one of them but not to the other is enough. Here it is the number 3:
What is a subset?
The set A is contained in the set B when every element of A is also an element of B. We then say that A is a subset of B and write A ⊂ B.
If even one element of A does not belong to B, then A is not a subset of B. We then write A ⊄ B. For example, {2, 5} is not contained in {1, 2, 3, 4}, because 5 does not belong to the second set:
Two things that surprise people
- Every set is a subset of itself: A ⊂ A, because every element of A obviously belongs to A.
- The empty set is a subset of every set: ∅ ⊂ A. The empty set has no elements - so it has no element that fails to belong to A.
In Polish textbooks the sign ⊂ allows the two sets to be equal, which is why A ⊂ A is true. Many books, especially English-language ones, write inclusion as ⊆ and use ⊂ only for a subset that is not the whole set.
Inclusion is handy for checking equality: A = B exactly when A ⊂ B and B ⊂ A. In practice, that is how you prove two sets are equal.
The number sets sit inside one another: every natural number is an integer, every integer is rational, and every rational number is real.
The most common mistake: ∈ instead of ⊂
The sign ∈ links an element to a set, and the sign ⊂ links a set to a set. The number 2 is an element, while {2} is a set with one element:
correct
correct
incorrect
incorrect
Which of these are correct: 0 ∈ ℕ, {0} ⊂ ℕ, 0 ⊂ ℕ, ∅ ⊂ ℕ?
Hint: First decide what is on the left: an element or a set.
Show the answerHide the answer
Answer
Three are correct: 0 ∈ ℕ, {0} ⊂ ℕ and ∅ ⊂ ℕ (the empty set is a subset of every set). Writing 0 ⊂ ℕ is wrong - 0 is an element, not a set, so it needs the sign ∈.
What is the universal set U?
In every problem it is clear what kind of objects we are talking about: the numbers from 1 to 8, the students in one class or all the real numbers. The set of all the elements we are considering in a given situation is called the universal set and is written U.
The universal set U is a set of which all the sets considered in a given problem are subsets.
On a Venn diagram the universal set is drawn as a rectangle and the sets as circles inside it. We will show every operation on these three sets:
In probability, which you will meet later, the universal set is the set of all possible outcomes of an experiment. It is written Ω.
What is the union of sets?
The union of the sets A and B is the set of the elements that belong to A or to B. It is written A ∪ B.
“Or” in maths does not exclude both at once: an element that belongs to both sets also goes into the union - but we write it only once.
The sign ∪ is easy to remember: it looks like the letter U, as in “union”. The order of the sets in a union does not matter:
What is the difference of sets?
The difference of the sets A and B is the set of the elements that belong to A and do not belong to B. It is written A \ B or A − B.
In a difference the order matters! B \ A is the elements of B that are not in A - a completely different set:
A difference is an easy way to describe the irrational numbers: they are the real numbers that are not rational, that is, the set ℝ \ ℚ.
What is the intersection of sets?
The intersection of the sets A and B is the set of the elements that belong to both A and B at the same time. It is written A ∩ B.
Here, again, the order does not matter:
A is the set of the natural divisors of 12, and B is the set of the natural divisors of 18. List the elements of both sets and find A ∩ B. What is the largest number in this intersection?
Hint: Divisors are easiest to list in pairs: 12 = 1 · 12 = 2 · 6 = 3 · 4.
Show the answerHide the answer
Answer
The intersection is the common divisors of 12 and 18. The largest of them, 6, is their greatest common divisor: gcd(12, 18) = 6.
When are sets disjoint?
Sets that have no element in common are called disjoint. Their intersection is the empty set.
The set of even numbers and the set of odd numbers are disjoint too: no integer is both even and odd.
What is the complement of a set?
The complement of the set A in the universal set U is the set of the elements of U that do not belong to A. It is written A′. It is simply the difference U \ A.
The complement depends on the universal set. When the universal set is ℤ, the complement of ℕ is the negative integers: …, −3, −2, −1. If the universal set were ℕ itself, the complement of ℕ would be the empty set.
A few properties of the complement can be seen straight from the diagram:
The sets C and D from the previous part complement each other: in the universal set U = {1, 2, 3, 4, 5, 6, 7, 8} everything that does not belong to C belongs to D.
Time to practise. In each round, shade the set described by the formula on the diagram - click the regions that belong to it.
Click the regions that belong to the set:
Worked examples, step by step
All the subsets of a four-element set
List all the subsets of A with one, two and three elements. Give its subset with four elements. How many subsets does A have?
- 1
Subsets with one element: put each element into a set of its own. There are four:
- 2
List the two-element subsets in order, so that you neither miss nor repeat any. First the pairs with a: with b, with c and with d. Then the pairs with b - but without a, because {b, a} is the same set as {a, b}: with c and with d. Finally c with d:
- 3
The three-element subsets are easiest to find the other way round: each one is A with one element removed. You can remove d, c, b or a - so there are four:
- 4
There is just one four-element subset - A itself. After all, every set is a subset of itself:
- 5
Do not forget the empty set - the subset with no elements. Now add them all up:
- 6
How can we be sure nothing was missed? When you build a subset, you decide about each of the four elements separately: you either take it or you do not. Each element gives two choices:
Union, intersection and difference of number sets
Find A ∪ B, A ∩ B, A \ B and B \ A.
- 1
First list the elements of A. They are the integers greater than −3 and not greater than 2. The number −3 is not in A, because −3 < x is strict, but 2 is:
- 2
Now B. These are the natural numbers less than 5 - remember that zero is a natural number too, and 5 is not in B:
- 3
Draw both sets on a diagram. The numbers 0, 1 and 2 belong to both, so they go in the overlap:
- 4
The union is all the elements of both sets, each written once:
- 5
The intersection is the elements that belong to both sets:
- 6
The difference A \ B is the elements of A that are not in B - the negative numbers in A:
- 7
The difference B \ A is the elements of B that are not in A:
Complements in a universal set
The universal set is U. A is the set of the even numbers in U, and B is the set of the prime numbers in U. Find A′, B′, A′ ∪ B, B′ ∩ A and A′ \ B′.
- 1
List the sets A and B. The number 1 is not prime - a prime number has exactly two divisors, and 1 has only one. Of the even numbers, only 2 is prime:
- 2
Put everything on a diagram - it makes the next sets easier to read off. The numbers 1 and 9 are neither even nor prime, so they sit outside the circles:
- 3
A′ is the numbers in U that are not even, that is, the odd numbers:
- 4
B′ is the numbers in U that are not prime:
- 5
A′ ∪ B is all the odd numbers plus the primes. Only 2 is new, because 3, 5 and 7 are already in A′:
- 6
B′ ∩ A is the numbers that are not prime and are even at the same time:
- 7
A′ \ B′ is the numbers in A′ that are not in B′. From the odd numbers 1, 3, 5, 7, 9 you remove those that are not prime (1 and 9). What is left is the odd primes:
- 8
Notice that B′ ∩ A is the same as A \ B, and A′ \ B′ is the same as B \ A. This is no accident: it holds for any sets, which is easy to check on a diagram.
Where are sets useful?
- Filters in an online shop are operations on sets. You tick “size M” and “colour black”, and the shop shows the intersection: items that are size M and black at the same time. When you tick two colours, you usually get the union: items that are black or navy.
- A search engine knows the difference of sets. If you type jaguar -car, Google shows pages with the word “jaguar” but without the word “car”.
- When you arrange to meet friends, you are looking for an intersection: the days on which every one of you is free.
- A person allergic to gluten and nuts looks for products outside the set “contains gluten” and at the same time outside the set “contains nuts” - that is, the intersection of two complements.
- In probability, events are sets: “A or B” is the union of events, “A and B” is their intersection, and the event opposite to A is the complement A′. This notation appears in exam problems.
- Programmers use sets every day. In Python the set type has the operators | (union), & (intersection) and - (difference) - the same ones you now know from this lesson.
A puzzle to finish
There are 30 people in a class. 18 of them go to volleyball, 15 go to basketball, and 7 go to both.
How many people go to neither?
Show the solutionHide the solution
Solution
Four. It is tempting to add 18 + 15 = 33 - but that is more than the whole class! The 7 people who go to both were counted twice: once among the volleyball players and once among the basketball players. So 18 + 15 − 7 = 26 people go to at least one - that is the number of elements in the union. The remaining 30 − 26 = 4 go to neither - that is the complement of the union.
Remember
A set is a primitive notion. An element either belongs to a set (∈) or does not (∉), and a set can be contained in another set (⊂). Sets are equal when they have the same elements. The union A ∪ B is the elements in A or in B, the intersection A ∩ B - the elements in both at once, the difference A \ B - the elements of A that are not in B, and the complement A′ - the elements of U outside A. Disjoint sets have no elements in common, and a set with n elements has 2ⁿ subsets.
PhiBoard is a free online whiteboard for maths
This lesson is part of it. On the board itself you can draw a number line, a graph or a figure, write a formula and solve a problem together with a teacher or a friend - live, in the browser. Our app is completely free.
Check whether you really know it
Theory is half the way. Work through a few exercises on the same material - each with a step-by-step solution, no account and no fees.
Frequently asked questions
What is the empty set?
It is the set with no elements at all, written ∅. There is only one empty set, and it is a subset of every set. Note that {0} is not empty - it has one element, the number zero.
What is the difference between ∈ and ⊂?
The sign ∈ links an element to a set: 2 ∈ {1, 2, 3}. The sign ⊂ links a set to a set: {2} ⊂ {1, 2, 3}. Writing 2 ⊂ {1, 2, 3} is wrong, because the number 2 is not a set.
How many subsets does a set with n elements have?
It has 2ⁿ subsets, counting the empty set and the set itself. A set with four elements has 2⁴ = 16 subsets: 1 empty, 4 with one element, 6 with two, 4 with three and 1 with four.
What is the difference between the union and the intersection of sets?
The union A ∪ B contains every element that is in A or in B (or in both). The intersection A ∩ B contains only the elements that are in both sets at once. For A = {1, 2, 3} and B = {2, 3, 4} we get A ∪ B = {1, 2, 3, 4} and A ∩ B = {2, 3}.
Is A − B the same as A \ B?
Yes. Both mean the same difference of sets: the elements of A that do not belong to B. Order matters in a difference: A \ B and B \ A are usually different sets.
What is the complement of a set?
The complement A′ is the set of the elements of the universal set U that do not belong to A, that is, the difference U \ A. For example, for U = {1, 2, 3, 4, 5} and A = {1, 2} the complement is A′ = {3, 4, 5}.
Is 0 a natural number?
In Polish schools, yes: ℕ = {0, 1, 2, 3, …}. In many books, especially English-language ones, the natural numbers start from 1. It is a convention, so it is always worth checking which one is being used.