terican

Last verified · v1.0

Calculator · math

Union And Intersection Calculator

Solve for set union or intersection using n(A∪B) = n(A) + n(B) − n(A∩B). Enter two set sizes and one known value to compute the other.

FreeInstantNo signupOpen source

Inputs

Set Size

Explain my result

0/3 free

Get a plain-English breakdown of your result with practical next steps.

Set Sizeelements

The formula

How the
result is
computed.

Union and Intersection Calculator: Formula, Derivation, and Applications

Set theory underpins probability, combinatorics, statistics, and database logic. The two most fundamental set operations — union and intersection — describe how collections of elements relate. This union intersection calculator applies the Inclusion-Exclusion Principle to compute either the union size or the intersection size when the other value is known.

The Inclusion-Exclusion Principle

The governing formula for any two finite sets A and B is:

n(A ∪ B) = n(A) + n(B) − n(A ∩ B)

This identity exists because a straightforward sum of n(A) and n(B) counts every element in the intersection twice — once for each set. Subtracting n(A ∩ B) once corrects the double-count, yielding the exact number of distinct elements across both sets combined.

Variable Definitions

  • n(A) — The cardinality of set A; the count of distinct elements in set A.
  • n(B) — The cardinality of set B; the count of distinct elements in set B.
  • n(A ∩ B) — Intersection size; elements belonging to both A and B simultaneously.
  • n(A ∪ B) — Union size; all elements appearing in at least one of the two sets.

Computing the Union from the Intersection

When n(A ∩ B) is the known quantity, apply the formula directly:

n(A ∪ B) = n(A) + n(B) − n(A ∩ B)

Example: A school survey shows 35 students play soccer (Set A) and 28 play basketball (Set B). Exactly 12 students play both. The count of students who play at least one sport equals 35 + 28 − 12 = 51 students.

Computing the Intersection from the Union

Rearranging the same equation isolates n(A ∩ B):

n(A ∩ B) = n(A) + n(B) − n(A ∪ B)

Example: In a class of 60 students, 40 passed Math and 35 passed English. A total of 55 students passed at least one subject. The number who passed both equals 40 + 35 − 55 = 20 students.

Disjoint Sets: The Zero-Intersection Special Case

When two sets share no elements, they are called disjoint, and n(A ∩ B) = 0. The formula simplifies to:

n(A ∪ B) = n(A) + n(B)

If Set A = {1, 2, 3} and Set B = {4, 5, 6}, these disjoint sets produce a union of exactly 3 + 3 = 6 elements. Mutually exclusive probability events follow this same pattern.

Mathematical Constraints for Valid Results

  • The intersection cannot exceed either set: n(A ∩ B) ≤ n(A) and n(A ∩ B) ≤ n(B).
  • The union must be at least as large as either set: n(A ∪ B) ≥ n(A) and n(A ∪ B) ≥ n(B).
  • All cardinality values must be non-negative integers.
  • The union cannot exceed n(A) + n(B), which would imply a negative intersection.

Real-World Applications

  • Probability theory: The Addition Rule P(A ∪ B) = P(A) + P(B) − P(A ∩ B) mirrors this formula exactly, making set cardinality the direct foundation of event probability calculations.
  • Survey and market research: Analysts use the formula to avoid double-counting respondents who satisfy multiple criteria, such as customers who own both Product A and Product B.
  • Database queries: SQL UNION and INTERSECT operations reflect these set principles when counting distinct records across two result sets.
  • Standardized testing: Venn diagram problems on college entrance exams and finite math exams consistently test the Inclusion-Exclusion Principle.

Academic Foundation

The Inclusion-Exclusion Principle is a required competency across college-level mathematics curricula. Northern Kentucky University's MAT 114 exam explicitly covers set operations including union and intersection as core testable material. Monroe Community College's MTH 096 course objectives list union, intersection, and complement as mandatory student competencies. The formula also appears in finite mathematics syllabi at New Hampshire Community Technical College, confirming its status as a standard topic across two-year and four-year institutions nationwide.

Reference

Frequently asked questions

What is the difference between union and intersection of two sets?
The union (A ∪ B) collects every element appearing in at least one of the two sets, while the intersection (A ∩ B) collects only elements present in both sets at the same time. For example, if A = {1, 2, 3} and B = {2, 3, 4}, then A ∪ B = {1, 2, 3, 4} with 4 elements, and A ∩ B = {2, 3} with only 2 elements. The union is always at least as large as either individual set, whereas the intersection is always at most as large as either set.
How does the Inclusion-Exclusion formula n(A ∪ B) = n(A) + n(B) − n(A ∩ B) work?
Adding n(A) and n(B) directly counts every element in the intersection twice — once per set. Subtracting n(A ∩ B) removes the duplicate count and returns the correct total of distinct elements. For example, if n(A) = 50, n(B) = 40, and n(A ∩ B) = 15, the union size equals 50 + 40 − 15 = 75. Rearranging the same equation gives the intersection: n(A ∩ B) = n(A) + n(B) − n(A ∪ B), which is equally useful when the union is already known.
What happens when two sets have no elements in common?
Sets with no shared elements are called disjoint sets, and their intersection is the empty set, so n(A ∩ B) = 0. The union formula reduces to n(A ∪ B) = n(A) + n(B) — no subtraction needed. For instance, if Set A has 25 elements and Set B has 18 elements with zero overlap, the union contains exactly 43 elements. In probability, mutually exclusive events behave the same way: P(A ∪ B) = P(A) + P(B) when P(A ∩ B) = 0.
Can the union of two sets ever be smaller than one of the individual sets?
No. The union always contains at least as many elements as the larger of the two sets, because it includes everything from both. Formally, n(A ∪ B) ≥ max(n(A), n(B)). The union equals n(A) only in the special case where B is a subset of A — every element of B already exists in A. In that scenario, n(A ∩ B) = n(B), and substituting into the formula confirms n(A ∪ B) = n(A) + n(B) − n(B) = n(A).
How does the union-intersection formula connect to probability theory?
The set cardinality formula translates directly into the Addition Rule for probability: P(A ∪ B) = P(A) + P(B) − P(A ∩ B). For example, if P(A) = 0.45, P(B) = 0.30, and P(A ∩ B) = 0.10, then P(A ∪ B) = 0.45 + 0.30 − 0.10 = 0.65. For mutually exclusive events where P(A ∩ B) = 0, the rule simplifies to simple addition. This connection makes the union intersection calculator directly applicable to basic probability problem-solving.
What are the most common real-world uses of union and intersection calculations?
Survey and market research top the list: if 130 customers use Service A, 95 use Service B, and 175 use at least one service, then 130 + 95 − 175 = 50 customers use both — avoiding double-counting. Healthcare researchers calculate patient overlap across diagnoses using the same method. Database administrators count unique records across overlapping query results. Educators and standardized test designers build Venn diagram word problems directly from this formula, making it one of the most tested relationships in finite mathematics curricula.