Set Operations Calculator

Set operations calculator: enter finite sets (A, B, and an optional universal set U) and compute union, intersection, difference, symmetric difference, complements, cardinalities, and probability-style ratios with clear notation.

Full original guide (expanded)

Set Operations Calculator

Type in two finite sets \(A\) and \(B\) (and optionally a universal set \(U\)) and this tool will compute union, intersection, differences, sym\-metric difference, complements, cardinalities, subset relations, and probability-style ratios such as \(|A| / |U|\).

Designed for probability, discrete maths, and CS students

Handles typical textbook notation, removes duplicates automatically, and surfaces the key relationships (\(A \subseteq B\), disjointness, complements) in one glance.

Author: CalcDomain Math Team

Reviewed by: Discrete mathematics instructor

Last updated: 2025

This calculator is an educational aid. For graded work or formal proofs, always double-check the underlying reasoning and show your working.

Interactive set operations workspace

Input format

Separate elements with commas, spaces, or line breaks. Braces are optional: a, b, c and {a, b, c} are treated identically.

Case sensitivity

When disabled, inputs are converted to lower case before comparison.

Required if you want complements and probability-style ratios. Must contain all elements of A and B.

Duplicates are ignored; A is treated as a set, not a multiset.

You can enter numbers, letters, or short labels (e.g. Mon, Tue, Wed).

Show detailed steps?

Example: \(A = \{1,2,3\}\), \(B = \{3,4,5\}\), \(U = \{1,2,3,4,5,6\}\) gives \(A \cup B = \{1,2,3,4,5\}\), \(A \cap B = \{3\}\), \(A^c = \{4,5,6\}\), etc.

Computed sets and relations will appear here.
Step-by-step explanation and formulas will appear here.

Basic set notation and operations

In set theory, a set is a collection of distinct elements. We usually denote sets with capital letters such as \(A, B, U\) and list elements inside braces, for example \(A = \{1,2,3\}\), \(B = \{3,4,5\}\).

\[ A \cup B = \{x : x \in A \text{ or } x \in B\} \] \[ A \cap B = \{x : x \in A \text{ and } x \in B\} \] \[ A \setminus B = \{x : x \in A \text{ and } x \notin B\} \] \[ A \Delta B = (A \setminus B) \cup (B \setminus A) \]

Union, intersection, and difference

Given sets \(A\) and \(B\) inside a universal set \(U\):

  • The union \(A \cup B\) contains every element that is in \(A\), in \(B\), or in both.
  • The intersection \(A \cap B\) contains elements that are in both \(A\) and \(B\).
  • The difference \(A \setminus B\) contains elements that are in \(A\) but not in \(B\).
  • The symmetric difference \(A \Delta B\) contains elements that are in exactly one of \(A\) or \(B\), but not in both.

Complements and cardinalities

A universal set \(U\) is a set that contains all elements under consideration. If \(A \subseteq U\), the complement of \(A\) in \(U\) is:

\[ A^{c} = U \setminus A = \{x : x \in U \text{ and } x \notin A\}. \]

The cardinality of a finite set \(A\), written \(|A|\), is simply the number of distinct elements in \(A\). When \(U\) is finite and all events of interest are subsets of \(U\), this blends naturally with basic probability:

\[ P(A) = \frac{|A|}{|U|}, \quad P(B) = \frac{|B|}{|U|}, \quad P(A \cap B) = \frac{|A \cap B|}{|U|}. \]

Worked example

Let the universal set be \(U = \{1,2,3,4,5,6\}\), and define \(A = \{1,2,3\}\) and \(B = \{3,4,5\}\).

  • \(A \cup B = \{1,2,3,4,5\}\)
  • \(A \cap B = \{3\}\)
  • \(A \setminus B = \{1,2\}\), \(B \setminus A = \{4,5\}\)
  • \(A \Delta B = \{1,2,4,5\}\)
  • \(A^{c} = U \setminus A = \{4,5,6\}\), \(B^{c} = \{1,2,6\}\)
  • \(|A| = 3\), \(|B| = 3\), \(|U| = 6\), so \(P(A) = \frac{3}{6} = 0.5\), \(P(B) = 0.5\), \(P(A \cap B) = \frac{1}{6} \approx 0.167\).

FAQ: set operations calculator

What happens if I repeat an element?

Sets, by definition, do not track multiplicity. If you enter 1, 1, 2, 2, 2, 3, the calculator treats the set as \(\{1,2,3\}\). This is intentional and matches standard set theory.

Can I use words or symbols as elements?

Yes. Elements are handled as text tokens. For example, Mon, Tue, Wed or apple, banana, cherry are perfectly valid sets. Just avoid commas inside a single element, as commas are used to separate elements.

Why are complements and probabilities sometimes disabled?

Complements \(A^{c}\) and \(B^{c}\) are only meaningful once you specify a universal set \(U\). The calculator requires that all elements of \(A\) and \(B\) belong to \(U\). If it detects elements outside \(U\), it will show a warning and skip complements and probability-style ratios.

How can I use this tool to debug exam or homework questions?

One good workflow is: translate the question into explicit sets \(A, B, U\); type them into the calculator; note the numeric outputs \(|A|, |B|, |A \cap B|\), etc.; and then reconstruct your own step-by-step argument, using the tool as a consistency check rather than as a black box.


Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[A \cup B = \{x : x \in A \text{ or } x \in B\}\]
A \cup B = \{x : x \in A \text{ or } x \in B\}
Formula (extracted LaTeX)
\[A \cap B = \{x : x \in A \text{ and } x \in B\}\]
A \cap B = \{x : x \in A \text{ and } x \in B\}
Formula (extracted LaTeX)
\[A \setminus B = \{x : x \in A \text{ and } x \notin B\}\]
A \setminus B = \{x : x \in A \text{ and } x \notin B\}
Formula (extracted LaTeX)
\[A \Delta B = (A \setminus B) \cup (B \setminus A)\]
A \Delta B = (A \setminus B) \cup (B \setminus A)
Formula (extracted LaTeX)
\[A^{c} = U \setminus A = \{x : x \in U \text{ and } x \notin A\}.\]
A^{c} = U \setminus A = \{x : x \in U \text{ and } x \notin A\}.
Formula (extracted LaTeX)
\[P(A) = \frac{|A|}{|U|}, \quad P(B) = \frac{|B|}{|U|}, \quad P(A \cap B) = \frac{|A \cap B|}{|U|}.\]
P(A) = \frac{|A|}{|U|}, \quad P(B) = \frac{|B|}{|U|}, \quad P(A \cap B) = \frac{|A \cap B|}{|U|}.
Formula (extracted text)
\[ A \cup B = \{x : x \in A \text{ or } x \in B\} \] \[ A \cap B = \{x : x \in A \text{ and } x \in B\} \] \[ A \setminus B = \{x : x \in A \text{ and } x \notin B\} \] \[ A \Delta B = (A \setminus B) \cup (B \setminus A) \]
Formula (extracted text)
\[ A^{c} = U \setminus A = \{x : x \in U \text{ and } x \notin A\}. \]
Formula (extracted text)
\[ P(A) = \frac{|A|}{|U|}, \quad P(B) = \frac{|B|}{|U|}, \quad P(A \cap B) = \frac{|A \cap B|}{|U|}. \]
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 2026-01-19
  • Initial audit spec draft generated from HTML extraction (review required).
  • Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
  • Confirm sources are authoritative and relevant to the calculator methodology.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn
Formulas

(Formulas preserved from original page content, if present.)

Version 0.1.0-draft
Citations

Add authoritative sources relevant to this calculator (standards bodies, manuals, official docs).

Changelog
  • 0.1.0-draft — 2026-01-19: Initial draft (review required).