Use this calculator to compute the union, intersection, or difference between two sets. Paste your lists into Data Set #1 and Data Set #2, choose an operation, and read the result in Output.

0 rows

Use commas, spaces, or new lines to separate items in your input sets.

Descriptions of Set Operations

In mathematics, a set operation is a function that takes two sets — unordered lists of items — and produces a third list based on a standard rule. These operations work on entire lists at once, unlike arithmetic on individual numbers.

See below for a detailed description of each operation.

Union

Union of two sets — both circles filled

The union of two sets contains every element that appears in either set. Think of it as combining both lists and removing duplicates.

For example, suppose Mary and Carlos are buying fruits and vegetables at a farmstand. Mary's basket contains:

  • berries,
  • lettuce, and
  • apples

and Carlos's basket contains:

  • lettuce,
  • peppers,
  • onions, and
  • berries

When they get home, together they purchased:

  • apples,
  • berries,
  • lettuce,
  • peppers, and
  • onions

This is the union of the two sets!

Try it!

Intersection

Intersection of two sets — overlapping region filled

The intersection of two sets contains only elements that appear in both sets — the shared overlap in a Venn diagram.

For example, suppose you are a teacher determining which students play multiple sports. The tennis team roster contains:

  • Jason,
  • James,
  • Emily, and
  • Robert

while the swim team roster includes:

  • Emily,
  • Jared,
  • Larry, and
  • Rachel

The only student on both teams is:

  • Emily

This is the intersection of the two sets!

Try it!

Difference

Difference of two sets — left circle minus overlap

The difference of two sets contains elements in the first set that do not appear in the second. Unlike union and intersection, order matters — the second set is subtracted from the first.

For example, suppose a teacher wants students in math courses except those taking geometry. The math roster is:

  • Stacy,
  • Matthew,
  • Jon,
  • Caroline

and the geometry roster is:

  • Stacy, and
  • Matthew

The remaining students are:

  • Caroline, and
  • Jon

This is the difference of the two sets!

Try it!