# Calculus

## Set Theory # Set Operations and Venn Diagrams

Sets are treated as mathematical objects. Similarly to numbers, we can perform certain mathematical operations on sets. Below we consider the principal operations involving the intersection, union, difference, symmetric difference, and the complement of sets.

To visualize set operations, we will use Venn diagrams. In a Venn diagram, a rectangle shows the universal set, and all other sets are usually represented by circles within the rectangle. The shaded region represents the result of the operation.

### Intersection of Sets

The intersection of two sets $$A$$ and $$B$$ is the set of elements which are in both sets $$A$$ and $$B.$$ The intersection of the two sets is written as $$A \cap B.$$

Two sets are called disjoint if they have no elements in common.

Examples:

1. $$A = \left\{ {a,b,c} \right\},$$ $$B = \left\{ {k,\ell,m} \right\}.$$ These two sets are disjoint as they have no common elements. Their intersection is the empty set.
2. $\require{AMSsymbols}{A \cap B = \left\{ {a,b,c} \right\} \cap \left\{ {k,l,m} \right\} }={ \varnothing.}$
3. $$C = \left\{ {1,2,3,4} \right\},$$ $$D = \left\{ {2,4,6,7} \right\}.$$ The intersection of these sets is
4. ${C \cap D = \left\{ {1,2,3,4} \right\} \cap \left\{ {2,4,6,7} \right\} }={ \left\{ {2,4} \right\}.}$

### Union of Sets

The union of two sets $$A$$ and $$B$$ is defined as the set of elements which are either in set $$A$$ or set $$B$$ or in both $$A$$ and $$B.$$ This operation is denoted by the $$\cup$$ symbol.

Examples:

1. $$A = \left\{ {a,b,c} \right\},$$ $$B = \left\{ {k,\ell,m} \right\}.$$ The union of the two sets is given by
2. ${A \cup B = \left\{ {a,b,c} \right\} \cup \left\{ {k,l,m} \right\} }={ \left\{ {a,b,c,k,l,m} \right\}.}$
3. $$C = \left\{ {1,2,3,4} \right\},$$ $$D = \left\{ {2,4,6,7} \right\}.$$ The union of the sets is given by
4. ${C \cup D = \left\{ {1,2,3,4} \right\} \cup \left\{ {2,4,6,7} \right\} }={ \left\{ {1,2,3,4,6,7} \right\}.}$

#### Cardinality of the Set Union

The cardinality of a finite set is defined as the number of elements in it. For example, the sets $$A$$ and $$B$$ below have the same cardinality (recall that we count only distinct elements):

${A = \left\{ {a,b,c,c} \right\},\;\;}\kern0pt{B = \left\{ {1,3,7,3,1} \right\},\;\;}\kern0pt{n\left( A \right) = n\left( B \right) = 3.}$

The cardinality of the union of two finite sets $$A$$ and $$B$$ is given by the following relationship:

${n\left( {A \cup B} \right) }={ n\left( A \right) + n\left( B \right) }-{ n\left( {A \cap B} \right),}$

where $$n\left( {A \cap B} \right)$$ is the number of elements (cardinality) of the intersection of $$A$$ and $$B.$$

The similar formula exists for the union of $$3$$ finite sets:

${n\left( {A \cup B \cup C} \right) }={ n\left( A \right) + n\left( B \right) + n\left( C \right) }-{ n\left( {A \cap B} \right) }-{ n\left( {A \cap C} \right) }-{ n\left( {B \cap C} \right) }+{ n\left( {A \cap B \cap C} \right).}$

### Difference of Two Sets

The difference of two sets $$A$$ and $$B$$ is the set that contains exactly all elements in $$A$$ but not in $$B.$$ The difference of two sets $$A$$ and $$B$$ is denoted by $$A \backslash B$$ or $$A – B.$$

Examples:

1. $$A = \left\{ {a,b,c} \right\},$$ $$B = \left\{ {k,\ell,m} \right\}.$$ The difference between two disjoint sets is equal to the initial set. So, we have
2. ${A \backslash B = A \backslash \left( {A \cap B} \right) }={ A \backslash \varnothing = A }={ \left\{ {a,b,c} \right\}.}$
3. $$C = \left\{ {1,2,3,4} \right\},$$ $$D = \left\{ {2,4,6,7} \right\}.$$ The difference of two sets $$C$$ and $$D$$ is given by
4. ${C \backslash D = \left\{ {1,2,3,4} \right\} – \left\{ {2,4,6,7} \right\} }={ \left\{ {1,3} \right\}.}$

### Symmetric Difference

The symmetric difference of two sets $$A$$ and $$B$$ is the set of all elements which belong to exactly one of the two original sets. This operation is written as $$A \,\triangle\, B$$ or $$A \oplus B.$$

In terms of unions and intersections, the symmetric difference of two sets $$A$$ and $$B$$ can be expressed as

$A \,\triangle\, B = \left( {A \cup B} \right) \backslash \left( {A \cap B} \right).$

Examples:

1. $$A = \left\{ {a,b,c} \right\},$$ $$B = \left\{ {k,\ell,m} \right\}.$$ The symmetric difference of two disjoint sets is equal to their union:
2. ${A \,\triangle\, B }={ \left( {A \cup B} \right) \backslash \left( {A \cap B} \right) }={ \left( {A \cup B} \right) \backslash \varnothing }={ A \cup B }={ \left\{ {a,b,c,k,\ell,m} \right\}.}$
3. $$C = \left\{ {1,2,3,4} \right\},$$ $$D = \left\{ {2,4,6,7} \right\}.$$ The symmetric difference of the sets $$C$$ and $$D$$ is given by
4. ${C \,\triangle\, D }={ \left( {C \cup D} \right) \backslash \left( {C \cap D} \right) }={ \left\{ {1,2,3,4,6,7} \right\} – \left\{ {2,4} \right\} }={ \left\{ {1,3,6,7} \right\}.}$

### Complement of a Set

The complement of a set $$A$$ is the set of elements in the given universal set $$U$$ that are not elements of $$A.$$ The complement of $$A$$ is denoted by $${A^c}$$ or $$A^\prime,$$ or sometimes $$\bar A.$$

So by definition, we have

$A^c = U \backslash A.$

Examples:

1. Let the universal set be $$U = \left\{ {a,b,c,d,e,f} \right\}.$$ If $$A = \left\{ {a,b,d,f} \right\},$$ then the complement of $$A$$ is given by
2. ${A^c} = U \backslash A = \left\{ {c,e} \right\}.$
3. Suppose the universal set is $$U = \{ x \in \mathbb{Z} \mid {x^2} \lt 20\}$$ and the set $$A$$ is given by $$A = \{ x \in \mathbb{Z} \mid -3 \le x \lt 3\}.$$ Find the complement of $$A.$$
4. ${U = \{- 4,- 3,- 2,- 1,0,1,2,3,4\},\;\;}\kern0pt{A = \{- 3,- 2,- 1,0,1,2\},}\;\;\Rightarrow {{A^c} = \{- 4,3,4\} .}$

## Solved Problems

Click or tap a problem to see the solution.

### Example 1

Given $$A = \left\{ {2,3,4,5,6,7} \right\}$$ and $$B = \left\{ {0,1,5,6} \right\}.$$ List the elements of the following sets:
1. $${A \cup B}$$
2. $${A \cap B}$$
3. $${A \backslash B}$$
4. $${B \backslash A}$$
5. $${A \,\triangle\, B}$$

### Example 2

Let the universal set be $$U = \{ x \in \mathbb{N} \mid x \le 10\}.$$ Its subsets $$A$$ and $$B$$ are given by $$A = \{ x \mid x \text{ is even}\},$$ $$B = \{ x \in \mathbb{N} \mid 5 \le x \lt 8\}.$$ Find the following sets:
1. $$A \cup {B^c}$$
2. $${\left( {A \cap B} \right)^c}$$
3. $${\left( {A\backslash B} \right)^c}$$

### Example 3

Find the elements of the sets $$A$$ and $$B$$ if $$A \backslash B = \left\{ {1,2,7,8} \right\},$$ $$B \backslash A = \left\{ {3,4,9} \right\}$$ and $$A \cap B = \left\{ {0,5,6} \right\}.$$

### Example 4

Find the elements of the sets $$A$$ and $$B$$ if $$A \backslash B = \left\{ {a,b,d} \right\},$$ $$A \cap B = \left\{ {c,e} \right\}$$ and $$A \cup B = \left\{ {a,b,c,d,e,g} \right\}.$$

### Example 5

Let $$A, B,$$ and $$C$$ be sets. Draw the Venn diagram for $$A \cap \left( {B \backslash C} \right).$$

### Example 6

Let $$A, B,$$ and $$C$$ be sets. Draw the Venn diagram for $$\left( {A \cap {B^c}} \right) \cup \left( {A \cap {C^c}} \right).$$

### Example 7

In a high school, $$100$$ students are surveyed and asked which of the foreign languages they learn. $$45$$ students learn Spanish, $$28$$ learn French, and $$22$$ learn Chinese. $$12$$ students learn Spanish and French, $$8$$ learn Spanish and Chinese, and $$10$$ learn French and Chinese. $$30$$ students learn no language. How many students learn three languages?

### Example 8

Let $$S$$ be a finite set of natural numbers. It is known that there are $$80$$ numbers among them multiple of $$2,$$ $$95$$ numbers multiple of $$3,$$ $$70$$ numbers multiple of $$5,$$ $$30$$ numbers multiple of $$6,$$ $$33$$ numbers multiple of $$10,$$ $$25$$ numbers multiple of $$15,$$ and $$13$$ numbers multiple of $$30.$$ Find the cardinality of the set $$S.$$

### Example 1.

Given $$A = \left\{ {2,3,4,5,6,7} \right\}$$ and $$B = \left\{ {0,1,5,6} \right\}.$$ List the elements of the following sets:
1. $${A \cup B}$$
2. $${A \cap B}$$
3. $${A \backslash B}$$
4. $${B \backslash A}$$
5. $${A \,\triangle\, B}$$

Solution.

1. By definition, the union of sets $${A \cup B}$$ contains all elements which are either in set $$A$$ or set $$B$$ or in both $$A$$ and $$B.$$ Therefore, we can write
2. ${A \cup B }={ \left\{ {2,3,4,5,6,7} \right\} \cup \left\{ {0,1,5,6} \right\} }={ \left\{ {0,1,2,3,4,5,6,7} \right\}.}$
3. The intersection of sets $${A \cap B}$$ is defined as the set containing all elements of $$A$$ that also belong to $$B.$$ Using this definition, we obtain
4. ${A \cap B }={ \left\{ {2,3,4,5,6,7} \right\} \cup \left\{ {0,1,5,6} \right\} }={ \left\{ {5,6} \right\}.}$
5. The set difference $${A \backslash B}$$ contains only those elements of $$A$$ that do not belong to $$B.$$
6. ${A\backslash B }={ \left\{ {2,3,4,5,6,7} \right\}\backslash \left\{ {0,1,5,6} \right\} }={ \left\{ {2,3,4,7} \right\}.}$
7. This question is opposite of the previous one. The set difference $${B \backslash A}$$ contains only those elements of $$B$$ that do not belong to $$A.$$
8. ${B\backslash A }={ \left\{ {0,1,5,6} \right\}\backslash \left\{ {2,3,4,5,6,7} \right\} }={ \left\{ {0,1} \right\}.}$
9. We compute the symmetric difference $${A \,\triangle\, B}$$ by the formula $$A \,\triangle\, B = \left( {A\backslash B} \right) \cup \left( {B\backslash A} \right).$$ This yields:
10. ${A \,\triangle\, B }={ \left( {A\backslash B} \right) \cup \left( {B\backslash A} \right) }={ \left\{ {2,3,4,7} \right\} \cup \left\{ {0,1} \right\} }={ \left\{ {0,1,2,3,4,7} \right\}.}$

### Example 2.

Let the universal set be $$U = \{ x \in \mathbb{N} \mid x \le 10\}.$$ Its subsets $$A$$ and $$B$$ are given by $$A = \{ x \mid x \text{ is even}\},$$ $$B = \{ x \in \mathbb{N} \mid 5 \le x \lt 8\}.$$ Find the following sets:
1. $$A \cup {B^c}$$
2. $${\left( {A \cap B} \right)^c}$$
3. $${\left( {A\backslash B} \right)^c}$$

Solution.

1. The complement of the set $$B$$ is written as follows: ${{B^c} = U\backslash B }={ \left\{ {1,2, \ldots ,10} \right\}\backslash \{ 5,6,7\} }={ \{ 1,2,3,4,8,9,10\}.}$ The set $$A$$ in roster form is expressed as $$A = \{ 2,4,6,8,10\},$$ so the set union $$A \cup {B^c}$$ is given by ${A \cup {B^c} \text{ = }}\kern0pt{ \{ 2,4,6,8,10\} \cup \{ 1,2,3,4,8,9,10\} }={ \left\{ {1,2,3,4,6,8,9,10} \right\}.}$
2. First we determine the set intersection $${A \cap B}:$$ ${A \cap B }={ \{ 2,4,6,8,10\} \cap \{ 5,6,7\} }={ \left\{ 6 \right\}.}$ Now we compute the complement $${\left( {A \cap B} \right)^c}:$$ ${{\left( {A \cap B} \right)^c} }={ U\backslash \left( {A \cap B} \right) }={ \left\{ {1,2, \ldots ,10} \right\}\backslash \left\{ 6 \right\} }={ \left\{ {1,2,3,4,5,7,8,9,10} \right\}.}$
3. Find the set difference $${A\backslash B}$$ in roster form: ${A\backslash B }={ \{ 2,4,6,8,10\} \backslash \{ 5,6,7\} }={ \left\{ {2,4,8,10} \right\}.}$ Hence, the complement $${\left( {A\backslash B} \right)^c}$$ is given by ${{\left( {A\backslash B} \right)^c} }={ U\backslash \left( {A\backslash B} \right) }={ \left\{ {1,2, \ldots ,10} \right\}\backslash \left\{ {2,4,8,10} \right\} }={ \left\{ {1,3,5,6,7,9} \right\}.}$

### Example 3.

Find the elements of the sets $$A$$ and $$B$$ if $$A \backslash B = \left\{ {1,2,7,8} \right\},$$ $$B \backslash A = \left\{ {3,4,9} \right\}$$ and $$A \cap B = \left\{ {0,5,6} \right\}.$$

Solution.

We can express the set $$A$$ as follows:

$A = \left( {A\backslash B} \right) \cup \left( {A \cap B} \right).$

Compute the elements of the set $$A:$$

${A = \left( {A\backslash B} \right) \cup \left( {A \cap B} \right) }={ \left\{ {1,2,7,8} \right\} \cup \left\{ {0,5,6} \right\} }={ \left\{ {0,1,2,5,6,7,8} \right\}.}$

Similarly, we determine the elements of the set $$B:$$

${B = \left( {B\backslash A} \right) \cup \left( {A \cap B} \right) }={ \left\{ {3,4,9} \right\} \cup \left\{ {0,5,6} \right\} }={ \left\{ {0,3,4,5,6,9} \right\}.}$

### Example 4.

Find the elements of the sets $$A$$ and $$B$$ if $$A \backslash B = \left\{ {a,b,d} \right\},$$ $$A \cap B = \left\{ {c,e} \right\}$$ and $$A \cup B = \left\{ {a,b,c,d,e,g} \right\}.$$

Solution.

We can find the set $$A$$ as follows:

${A = \left( {A\backslash B} \right) \cup \left( {A \cap B} \right) }={ \left\{ {a,b,d} \right\} \cup \left\{ {c,e} \right\} }={ \left\{ {a,b,c,d,e} \right\}.}$

The set $$B$$ is given by

${B = \left( {A \cup B} \right)\backslash \left( {A\backslash B} \right) }={ \left\{ {a,b,c,d,e,g} \right\}\backslash \left\{ {a,b,d} \right\} }={ \left\{ {c,e,g} \right\}.}$

### Example 5.

Let $$A, B,$$ and $$C$$ be sets. Draw the Venn diagram for the set combination $$A \cap \left( {B \backslash C} \right).$$

Solution.

The region $$A \cap \left( {B\backslash C} \right)$$ is colored with orange.

### Example 6.

Let $$A, B,$$ and $$C$$ be sets. Draw the Venn diagram for $$\left( {A \cap {B^c}} \right) \cup \left( {A \cap {C^c}} \right).$$

Solution.

The region $$\left( {A \cap {B^c}} \right) \cup \left( {A \cap {C^c}} \right)$$ is colored with orange.

### Example 7.

In a high school, $$100$$ students are surveyed and asked which of the foreign languages they learn. $$45$$ students learn Spanish, $$28$$ learn French, and $$22$$ learn Chinese. $$12$$ students learn Spanish and French, $$8$$ learn Spanish and Chinese, and $$10$$ learn French and Chinese. $$30$$ students learn no language. How many students learn three languages?

Solution.

We denote the set of students learning Spanish by $$S$$, the set of students learning French – by $$F,$$ and the set of students learning Chinese – by $$C.$$

Let $$x$$ be the number of students learning the $$3$$ languages simultaneously. Draw the Venn diagram and express in terms of $$x$$ the number of students in all regions.

As the number of students learning Spanish and French is $$12,$$ the intersection between the sets $$S$$ and $$F$$ is represented in the form $$12 = x + \left( {12 – x} \right).$$

Similarly, since $$8$$ students learn Spanish and Chinese, we represent the intersection between the two sets as $$8 = x + \left( {8 – x} \right).$$

The last pair of French and Chinese is given by $$10 = x + \left( {10 – x} \right).$$

Recall that the total number of students learning Spanish is $$45.$$ Using the Venn diagram, we find that the remaining portion of the green circle $$S$$ contains the number of students equal to

${45 – \left[ {\left( {12 – x} \right) + x + \left( {8 – x} \right)} \right] }={ 25 + x.}$

Similarly, we can calculate the remaining portion of the blue circle $$F:$$

${28 – \left[ {\left( {12 – x} \right) + x + \left( {10 – x} \right)} \right] }={ 6 + x.}$

For the purple circle $$C$$ we have

${22 – \left[ {\left( {8 – x} \right) + x + \left( {10 – x} \right)} \right] }={ 4 + x.}$

Now all the partitions are expressed in terms of $$x,$$ so we can write the following equation:

${30 + \left( {4 + x} \right) }+{ \left( {25 + x} \right) }+{ \left( {6 + x} \right) }+{ \left( {12 – x} \right) }+{ \left( {8 – x} \right) }+{ \left( {10 – x} \right) + x }={ 100.}$

Solving it for $$x,$$ we find the number of students learning all $$3$$ languages:

$\require{cancel}{30 + 4 + \cancel{x} + 25 + \cancel{x} }+{ 6 + \cancel{x} }+{ 12 \cancel{- x} }+{ 8 \cancel{- x} }+{ 10 \cancel{- }x + x }+{ 100,}$

$\Rightarrow {95 + x = 100,}\;\; \Rightarrow {x = 5.}$

### Example 8.

Let $$S$$ be a finite set of natural numbers. It is known that there are $$80$$ numbers among them multiple of $$2,$$ $$95$$ numbers multiple of $$3,$$ $$70$$ numbers multiple of $$5,$$ $$30$$ numbers multiple of $$6,$$ $$33$$ numbers multiple of $$10,$$ $$25$$ numbers multiple of $$15,$$ and $$13$$ numbers multiple of $$30.$$ Find the cardinality of the set $$S.$$

Solution.

We denote the subsets of numbers multiple of $$2,$$ $$3,$$ and $$5$$, respectively by $$A,$$ $$B,$$ and $$C.$$ By condition,

${n\left( A \right) = 80,\;\;}\kern0pt{n\left( B \right) = 95,\;\;}\kern0pt{n\left( C \right) = 70.}$

If a number is multiple of $$6,$$ this means it is divisible by $$2$$ and $$3.$$ So such numbers belong to the intersection of the subsets $$A$$ and $$B,$$ and we can write:

$n\left( {A \cap B} \right) = 30.$

Similarly, we have

${n\left( {A \cap C} \right) = 33,\;\;}\kern0pt{n\left( {B \cap C} \right) = 25.}$

Finally, if a number is multiple of $$30,$$ this means it is divisible by $$2,$$ $$3,$$ and $$5.$$ Here we have the intersection of three subsets:

$n\left( {A \cap B \cap C} \right) = 13.$

The cardinality of the union of three sets is given by the formula

${n\left( {A \cup B \cup C} \right) }={ n\left( A \right) + n\left( B \right) + n\left( C \right) }-{ n\left( {A \cap B} \right) }-{ n\left( {A \cap C} \right) }-{ n\left( {B \cap C} \right) }+{ n\left( {A \cap B \cap C} \right).}$

By substituting the known values, we get:

${n\left( {A \cup B \cup C} \right) }={ 80 + 95 + 70 }-{ 30 – 33 – 25 }+{ 13 }={ 170.}$