The formula for the union of two sets A and B is written as A ∪ B, and it represents the set of all elements that belong to A, or to B, or to both. In set-builder notation, A ∪ B = { x | x ∈ A or x ∈ B }. This page explains the formula, how to apply it, and how it relates to intersections and complements.
Formula
The fundamental formula for the size (cardinality) of the union of two sets is:
|A ∪ B| = |A| + |B| − |A ∩ B|
Where:
- |A| is the number of elements in set A.
- |B| is the number of elements in set B.
- |A ∩ B| is the number of elements that are in both A and B (the intersection).
This formula is often called the inclusion–exclusion principle for two sets. It works because when you add |A| and |B|, elements in the intersection are counted twice. Subtracting |A ∩ B| once corrects that double count.
Worked Example
Using the default values from the calculator: |A| = 5, |B| = 7, |A ∩ B| = 2.
- Add the sizes of A and B: 5 + 7 = 12.
- Subtract the intersection: 12 − 2 = 10.
So |A ∪ B| = 10. The calculator gives 10, confirming the arithmetic. The elements only in A are 5 − 2 = 3, and only in B are 7 − 2 = 5. Together: 3 + 5 + 2 (the overlap) = 10, which matches.
Assumptions
- Sets are finite; the formula counts distinct elements only.
- The intersection size |A ∩ B| is known or can be determined. If the sets are disjoint, |A ∩ B| = 0.
- Elements are unique within each set (no duplicates, as per set definition).
When to Use the Union Formula
Use the union formula whenever you need the total number of distinct items that appear in at least one of two groups. Common real-world situations include:
- Counting students who take at least one of two courses.
- Finding how many products have at least one of two features.
- Calculating the probability of event A or event B occurring: P(A ∪ B) = P(A) + P(B) − P(A ∩ B).
The formula is also the basis for more advanced counting in computer science (e.g., database queries, set operations) and in probability theory.
How to Read the Result
The result |A ∪ B| is a whole number: the count of distinct elements in the combined set. It is always at least max(|A|, |B|) and at most |A| + |B|. If the intersection is large, the union is close to the larger set; if the intersection is zero, the union is simply the sum.
For example, if |A| = 5 and |B| = 7, the union can range from 7 (if A is a subset of B) to 12 (if they share no elements). The intersection size tells you where in that range you are.
Common Mistakes and Misconceptions
- Forgetting to subtract the intersection: Adding |A| + |B| directly overcounts shared elements. This is the most frequent error.
- Assuming disjoint sets: Unless stated, sets may overlap. Always check for common elements.
- Confusing union with intersection: Union (∪) means “or” (at least one), intersection (∩) means “and” (both).
- Using the formula for three sets without extension: For three sets, the formula is |A ∪ B ∪ C| = |A| + |B| + |C| − |A∩B| − |A∩C| − |B∩C| + |A∩B∩C|. The two-set version does not generalize by simply adding more terms without the pairwise subtractions and the triple addition.
Relationships with Other Set Operations
The union is closely tied to intersection and complement. De Morgan’s laws relate them:
- (A ∪ B)c = Ac ∩ Bc
- (A ∩ B)c = Ac ∪ Bc
These laws are useful for simplifying expressions in logic and set theory. Also, the union is distributive over intersection: A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C).
Frequently Asked Questions
What does “A ∪ B” mean in plain English?
It means “the set of everything that is in A, or in B, or in both.” For example, if A = {1, 2} and B = {2, 3}, then A ∪ B = {1, 2, 3}.
How do I find the union if the sets are given as lists?
Combine all elements from both lists, then remove duplicates. For instance, A = {a, b, c}, B = {c, d} → union = {a, b, c, d}.
What if the sets have no elements in common?
Then the intersection is empty, so |A ∩ B| = 0, and the formula simplifies to |A ∪ B| = |A| + |B|. The sets are called disjoint.
Is the union formula the same as the probability formula?
Yes, the probability of A or B occurring is P(A ∪ B) = P(A) + P(B) − P(A ∩ B), which mirrors the set cardinality formula. The same logic of avoiding double-counting applies.
Can I use this formula for three sets?
Yes, but you need the extended version: |A ∪ B ∪ C| = |A| + |B| + |C| − |A∩B| − |A∩C| − |B∩C| + |A∩B∩C|. The pattern continues for more sets with alternating signs.
Why is the union size never larger than the sum of the sizes?
Because the union only includes each distinct element once. The sum |A| + |B| counts elements in the intersection twice; subtracting the intersection removes that duplicate count, so the result cannot exceed the sum.
Related
Formula used
in nA | Number of elements in set A | - | 5 | 0 in nB | Number of elements in set B | - | 7 | 0 in nAB | Number of elements in both A and B (intersection) | - | 2 | 0 out union | Size of A ∪ B | elements | nA + nB - nAB | 0 out inter | Size of A ∩ B | elements | nAB | 0 out onlyA | Elements only in A | elements | nA - nAB | 0 out onlyB | Elements only in B | elements | nB - nAB | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation with the constants and conversion factors written on the page, rounded as each result states. See method and constants, the disclaimer or report an error.
More in this section
- Mole Fraction: Formula and Calculation Steps0.2000 mol/L
- Tidal Volume Percent: Normal Range & How to Calculate87.0 %
- PPM to Volume Percentage: How to Convert0.0500 %
- PowerShell Set Volume to 80%: Script & Guide
- Percentage to Volume? Convert % to mL12.50 mL
- Percent Volume Equation: Formula, Uses & Examples10.00 %