What Is the Difference of Sets?
The difference of two sets $A$ and $B$, written $A - B$ (or $A \setminus B$), is the set of all elements that are in $A$ but not in $B$. You take set $A$ and remove from it everything it shares with $B$.
Set-difference formula: $A - B = {x : x \in A \text{ and } x \notin B}$.
Read it aloud: "$x$ is in $A$ and $x$ is not in $B$." Both conditions must hold. The word "not" is doing the heavy lifting — it is what makes the difference of sets different from the intersection or the union.
Examples of the Difference of Sets
The examples move from a plain computation to reasoning about order and disjoint sets.
Example 1
If $A = {1, 2, 3, 4, 5, 6}$ and $B = {3, 4, 5, 6, 7, 8}$, find $A - B$.
Keep the elements of $A$ that are not in $B$. $1$ and $2$ are in $A$ but not in $B$. $3, 4, 5, 6$ are in both, so they leave.
$A - B = {1, 2}$.
Example 2
Using the same $A$ and $B$, a student writes $B - A = {1, 2}$ as well. Is that correct?
Here is the intuitive-but-wrong move.
The student assumes that because difference "removes the overlap," the leftover is the same either way, so $B - A$ must also be ${1, 2}$.
Watch it fail. $B - A$ means "elements in $B$ but not in $A$." The elements $1$ and $2$ are not even in $B$, so they cannot possibly be in $B - A$.
The correct way: scan $B$ instead. $7$ and $8$ are in $B$ but not in $A$. $B - A = {7, 8}$.
So $A - B = {1, 2}$ but $B - A = {7, 8}$: different sets. Order matters.
Example 3
If $A = {a, b, c}$ and $B = {c, d, e}$, find $A - B$ and $B - A$.
$A - B$: keep $a, b, c$ that are not in $B$. Only $c$ is shared, so it leaves. $A - B = {a, b}$.
$B - A$: keep $c, d, e$ that are not in $A$. Only $c$ is shared, so it leaves. $B - A = {d, e}$.
Example 4
If $A = {2, 4, 6}$ and $B = {1, 3, 5}$ are disjoint, find $A - B$.
$A$ and $B$ share no elements. So removing $B$ from $A$ removes nothing.
$A - B = {2, 4, 6} = A$.
When two sets are disjoint, $A - B = A$ and $B - A = B$, so nothing gets subtracted.
Example 5
If $A = {1, 2, 3}$, find $A - A$ and $A - \varnothing$.
$A - A$: keep elements of $A$ not in $A$, of which there are none. $A - A = \varnothing$ (the empty set).
$A - \varnothing$: remove nothing from $A$. $A - \varnothing = {1, 2, 3} = A$.
Example 6
If $A = {1, 2, 3, 4}$ and $B = {2, 3}$ with $B \subseteq A$, find $A - B$ and $B - A$.
$A - B$: keep $1, 2, 3, 4$ not in $B$. $A - B = {1, 4}$.
$B - A$: keep $2, 3$ not in $A$, but both are in $A$. $B - A = \varnothing$.
Whenever $B \subseteq A$, the subset subtracted from itself gives the empty set: $B - A = \varnothing$.
Where the Difference of Sets Earns Its Keep
The difference of sets is the mathematics of "what's left after you take something away" — and that shows up long before anyone writes $A - B$.
The complement is a difference. The complement of $B$ is just $U - B$, where $U$ is the universal set. Set difference and complement are the same idea, one relative to $A$ and one relative to everything.
De Morgan-style rewriting. A useful identity is $A - B = A \cap B'$: "take $A$, intersect with everything outside $B$." It links difference, intersection, and complement in one line.
Filtering data. "Customers who bought last month but not this month" is $A - B$. "Files in the backup but not in the source" is a difference. The operation names a question people ask constantly.
Because $A - B$ and $B - A$ answer different questions, keeping the order straight is not pedantry — it is the whole point of the tool.
Properties of the Difference of Sets
These rules follow directly from the definition "in $A$ and not in $B$," and they cover almost every question an exam can ask.
Complement form: $A - B = A \cap B'$ — the difference is $A$ intersected with everything outside $B$. This links difference to the intersection of sets.
Not commutative: $A - B \neq B - A$ in general; they agree only when $A = B$.
Self-difference: $A - A = \varnothing$.
Empty-set rules: $A - \varnothing = A$ and $\varnothing - A = \varnothing$.
Disjoint sets: if $A \cap B = \varnothing$, then $A - B = A$ and $B - A = B$.
Subset case: if $A \subseteq B$, then $A - B = \varnothing$.
Always a subset: $A - B \subseteq A$; the difference never adds elements that were not already in $A$.
Where the Difference of Sets Goes Wrong
Mistake 1: Treating $A - B$ as commutative
Where it slips in: Right after learning addition and multiplication of numbers, where order does not matter. That habit carries over.
Don't do this: Assume $A - B = B - A$.
The correct way: Compute each separately. $A - B$ keeps the leftovers of $A$; $B - A$ keeps the leftovers of $B$. The reader who slows down to ask "which set am I keeping elements from?" avoids the swap that trips up the rusher every time. Set difference is not commutative — that is the habit-breaker to internalise.
Mistake 2: Removing shared elements from the wrong set
Where it slips in: When the overlap is large and the two sets look similar.
Don't do this: For $A - B$, cross out elements of $B$ that happen not to be in $A$ (they were never there to remove).
The correct way: Start from $A$, then delete only the elements that also appear in $B$. Everything you keep must have come from $A$ in the first place.
Mistake 3: Confusing $A - B$ with $A \cap B$ or $A \cup B$
Where it slips in: The three operations sit next to each other in the same chapter, and their symbols blur together.
Don't do this: Report the shared elements (that's the intersection) when the question asked for the difference.
The correct way: Difference keeps what's in $A$ and not in $B$; intersection keeps what's in both; union keeps what's in either. In the real world, a data-migration audit once double-counted records because "in system A but not system B" ($A - B$) was computed as "in both" ($A \cap B$) — the kind of set-logic slip that the ProofWiki identity $A - B = A \cap B'$ is designed to keep you honest about.
Conclusion
The difference of sets $A - B = {x : x \in A \text{ and } x \notin B}$ keeps what's in $A$ but not $B$.
It is not commutative: $A - B \neq B - A$ in general.
For disjoint sets, $A - B = A$; for $A = A$, $A - A = \varnothing$; and $A - \varnothing = A$.
The identity $A - B = A \cap B'$ links difference to intersection and complement.
The Venn diagram makes the answer visible: shade the crescent of the first set that lies outside the second.
To take the difference of sets further with a teacher, explore Bhanzu's algebra tutor, help with algebra, or math classes online. Want to build set operations with a live trainer? Book a free demo class.
Now try these: with $A = {1,2,3,4}$ and $B = {3,4,5}$, find $A - B$, $B - A$, and $A - A$. If the order of subtraction confuses you, come back to Example 2.
Read More
Was this article helpful?
Your feedback helps us write better content
