Skip to content
ENExplore Calculators

Set Difference Calculator

Work out set difference instantly with clear inputs, formula shown and shareable results.

About Set Difference Calculator

The set difference A \\ B keeps the elements of A that are not in B. Unlike union and intersection it is not symmetric, so A \\ B and B \\ A are generally different sets.

Formula

Set difference

A \\ B = { x : x ∈ A and x ∉ B }

Worked example

With the default values below, Set Difference Calculator returns A \\ B of 1, 3, 5. Change any input above and every figure here is recalculated in your browser.

Inputs used

Set A
1, 2, 3, 4, 5, 6
Set B
2, 4, 6, 8

Results

A \\ B
1, 3, 5
B \\ A
8
|A \\ B|
3
|B \\ A|
1

Step by step

  1. 1Values used
  2. 2Set difference
  3. 3A \\ B= 1, 3, 5
  4. 4B \\ A= 8
  5. 5|A \\ B|= 3
  6. 6|B \\ A|= 1

Assumptions and limits

  • The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

For A = {1..6} and B = {2,4,6,8}?

A \\ B = {1, 3, 5} while B \\ A = {8}.

Is difference the same as complement?

The complement is the difference from a universal set, so it is a special case where A is everything under consideration.

Set Difference Calculator – Calculate A \\ B & B \\ A