Set Difference Calculator – Find A - B Online
Calculate the difference between any two sets with our free online set difference calculator. Find all elements in A that are not in B with clear set notation and step-by-step results.
Understanding Set Difference
Set difference is one of the fundamental operations in set theory. When we write A - B (or A \ B), we're asking: "What's in A that isn't in B?" Think of it like subtraction for sets – you start with everything in A and remove anything that also appears in B.
This operation is useful in many contexts. Database queries use set difference to find records in one table that don't exist in another. Programmers use it to find unique items. Mathematicians use it to prove theorems about set relationships.
Set Difference Formula and Notation
A - B = {x | x ∈ A and x ∉ B}
"A minus B equals the set of all x such that x is in A and x is not in B"
Notation Variants
Key Properties
- • A - A = ∅ (empty set)
- • A - ∅ = A
- • ∅ - A = ∅
- • A - B ≠ B - A (not commutative)
Worked Examples
Example 1: Basic Number Sets
A = {1, 2, 3, 4, 5, 6}
B = {2, 4, 6, 8}
A - B = {1, 3, 5}
We remove 2, 4, and 6 from A because they appear in B. The result contains only elements unique to A.
Example 2: Multiples of 10
A = {10, 20, 30, 40, 50}
B = {15, 20, 25, 30}
A - B = {10, 40, 50}
20 and 30 appear in both sets, so they're removed. 15 and 25 don't affect the result since they're not in A.
Example 3: Fruit Names (String Elements)
A = {apple, banana, cherry, date}
B = {banana, date, fig}
A - B = {apple, cherry}
Set difference works with any type of element. Banana and date are removed, leaving apple and cherry.
Example 4: Odd vs Even Numbers
A = {1, 3, 5, 7, 9, 11} (odd numbers)
B = {2, 4, 6, 8, 10} (even numbers)
A - B = {1, 3, 5, 7, 9, 11}
Since no odd numbers are in B, A - B equals A entirely. The sets are disjoint (no overlap).
Example 5: Identical Sets
A = {1, 2, 3, 4, 5}
B = {1, 2, 3, 4, 5}
A - B = ∅ (empty set)
When sets are identical, their difference is empty. Every element in A is also in B, so nothing remains.
Example 6: Primes vs Composites
A = {2, 3, 5, 7, 11, 13, 17} (primes under 20)
B = {4, 6, 8, 9, 10, 12, 14} (composites under 15)
A - B = {2, 3, 5, 7, 11, 13, 17}
No prime numbers are composite, so A - B = A. These sets have no common elements.
Quick Fact
Set theory was created by Georg Cantor in the 1870s as a way to rigorously study infinity. His work was initially controversial – some mathematicians rejected his ideas about different "sizes" of infinity. Today, set theory forms the foundation of modern mathematics. Nearly all mathematical objects can be defined in terms of sets.
Frequently Asked Questions
Is A - B the same as B - A?
No, set difference is not commutative. A - B gives elements in A but not B. B - A gives elements in B but not A. These are usually different. For example, if A = {1,2} and B = {2,3}, then A - B = {1} but B - A = {3}.
What if the sets have no common elements?
If A and B are disjoint (no overlap), then A - B = A. Nothing gets removed because nothing from B exists in A. The same applies to B - A = B.
Can set difference result in an empty set?
Yes. A - B = ∅ when every element of A is also in B (A is a subset of B). Also, ∅ - A = ∅ for any set A, since there's nothing to begin with.
Does order matter within a set?
No. Sets are unordered collections. {1, 2, 3} is the same set as {3, 1, 2}. The calculator sorts results for readability, but mathematically the order doesn't matter.
Can I use strings or only numbers?
Sets can contain any type of element – numbers, strings, objects, even other sets. This calculator handles both numbers and text strings. Elements are compared by value.
What's the difference between set difference and symmetric difference?
Set difference (A - B) gives elements only in A. Symmetric difference (A △ B) gives elements in either A or B but not both. Symmetric difference = (A - B) ∪ (B - A).
Other Free Tools
Union of Sets Calculator – Find A ∪ B Online
Calculate the union of any two or more sets with our free online union calculator. Returns all unique elements combined from each set with clear set notation.
Intersection of Sets Calculator – Find A ∩ B Online
Find the intersection of any two or more sets with our free online intersection calculator. Identifies all common elements shared between sets with clear notation.
Complement of a Set Calculator – Find Set Complement Online
Find the complement of any set with respect to a universal set using our free online complement calculator. Get all elements in the universal set not present in the given set.
Subset Checker – Check if A is a Subset of B Online
Check whether a set is a subset or proper subset of another set with our free online subset checker. Instantly verify set containment relationships with clear explanations.
Power Set Generator – Find All Subsets of a Set Online
Generate the complete power set (all subsets) of any set with our free online power set generator. Lists every possible subset from empty set to the complete set.
Cartesian Product Calculator – Find A × B Online
Calculate the Cartesian product of any two sets with our free online calculator. Lists all ordered pairs in A × B for set theory, relations, and combinatorics applications.
Venn Diagram Tool – Create 2 & 3 Set Venn Diagrams Online
Create interactive Venn diagrams for 2 or 3 sets with our free online tool. Visualize union, intersection, and set differences with customizable labels and shading.
Probability Calculator – Calculate Probability of Events Online
Calculate the probability of any event with our free online probability calculator. Find simple, complementary, and conditional probabilities with formula explanations.