Set Difference — Definition, Formula & Examples
Set difference is the operation that produces a new set containing all elements that belong to one set but not to another. If you start with set and remove every element that also appears in set , the remaining elements form the set difference .
Given sets and , the set difference (also written ) is defined as .
Key Formula
Where:
- = The set you start with
- = The set whose elements you remove from A
- = An arbitrary element being tested for membership
Worked Example
Problem: Let and . Find and .
Find A \ B: Keep elements of that are not in . The elements 3 and 5 appear in both sets, so remove them from .
Find B \ A: Now keep elements of that are not in . The elements 7 and 9 are in but not in .
Observe order matters: , which confirms that set difference is not commutative.
Answer: and .
Why It Matters
Set difference appears in database queries (SQL's EXCEPT operator), probability calculations where you subtract overlapping events, and programming when filtering collections. In discrete mathematics courses, it is essential for proving subset relationships and working with partitions.
Common Mistakes
Mistake: Treating set difference as commutative, assuming .
Correction: Set difference depends on which set comes first. removes 's elements from , while removes 's elements from . These generally produce different results.
