Difference of Sets: Definition, Formula, and Examples

#Algebra
TL;DR
The difference of sets A−BA - B is the set of elements that belong to AA but not to BB: A−B=x:x∈A and x∉BA - B = {x : x \in A \text{ and } x \notin B}. This article shows the formula, the Venn diagram, worked examples, and why A−B≠B−AA - B \neq B - A.
BT
Bhanzu TeamLast updated on July 18, 20267 min read

What Is the Difference of Sets?

The difference of two sets AA and BB, written A−BA - B (or A∖BA \setminus B), is the set of all elements that are in AA but not in BB. You take set AA and remove from it everything it shares with BB.

Set-difference formula: A−B=x:x∈A and x∉BA - B = {x : x \in A \text{ and } x \notin B}.

Read it aloud: "xx is in AA and xx is not in BB." 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,6A = {1, 2, 3, 4, 5, 6} and B=3,4,5,6,7,8B = {3, 4, 5, 6, 7, 8}, find A−BA - B.

Keep the elements of AA that are not in BB. 11 and 22 are in AA but not in BB. 3,4,5,63, 4, 5, 6 are in both, so they leave.

A−B=1,2A - B = {1, 2}.

Example 2

Using the same AA and BB, a student writes B−A=1,2B - 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−AB - A must also be 1,2{1, 2}.

Watch it fail. B−AB - A means "elements in BB but not in AA." The elements 11 and 22 are not even in BB, so they cannot possibly be in B−AB - A.

The correct way: scan BB instead. 77 and 88 are in BB but not in AA. B−A=7,8B - A = {7, 8}.

So A−B=1,2A - B = {1, 2} but B−A=7,8B - A = {7, 8}: different sets. Order matters.

Example 3

If A=a,b,cA = {a, b, c} and B=c,d,eB = {c, d, e}, find A−BA - B and B−AB - A.

A−BA - B: keep a,b,ca, b, c that are not in BB. Only cc is shared, so it leaves. A−B=a,bA - B = {a, b}.

B−AB - A: keep c,d,ec, d, e that are not in AA. Only cc is shared, so it leaves. B−A=d,eB - A = {d, e}.

Example 4

If A=2,4,6A = {2, 4, 6} and B=1,3,5B = {1, 3, 5} are disjoint, find A−BA - B.

AA and BB share no elements. So removing BB from AA removes nothing.

A−B=2,4,6=AA - B = {2, 4, 6} = A.

When two sets are disjoint, A−B=AA - B = A and B−A=BB - A = B, so nothing gets subtracted.

Example 5

If A=1,2,3A = {1, 2, 3}, find A−AA - A and A−∅A - \varnothing.

A−AA - A: keep elements of AA not in AA, of which there are none. A−A=∅A - A = \varnothing (the empty set).

A−∅A - \varnothing: remove nothing from AA. A−∅=1,2,3=AA - \varnothing = {1, 2, 3} = A.

Example 6

If A=1,2,3,4A = {1, 2, 3, 4} and B=2,3B = {2, 3} with B⊆AB \subseteq A, find A−BA - B and B−AB - A.

A−BA - B: keep 1,2,3,41, 2, 3, 4 not in BB. A−B=1,4A - B = {1, 4}.

B−AB - A: keep 2,32, 3 not in AA, but both are in AA. B−A=∅B - A = \varnothing.

Whenever B⊆AB \subseteq A, the subset subtracted from itself gives the empty set: B−A=∅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−BA - B.

  • The complement is a difference. The complement of BB is just U−BU - B, where UU is the universal set. Set difference and complement are the same idea, one relative to AA and one relative to everything.

  • De Morgan-style rewriting. A useful identity is A−B=A∩B′A - B = A \cap B': "take AA, intersect with everything outside BB." It links difference, intersection, and complement in one line.

  • Filtering data. "Customers who bought last month but not this month" is A−BA - B. "Files in the backup but not in the source" is a difference. The operation names a question people ask constantly.

Because A−BA - B and B−AB - 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 AA and not in BB," and they cover almost every question an exam can ask.

  • Complement form: A−B=A∩B′A - B = A \cap B' — the difference is AA intersected with everything outside BB. This links difference to the intersection of sets.

  • Not commutative: A−B≠B−AA - B \neq B - A in general; they agree only when A=BA = B.

  • Self-difference: A−A=∅A - A = \varnothing.

  • Empty-set rules: A−∅=AA - \varnothing = A and ∅−A=∅\varnothing - A = \varnothing.

  • Disjoint sets: if A∩B=∅A \cap B = \varnothing, then A−B=AA - B = A and B−A=BB - A = B.

  • Subset case: if A⊆BA \subseteq B, then A−B=∅A - B = \varnothing.

  • Always a subset: A−B⊆AA - B \subseteq A; the difference never adds elements that were not already in AA.

Where the Difference of Sets Goes Wrong

Mistake 1: Treating A−BA - 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−AA - B = B - A.

The correct way: Compute each separately. A−BA - B keeps the leftovers of AA; B−AB - A keeps the leftovers of BB. 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−BA - B, cross out elements of BB that happen not to be in AA (they were never there to remove).

The correct way: Start from AA, then delete only the elements that also appear in BB. Everything you keep must have come from AA in the first place.

Mistake 3: Confusing A−BA - B with A∩BA \cap B or A∪BA \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 AA and not in BB; 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−BA - B) was computed as "in both" (A∩BA \cap B) — the kind of set-logic slip that the ProofWiki identity A−B=A∩B′A - B = A \cap B' is designed to keep you honest about.

Conclusion

  • The difference of sets A−B=x:x∈A and x∉BA - B = {x : x \in A \text{ and } x \notin B} keeps what's in AA but not BB.

  • It is not commutative: A−B≠B−AA - B \neq B - A in general.

  • For disjoint sets, A−B=AA - B = A; for A=AA = A, A−A=∅A - A = \varnothing; and A−∅=AA - \varnothing = A.

  • The identity A−B=A∩B′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,4A = {1,2,3,4} and B=3,4,5B = {3,4,5}, find A−BA - B, B−AB - A, and A−AA - 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

Frequently Asked Questions

Is A−BA - B the same as B−AB - A?
No. They are equal only in the special case A=BA = B, when both are the empty set. In general they shade opposite crescents of the Venn diagram.
What is A−BA - B when AA and BB are disjoint?
A−B=AA - B = A. If the two sets share nothing, subtracting BB removes nothing.
How is the difference of sets related to the complement?
The complement of BB is U−BU - B, and more generally A−B=A∩B′A - B = A \cap B'. Difference and complement are the same operation viewed against different backgrounds.
What is A−AA - A?
The empty set, ∅\varnothing. Every element of AA is also in AA, so nothing survives the subtraction.
Can the difference of sets be empty even when the sets are not equal?
Yes. If A⊆BA \subseteq B, then A−B=∅A - B = \varnothing, because every element of AA is already in BB and gets removed.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →