Union Intersection Calculator - Union, Intersection, Difference, Three-Set View

Use this union intersection calculator to find A ∪ B, A ∩ B, A \ B, B \ A, and the matching element counts from two or three typed sets.

Updated: June 16, 2026 • Free Tool

Union Intersection Calculator

Type the elements of A. Duplicates are removed.

Type the elements of B. The page computes the union, intersection, and differences from these two sets.

Optional third set. Toggle the switch on to add A ∪ B ∪ C and A ∩ B ∩ C.

Turn on to add the three-set union and intersection.

Numbers sort numerically so 10 follows 9.

Results

A ∪ B (union)
0elements
|A ∪ B| 0elements
A ∩ B (intersection) 0elements
|A ∩ B| 0elements
A \ B (A minus B) 0elements
|A \ B| 0elements
B \ A (B minus A) 0elements
|B \ A| 0elements
A ∪ B ∪ C (3-set union) 0elements
|A ∪ B ∪ C| 0elements
A ∩ B ∩ C (3-set intersection) 0elements
|A ∩ B ∩ C| 0elements

What Is a Union Intersection Calculator?

A union intersection calculator takes two or three sets you type in and returns the union, the intersection, both set differences, the symmetric difference, and the matching element counts from a single pass. Type the elements of A and B, optionally turn on the third set C, and the page prints the standard set-theory results alongside a sorted roster list.

  • Pre-calculus and discrete math homework: Check the union, intersection, and difference of two or three sets for problem sets written as a roster or a set-builder expression.
  • Probability sample-space work: Find A ∪ B and A ∩ B for two events, then drop the result into a probability calculation as the count of favorable outcomes.
  • Database and tag cleanups: Diff two tag or ID lists to see which entries are unique to A, unique to B, or shared.
  • Venn diagram sanity check: Read the four standard regions of a two-set Venn diagram directly off the page.

The page is intentionally narrow. It accepts plain text lists, deduplicates the entries, and applies the four standard set operations at once. With the third-set toggle on, the result panel also shows the union and intersection of A, B, and C.

If the set is described by a property rather than a roster, the set builder calculator page turns an interval or a rule into a roster form first and then hands the elements back to this page.

How the Union Intersection Calculator Works

The page parses each input as a list of tokens, deduplicates the tokens case-insensitively, and applies the set operations in a single pass.

A ∪ B = { x : x ∈ A or x ∈ B }; A ∩ B = { x : x ∈ A and x ∈ B }; A \ B = { x : x ∈ A and x ∉ B }; |A ∪ B| = |A| + |B| − |A ∩ B|
  • A, B, C: Input sets. The user types comma-, space-, or newline-separated tokens; the page deduplicates them and lower-cases for membership tests only.
  • A ∪ B (union): Every element in A, in B, or in both. Element count is |A| + |B| − |A ∩ B|.
  • A ∩ B (intersection): The elements that are in A and in B at the same time.
  • A \ B (difference): The elements in A but not in B; the page also returns B \ A by symmetry.
  • Symmetric difference: A △ B = (A \ B) ∪ (B \ A); every element in exactly one of the two sets.

The same logic extends to three sets. A ∪ B ∪ C concatenates the three input lists with duplicates removed, and A ∩ B ∩ C keeps only the elements that appear in every list. The page returns the full union, the full intersection, and the per-input set sizes.

Worked example: A = {1, 2, 3, 4, 5} and B = {4, 5, 6, 7, 8}

A = {1, 2, 3, 4, 5}; B = {4, 5, 6, 7, 8}; third set off.

A ∪ B = {1, 2, 3, 4, 5, 6, 7, 8}; A ∩ B = {4, 5}; A \ B = {1, 2, 3}; B \ A = {6, 7, 8}; symmetric difference = {1, 2, 3, 6, 7, 8}.

Union size 8 (|A| + |B| − |A ∩ B| = 5 + 5 − 2 = 8), intersection size 2, A \ B size 3, B \ A size 3, symmetric difference size 6.

The two sets share only 4 and 5, so the union is the concatenation with the overlap removed, and the symmetric difference is everything in exactly one set.

According to Wolfram MathWorld - Set Union, the union of two sets A and B is the set of elements that are in A, in B, or in both, and the size of the union is |A| + |B| − |A ∩ B|.

According to Wolfram MathWorld - Set Intersection, the intersection A ∩ B is the set of elements common to both A and B, and the inclusion-exclusion formula |A ∪ B| = |A| + |B| − |A ∩ B| prevents double-counting in the union.

When the same sets need the full 2^n subset listing, the power set calculator page enumerates every subset of A while this page returns the union, intersection, and difference of two or three sets.

Key Concepts Behind Set Operations

Four ideas explain every output on the result panel.

Union

The union A ∪ B is every element in A, in B, or in both. The size is |A| + |B| − |A ∩ B| so the shared elements are not double-counted.

Intersection

The intersection A ∩ B is every element in A and in B at the same time. When A ∩ B is empty the two sets are called disjoint.

Set difference

A \ B keeps the elements of A that are not in B. B \ A is the reverse; the symmetric difference A △ B is the union of the two differences.

Venn regions

The four standard Venn regions for two sets are A only, B only, A ∩ B, and outside both. The page reports the size of each region.

These four ideas cover every output on the result panel: the union list is the union, the intersection list is the intersection, the two difference lists are the two single-set regions, and the symmetric difference is the union of the two difference lists.

When the question is whether A is contained in B, the subset calculator page answers the membership question by listing every subset of a given size while this page answers the union, intersection, and difference.

How to Use This Union Intersection Calculator

Five short steps cover every common case.

  1. 1 Type the elements of set A: Enter A as comma- or space-separated tokens. The page trims and deduplicates them.
  2. 2 Type the elements of set B: Enter B the same way. The default is {4, 5, 6, 7, 8}, which overlaps A on 4 and 5 to give a non-empty intersection.
  3. 3 Add an optional set C and toggle it on: Type the third set, then switch the toggle to Yes to add A ∪ B ∪ C and A ∩ B ∩ C.
  4. 4 Pick how the result lists are sorted: Choose ascending, descending, or input order. Numbers sort numerically.
  5. 5 Read the four standard regions and the counts: The result panel returns the union, intersection, A \ B, B \ A, the symmetric difference, and the three-set results when C is on.

Try A = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7, 8}, third-set off, ascending sort. The page prints A ∪ B = {1, 2, 3, 4, 5, 6, 7, 8} (8 elements), A ∩ B = {4, 5} (2 elements), A \ B = {1, 2, 3} (3 elements), B \ A = {6, 7, 8} (3 elements).

When the next question is how many ways the elements can be ordered, the permutation and combination calculator page handles the nPk and nCk counts.

Benefits of Using This Union Intersection Calculator

These benefits matter most when the answer has to be read in symbols, in a roster list, and as a count.

  • See union, intersection, and both differences from one input: The page prints A ∪ B, A ∩ B, A \ B, B \ A, the symmetric difference, and the per-set sizes from the same input boxes.
  • Skip the off-by-one duplicate trap: The page deduplicates the inputs and counts the union by inclusion-exclusion, so the counts and the lists never disagree.
  • Extend to three sets without retyping: A toggle adds the three-set union and intersection, so the same inputs work for both versions of a problem.
  • Read the answer in symbols or in a roster list: Every output is shown as a sorted comma-separated list and as a count.
  • Handle mixed-type sets: Numeric and text tokens coexist; the page keeps each distinct entry as a token and sorts numbers numerically.

The page is most useful as a set-theory and counting aid, not as a replacement for understanding the definitions.

When the two sets are continuous intervals on the real line, the interval notation calculator page handles the bracket and inequality form.

Factors That Affect the Union Intersection Result

The four inputs that drive the page are the elements of A, the elements of B, the optional elements of C, and the sort control. Each one shifts the result in a predictable way.

Overlap between A and B

The bigger the intersection, the closer |A ∪ B| gets to max(|A|, |B|). When A and B are disjoint, |A ∪ B| = |A| + |B|; when A = B, |A ∪ B| = |A|.

Whitespace, case, and punctuation

The page trims each token and treats tokens case-insensitively for the membership test, so { Cat, cat } becomes a single-element set.

Duplicates in the input

The page deduplicates each input set before the membership test, so a repeated element does not double-count it in the union or the intersection.

Third-set toggle

Turning the toggle off hides the A ∪ B ∪ C and A ∩ B ∩ C rows and their counts. Turning it on without typing C just adds the empty set to those results.

  • The page works on finite, explicitly listed sets. It does not compute the union or intersection of two infinite sets given by a rule, and it does not return the complement of a set inside a sample space unless the sample space is typed in as a third set.
  • Numeric tokens are compared as strings for the membership test, not as values, so 01 and 1 are treated as different tokens. Use the same notation across all three inputs to keep the intersection count clean.

The factors and limitations are the same idea seen from two sides: the factors describe what the user can change, and the limitations describe what the page is intentionally not doing.

According to Khan Academy - Set Operations, the union combines every element from both sets, the intersection keeps only the elements that appear in both, and the set difference A \ B keeps the elements of A that are not in B.

When the next step is to turn |A ∩ B| into a probability, the probability calculator page takes |A ∩ B| and |sample space| alongside any independent event and returns a numeric probability from 0 to 1.

union intersection calculator showing two sets A and B as a Venn diagram with the union, intersection, and A minus B and B minus A regions filled, plus element counts for each set
union intersection calculator showing two sets A and B as a Venn diagram with the union, intersection, and A minus B and B minus A regions filled, plus element counts for each set

Frequently Asked Questions

Q: What does a union intersection calculator do?

A: A union intersection calculator takes two or three sets you type in and returns the union A ∪ B, the intersection A ∩ B, the two differences A \ B and B \ A, the symmetric difference, and the matching element counts. With the third-set toggle on, it also returns the three-set union and intersection from the same inputs.

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

A: List every element of A, then add the elements of B that are not already listed, and that list is A ∪ B. List only the elements that appear in both A and B, and that list is A ∩ B. The page does both passes in one go and shows the sorted roster form and the counts.

Q: What is the formula for the union of two sets?

A: In symbols, A ∪ B = { x : x ∈ A or x ∈ B }. For the count, the inclusion-exclusion formula is |A ∪ B| = |A| + |B| − |A ∩ B|, which subtracts the intersection once so the shared elements are not double-counted.

Q: What is the difference between union and intersection?

A: The union A ∪ B is every element in A, in B, or in both, so it can only grow as more sets are added. The intersection A ∩ B is only the elements in A and in B at the same time, so it can only shrink as more sets are added. The symmetric difference combines the two single-set regions of the Venn diagram into one result.

Q: What is the symmetric difference of two sets?

A: The symmetric difference A △ B is the set of elements in A or in B but not in both, and equals (A \ B) ∪ (B \ A). The page returns it as the union of the A \ B and B \ A lists, deduplicated and sorted by the same control as the other results.

Q: Can this calculator handle three sets at once?

A: Yes. Type the elements of C and switch the Include third set control to Yes. The result panel then adds A ∪ B ∪ C and A ∩ B ∩ C, the two counts, and the per-set sizes, all from the same inputs.