Logic & Sets

Union and Intersection of Sets

The union A∪BA\cup B is the set of everything that is in AA or in BB (or both), and the intersection A∩BA\cap B is the set of everything that is in both. To count a union without listing it, use ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A\cup B|=|A|+|B|-|A\cap B|.

∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A \cup B| = |A| + |B| - |A \cap B|

Most lost points come from three places: repeating elements in a union, treating “or” as “one or the other but not both”, and fumbling endpoints in intervals. Each one gets a fix below, along with a clean way to see it in a Venn diagram.

What do union and intersection mean in set notation?

In set-builder form, the two operations are

A∪B={x:x∈A or x∈B},A∩B={x:x∈A and x∈B}.A\cup B=\{x : x\in A \text{ or } x\in B\},\qquad A\cap B=\{x : x\in A \text{ and } x\in B\}.

One clean idea explains both: the union is the smallest set that contains AA and BB together, and the intersection is the largest set that sits inside both. That gives a sanity check you can run on any answer: A∩B⊆A⊆A∪BA\cap B\subseteq A\subseteq A\cup B always holds. If your “intersection” contains something that is missing from AA, it is wrong. A handy picture: ∪\cup is a cup that holds everything, and ∩\cap is a cap that covers only the overlap. If the notation itself feels unfamiliar, the page on set notation covers braces, ∈\in and the builder form.

Order never matters, since A∪B=B∪AA\cup B=B\cup A and A∩B=B∩AA\cap B=B\cap A. A set also ignores repeats, so {1,2,2,3}\{1,2,2,3\} is just {1,2,3}\{1,2,3\}. That second fact is why unions never list a shared element twice.

Quick check

Let A={1,2,3}A=\{1,2,3\} and B={4,5,6}B=\{4,5,6\}. What is A∩BA\cap B?

How do you find the union and intersection of two sets?

For small sets, a short routine beats guessing:

  1. Rewrite each set with no repeats.
  2. For the intersection, scan the smaller set and keep an element only if the other set also contains it.
  3. For the union, copy the first set, then add each element of the second set that is not already there.
  4. Confirm the sizes with ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A\cup B|=|A|+|B|-|A\cap B|.

Example 1. Let A={2,4,6,8,10,12}A=\{2,4,6,8,10,12\} and B={3,6,9,12,15}B=\{3,6,9,12,15\}. Scanning BB: 33 is not in AA, 66 is, 99 is not, 1212 is, 1515 is not. So

A∩B={6,12}.A\cap B=\{6,12\}.

For the union, copy AA and add 33, 99 and 1515:

A∪B={2,3,4,6,8,9,10,12,15}.A\cup B=\{2,3,4,6,8,9,10,12,15\}.

Check: 6+5−2=96+5-2=9, and the union has nine elements.

Try this: List the multiples of 4 and of 6 up to 40, then write their intersection. Every element is a multiple of 12. Predict the intersection of the multiples of 6 and of 10 up to 100 before you list anything.

The pattern in that exercise is real: the intersection of multiples of mm and multiples of nn is the multiples of their least common multiple. The most common trap is the opposite mistake, writing the elements of both sets as the “intersection” when the sets share nothing. If there is no overlap, the answer is the empty set, not a merged list.

How do AND and OR connect to union and intersection?

Membership in a union is an OR statement and membership in an intersection is an AND statement. So every set identity is a logic identity wearing different symbols, and a truth table for the logical connectives can prove it row by row: the rows where x∈Ax\in A and x∈Bx\in B are both true correspond to the center of a Venn diagram.

Inclusive OR

An element in both sets still belongs to A∪BA\cup B. For "exactly one of the two", use (A∪B)∖(A∩B)(A\cup B)\setminus(A\cap B).

Everyday English is where the confusion starts. “Everyone in the choir and the band” usually means a union: you are naming two groups and want all their members. “Students who are in the choir and in the band” is an intersection: one condition after another, applied to the same person. A reliable test is to ask whether the word “and” joins groups of people (union) or joins requirements on one person (intersection).

How do you find the union and intersection of intervals?

Number line showing open intervals (1,3) and (3,5) whose union leaves a hole at 3
The union of (1,3) and (3,5) skips 3, but closing one bracket fills the hole.

Sketch both intervals on a number line first. For an intersection, take the larger left endpoint and the smaller right endpoint. If the left endpoint ends up beyond the right one, the intersection is empty. For a union, merge intervals that overlap or touch at an included point, and keep two pieces when there is a gap.

Example 2. Let A=[−3,4)A=[-3,4) and B=(2,9]B=(2,9]. The larger left endpoint is 22, from BB and open. The smaller right endpoint is 44, from AA and open. So

A∩B=(2,4).A\cap B=(2,4).

The intervals overlap, so the union is one piece running from the smallest left end (−3-3, closed) to the largest right end (99, closed):

A∪B=[−3,9].A\cup B=[-3,9].

Touching intervals are the classic trap. (1,3)∪(3,5)(1,3)\cup(3,5) is not (1,5)(1,5), because 33 is in neither piece. Change one bracket and it flips: (1,3]∪(3,5)=(1,5)(1,3]\cup(3,5)=(1,5). When two intervals share an endpoint on the same side, this table decides the bracket:

Same endpoint, both intervals Intersection Union
Both closed closed closed
One open, one closed open closed
Both open open open

Compound inequalities use the same logic. ”x≤−2x\le-2 or x>5x>5” is (−∞,−2]∪(5,∞)(-\infty,-2]\cup(5,\infty), while ”x>5x>5 and x≤−2x\le-2” has no solution at all. Infinity always gets a parenthesis, because it is not a number you can reach.

Quick check

Write the solution of x≤−2x\le -2 or x>5x>5 in interval notation.

Why does the inclusion-exclusion formula for a union work?

Bar model showing 70 plus 65 double counts 15 students, giving 120 in the union
Stacking the two groups gives 135, but the 15 students in both are counted twice, so the real total is 120.

Adding ∣A∣+∣B∣|A|+|B| counts every element of the overlap twice, once from each set. Subtracting ∣A∩B∣|A\cap B| once corrects that:

∣A∪B∣=∣A∣+∣B∣−∣A∩B∣.|A\cup B|=|A|+|B|-|A\cap B|.

Another view makes it obvious: A∪BA\cup B splits into three pieces that do not overlap (only AA, both, only BB), and ∣A∣|A| and ∣B∣|B| each include the middle piece.

Example 3 (working backwards). A survey of 120 students finds that 70 use app X, 65 use app Y, and everyone uses at least one. How many use both? Here ∣A∪B∣=120|A\cup B|=120, so

120=70+65−∣A∩B∣⇒∣A∩B∣=135−120=15.120=70+65-|A\cap B|\quad\Rightarrow\quad |A\cap B|=135-120=15.

Check: 5555 use only X, 5050 use only Y, 1515 use both, and 55+50+15=12055+50+15=120.

With three sets the pattern alternates signs:

∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣.|A\cup B\cup C|=|A|+|B|+|C|-|A\cap B|-|A\cap C|-|B\cap C|+|A\cap B\cap C|.

The triple overlap is counted three times by the singles and removed three times by the pair terms, so it needs to be added back once. Forgetting that last term is the usual error. The same formula holds for probabilities: P(A∪B)=P(A)+P(B)−P(A∩B)P(A\cup B)=P(A)+P(B)-P(A\cap B).

What happens with empty, disjoint and nested sets?

Sets are disjoint when A∩B=∅A\cap B=\emptyset, and then the formula collapses to plain addition, ∣A∪B∣=∣A∣+∣B∣|A\cup B|=|A|+|B|. Angles give a tidy example: the set of acute angles (0∘,90∘)(0^\circ,90^\circ) and the set of obtuse angles (90∘,180∘)(90^\circ,180^\circ) are disjoint, and their union is not the full interval (0∘,180∘)(0^\circ,180^\circ), because the right angle at 90∘90^\circ belongs to neither. The types of angles page lists the other categories.

Nested sets behave just as cleanly. If A⊆BA\subseteq B, then A∪B=BA\cup B=B and A∩B=AA\cap B=A. The empty set and the universal set UU act like identities: A∪∅=AA\cup\emptyset=A, A∩U=AA\cap U=A, while A∩∅=∅A\cap\emptyset=\emptyset and A∪U=UA\cup U=U. Think of ∅\emptyset as the zero of union and UU as the one of intersection.

Nested sets also give a neat test for equality. A=BA=B exactly when A∪B=A∩BA\cup B=A\cap B. If the union and intersection coincide, then A⊆A∪B=A∩B⊆BA\subseteq A\cup B=A\cap B\subseteq B, and the same argument runs the other way. This is the set version of a biconditional statement: each direction holds, so the sets are equal.

What are the distributive and De Morgan laws for sets?

Unlike addition and multiplication, each operation distributes over the other:

A∩(B∪C)=(A∩B)∪(A∩C),A∪(B∩C)=(A∪B)∩(A∪C).A\cap(B\cup C)=(A\cap B)\cup(A\cap C),\qquad A\cup(B\cap C)=(A\cup B)\cap(A\cup C).

Because ∪\cup and ∩\cap have no built-in precedence, parentheses are required whenever they are mixed. A∪(B∩C)A\cup(B\cap C) and (A∪B)∩C(A\cup B)\cap C are generally different sets.

The complement AcA^c means everything in UU outside AA. De Morgan’s laws say how it passes through a bracket:

(A∪B)c=Ac∩Bc,(A∩B)c=Ac∪Bc.(A\cup B)^c=A^c\cap B^c,\qquad (A\cap B)^c=A^c\cup B^c.

The reasoning is one sentence: not being in AA or BB means not being in AA and not being in BB. Test it with U={1,…,6}U=\{1,\dots,6\}, A={1,2,3}A=\{1,2,3\}, B={3,4}B=\{3,4\}. Then (A∪B)c={1,2,3,4}c={5,6}(A\cup B)^c=\{1,2,3,4\}^c=\{5,6\}, and Ac∩Bc={4,5,6}∩{1,2,5,6}={5,6}A^c\cap B^c=\{4,5,6\}\cap\{1,2,5,6\}=\{5,6\}.

Break the bar, flip the sign

To split a complement over a bracket, break the bar over each set and swap ∪\cup with ∩\cap.

The same flip explains why "A⊆BA\subseteq B" is equivalent to "Bc⊆AcB^c\subseteq A^c". That is the contrapositive of “if x∈Ax\in A then x∈Bx\in B”, and the page on converse, inverse and contrapositive shows why a statement and its contrapositive always agree.

Quick check

Let U={1,2,…,10}U=\{1,2,\dots,10\}, A={1,2,3,4}A=\{1,2,3,4\} and B={3,4,5,6}B=\{3,4,5,6\}. Find (A∩B)c(A\cap B)^c.

Where do union and intersection appear in algebra?

Solving a system of equations is an intersection: the solution set is the points that satisfy the first equation and the second. Two lines in slope-intercept form, such as y=2x+1y=2x+1 and y=2x−3y=2x-3, have the same slope and different intercepts, so their intersection is empty. For a system ax+by=eax+by=e, cx+dy=fcx+dy=f, the 2×2 determinant ad−bcad-bc decides the outcome: nonzero means exactly one intersection point, and zero means the lines are parallel (empty) or identical (the whole line).

Unions come from “or”. The equation (x−1)(x−4)=0(x-1)(x-4)=0 says x−1=0x-1=0 or x−4=0x-4=0, so the solution set is {1}∪{4}\{1\}\cup\{4\}. The same idea sits behind every quadratic you solve with the formula; the quadratic formula practice problems show the two roots arriving as a union of two solution sets.

Domains combine both. The domain of f(x)=ln⁡(x−1)+ln⁡(5−x)f(x)=\ln(x-1)+\ln(5-x) is the intersection of x>1x>1 and x<5x<5, which is (1,5)(1,5), because a sum needs both pieces defined (the logarithm rules explain why inputs must be positive). By contrast, the domain of 1x−2\frac{1}{x-2} is a union, (−∞,2)∪(2,∞)(-\infty,2)\cup(2,\infty). Even arithmetic sequences use it: the terms shared by 2,5,8,11,…2,5,8,11,\dots and 3,7,11,15,…3,7,11,15,\dots are 11,23,35,…11,23,35,\dots, a new sequence with difference 1212, and you can sum it with the arithmetic series formula. Databases borrow the vocabulary too: SQL has UNION and INTERSECT for combining query results.

How do you check a union and intersection answer?

Run these quick tests before you trust a result:

  • Size bounds: max⁡(∣A∣,∣B∣)≤∣A∪B∣≤∣A∣+∣B∣\max(|A|,|B|)\le|A\cup B|\le|A|+|B| and 0≤∣A∩B∣≤min⁡(∣A∣,∣B∣)0\le|A\cap B|\le\min(|A|,|B|).
  • Count match: the number of listed elements in the union must equal ∣A∣+∣B∣−∣A∩B∣|A|+|B|-|A\cap B|.
  • Membership test: every element of the intersection must appear in both original sets, and every element of the union must appear in at least one.
  • No repeats: each element appears once, in any order.

Take the claim {1,2,3}∩{4,5,6}={4,5,6}\{1,2,3\}\cap\{4,5,6\}=\{4,5,6\}. The membership test kills it at once, since 44 is not in the first set. The size bound agrees: an intersection can never have more elements than the smaller set allows, and here it should have zero.

For intervals, test sample points. Pick one number inside each piece of your answer and one outside, then substitute them into the original conditions. For (2,4)(2,4) as the answer in Example 2, try 33 (in both intervals, so it belongs) and 44 (not in [−3,4)[-3,4), so it does not). Two or three test points catch nearly every endpoint error.

Practice problems

0 of 5 solved

  1. Let A={1,3,5,7,9}A=\{1,3,5,7,9\} and B={3,6,9,12}B=\{3,6,9,12\}. Find A∪BA\cup B and A∩BA\cap B.

  2. Find (−∞,4]∩(−1,7)(-\infty,4]\cap(-1,7).

  3. Write [−5,1)∪[1,6)[-5,1)\cup[1,6) as a single interval.

  4. Among 50 people, 30 own a bike, 22 own a car and 9 own both. How many own neither?

  5. Given ∣A∣=30|A|=30, ∣B∣=25|B|=25, ∣C∣=20|C|=20, ∣A∩B∣=10|A\cap B|=10, ∣A∩C∣=8|A\cap C|=8, ∣B∩C∣=6|B\cap C|=6 and ∣A∩B∩C∣=4|A\cap B\cap C|=4, find ∣A∪B∪C∣|A\cup B\cup C|.

Common questions

What is the difference between union and intersection?

The union A∪BA\cup B collects every element that is in AA or in BB or in both. The intersection A∩BA\cap B keeps only the elements that are in both sets. The union is always at least as big as either set, and the intersection is never bigger than either one.

How do you find the number of elements in a union?

Add the sizes of the two sets and subtract the size of their intersection: ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣|A\cup B|=|A|+|B|-|A\cap B|. The subtraction removes the overlap, which was counted twice. If the sets are disjoint, the intersection is empty and you simply add.

What does it mean when the intersection of two sets is empty?

It means the sets are disjoint: they share no elements. The intersection is then written ∅\emptyset or {}\{\}. For example, the set of even integers and the set of odd integers have an empty intersection.

Does 'and' always mean intersection?

Not in word problems. 'Students in choir and band' can mean everyone in either group (a union), while 'students who are in choir and in band' means those in both (an intersection). In compound inequalities, 'and' means intersection and 'or' means union.

How do you write the union and intersection of intervals?

For an intersection, take the larger left endpoint and the smaller right endpoint, and return the empty set if they cross. For a union, merge intervals that overlap or touch at an included point, and keep separate pieces when there is a gap.

What are the symbols for union and intersection?

Union is ∪\cup (written \cup in LaTeX) and intersection is ∩\cap (written \cap). A capital letter U is not a valid substitute for the union symbol, since a capital U often stands for the universal set.

Up next