Mathwords logoMathwords

Set Subtraction — Definition, Formula & Examples

Set Subtraction

A way of modifying a set by removing the elements belonging to another set. Subtraction of sets is indicated by either of the symbols – or \. For example, A minus B can be written either A – B or A \ B.

 

Two Venn diagrams showing set subtraction: A–B (left part of A only) and B–A (right part of B only). Example: {a,b,c}–{a,c,e}={b}

 

 

See also

Intersection, union, Venn diagrams

Key Formula

AB={xxA and xB}A - B = \{x \mid x \in A \text{ and } x \notin B\}
Where:
  • AA = The original set (the set you start with)
  • BB = The set whose elements you remove from A
  • xx = An element that belongs to A but does not belong to B
  • ABA - B = The resulting set after subtraction (also written A \ B)

Worked Example

Problem: Let A = {1, 2, 3, 4, 5, 6} and B = {2, 4, 6, 8}. Find A − B.
Step 1: Write out the definition: A − B contains every element that is in A and not in B.
AB={xxA and xB}A - B = \{x \mid x \in A \text{ and } x \notin B\}
Step 2: Check each element of A against B. The element 1 is in A but not in B, so 1 stays. The element 2 is in both A and B, so 2 is removed.
1A,  1B    1AB1 \in A,\; 1 \notin B \implies 1 \in A - B
Step 3: Continue for the remaining elements: 3 is not in B (keep), 4 is in B (remove), 5 is not in B (keep), 6 is in B (remove).
3B  ,4B  ×,5B  ,6B  ×3 \notin B \;\checkmark, \quad 4 \in B \;\times, \quad 5 \notin B \;\checkmark, \quad 6 \in B \;\times
Step 4: Collect the remaining elements into the result set.
AB={1,3,5}A - B = \{1, 3, 5\}
Answer: A − B = {1, 3, 5}

Another Example

This example uses the same two sets but reverses the order of subtraction, demonstrating that set subtraction is NOT commutative — A − B ≠ B − A in general.

Problem: Let A = {1, 2, 3, 4, 5, 6} and B = {2, 4, 6, 8}. Find B − A.
Step 1: Notice the order is reversed compared to the first example. Now we keep elements in B that are not in A.
BA={xxB and xA}B - A = \{x \mid x \in B \text{ and } x \notin A\}
Step 2: Check each element of B: 2 is in A (remove), 4 is in A (remove), 6 is in A (remove), 8 is not in A (keep).
2A  ×,4A  ×,6A  ×,8A  2 \in A \;\times, \quad 4 \in A \;\times, \quad 6 \in A \;\times, \quad 8 \notin A \;\checkmark
Step 3: Collect the remaining elements.
BA={8}B - A = \{8\}
Answer: B − A = {8}

Frequently Asked Questions

Is set subtraction the same as set difference?
Yes, they are two names for the same operation. Both refer to removing from one set all elements that belong to another set. You may see it written as A − B, A \ B, or described as "the difference of A and B."
Is set subtraction commutative?
No. The order matters. A − B gives you elements in A that are not in B, while B − A gives you elements in B that are not in A. These are generally different sets. For instance, {1, 2, 3} − {2, 3, 4} = {1}, but {2, 3, 4} − {1, 2, 3} = {4}.
What is the difference between set subtraction and complement?
Set subtraction A − B removes elements of B from A and works with any two sets. The complement of a set A (written Aᶜ or A') removes all elements of A from the universal set U. In fact, the complement is a special case: Aᶜ = U − A.

Set Subtraction (A − B) vs. Set Intersection (A ∩ B)

Set Subtraction (A − B)Set Intersection (A ∩ B)
DefinitionElements in A that are NOT in BElements that are in BOTH A and B
Formula{x | x ∈ A and x ∉ B}{x | x ∈ A and x ∈ B}
Commutative?No — A − B ≠ B − A in generalYes — A ∩ B = B ∩ A always
Venn diagram regionThe part of circle A that does not overlap with circle BThe overlapping region of both circles
RelationshipA − B = A − (A ∩ B)A ∩ B = A − (A − B)

Why It Matters

Set subtraction appears throughout discrete mathematics, probability, and computer science. When you calculate the probability of "A but not B," you are using set subtraction on event sets. Database queries, filtering data, and programming operations like removing items from a list all rely on this concept.

Common Mistakes

Mistake: Assuming A − B equals B − A (treating set subtraction as commutative).
Correction: Set subtraction is not commutative. Always pay attention to which set comes first. A − B removes B's elements from A, while B − A removes A's elements from B. These usually give different results.
Mistake: Including elements from B that are not in A in the result of A − B.
Correction: A − B can only contain elements that were originally in A. You never add elements from B; you only remove them. If an element is in B but not in A, it simply does not appear in A − B.

Related Terms

  • SetThe fundamental object in set subtraction
  • Element of a SetIndividual items checked during subtraction
  • IntersectionElements common to both sets; closely related operation
  • UnionCombines all elements from both sets
  • Venn DiagramsVisual tool for illustrating set subtraction
  • ComplementSpecial case: subtract a set from the universal set
  • Symmetric DifferenceElements in either set but not both