Calculator

Set operations calculator

Enter two sets as comma separated lists and get their union, intersection, difference and more.

  • No account needed
  • Nothing leaves your browser
  • Works offline

What is in here

7topics
534problems
54formulas
60proof tasks
0 learned0 saved0 practice attempts0% accuracy0 proof checks

Calculators

Discrete math tools

Six calculators that run entirely in this browser. Inputs are validated, so a rejected entry says what is wrong instead of returning a confident wrong answer.

Sets

Set operations

Union, intersection, both differences, and the symmetric difference of two sets.

Separate elements with commas or spaces. Duplicates collapse, because a set holds each element once. Leaving one side blank is a real question - that side is the empty set.

Try
A
{1, 2, 3, 5}
B
{2, 4, 5, 8}
A ∪ B
{1, 2, 3, 5, 4, 8}
A ∩ B
{2, 5}
A ∖ B
{1, 3}
B ∖ A
{4, 8}
A △ B
{1, 3, 4, 8}

About the set operations calculator

Enter the members of each set separated by commas. Braces are optional, whitespace around a member is ignored, and repeated members collapse, because a set contains an element or it does not: {1, 1, 2} and {1, 2} are the same set.

The union A union B holds every element in either set. The intersection A intersect B holds only the elements in both. The difference A minus B holds the elements of A that are not in B, and is not symmetric: A minus B and B minus A are usually different. The symmetric difference holds the elements in exactly one of the two sets, which is the union minus the intersection.

The calculator also reports cardinalities, so you can check inclusion-exclusion by hand: the size of the union equals the size of A plus the size of B minus the size of the intersection. Elements are compared as text, so 01 and 1 are two different members.

Worked example

Worked example

InputA = {1, 2, 3, 4} B = {3, 4, 5}
ResultUnion {1, 2, 3, 4, 5}, intersection {3, 4}, A minus B {1, 2}, symmetric difference {1, 2, 5}

Inclusion-exclusion checks out: 4 + 3 - 2 = 5, the size of the union.

Questions

Frequently asked

What is the difference between union and intersection?

The union collects every element that appears in either set, so it is at least as large as the larger set. The intersection collects only the elements that appear in both, so it is at most as large as the smaller set.

Does the order of the elements matter?

No. A set is unordered, so {1, 3} and {3, 1} are the same set. Repeated members also collapse: an element is either in the set or it is not.

What is the symmetric difference of two sets?

The elements that belong to exactly one of the two sets. It equals the union with the intersection removed, and unlike the plain difference it does not depend on which set you write first.