Set Operations Calculator

Union, intersection, difference and symmetric difference of two sets.

Free set operations calculator — compute the union, intersection, difference and symmetric difference of two sets. Duplicates removed automatically. Runs entirely in your browser, nothing uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is the symmetric difference of two sets?

The symmetric difference (A △ B) is the set of elements that are in exactly one of the two sets — present in A or B but not in both. It equals (A − B) ∪ (B − A).

Set operations calculator

Compute the core operations of set theory on two sets: union (A ∪ B), intersection (A ∩ B), difference (A − B and B − A), and symmetric difference (A △ B). It is for maths students, data wranglers and anyone comparing two lists of values.

How it works

Each input is split on commas and new lines, trimmed, and deduplicated — a set holds each member at most once. The chosen operation then runs:

OperationResult
Union (A ∪ B)every element in A or B
Intersection (A ∩ B)elements in both A and B
Difference (A − B)elements in A but not B
Difference (B − A)elements in B but not A
Symmetric difference (A △ B)elements in exactly one set

The symmetric difference equals (A − B) ∪ (B − A). The result and its cardinality (the number of members) are shown.

Worked example

With A = {1, 2, 3, 4, 5} and B = {4, 5, 6, 7}:

OperationResultSize
Union{1, 2, 3, 4, 5, 6, 7}7
Intersection{4, 5}2
A − B{1, 2, 3}3
B − A{6, 7}2
Symmetric difference{1, 2, 3, 6, 7}5

Pick an operation and the result updates instantly — all in your browser, with no network calls.

Practical data-wrangling uses

Set operations on lists of values come up constantly in data work, even when the problem is not framed in mathematical terms.

Finding new customers: you have last month’s customer IDs in Set A and this month’s in Set B. B − A gives you new customers who appeared this month. A − B gives you churned customers who did not return.

Deduplicating two lists: import two exports from different systems and take the union. The result is a merged, deduplicated list with each entry exactly once.

Finding common records: you have a list of users who completed step 1 (A) and a list who completed step 2 (B). The intersection gives you users who completed both — your conversion funnel’s pass-through rate.

Spotting discrepancies: you expect two systems to hold the same user IDs. The symmetric difference shows you the IDs that appear in exactly one system — these are the mismatches to investigate.

Set theory notation quick reference

  • A ∪ B (union): in A or B (or both)
  • A ∩ B (intersection): in A and B
  • A − B (difference): in A but not B; also written A \ B
  • A △ B (symmetric difference): in A or B but not both; A △ B = (A ∪ B) − (A ∩ B)
  • |A| (cardinality): the number of elements in set A
  • A set contains each element at most once; order does not matter