Union
A ∪ B = {x | x ∈ A or x ∈ B}
Every element found in either set, listed once.
Separate elements with commas, semicolons, or new lines. Values are text labels, so 1 and 1.0 are different elements.
Private by design: the sets are parsed and compared on this device. Inputs are not uploaded, saved, or included in the page URL.
A ∪ B = {x | x ∈ A or x ∈ B}
Every element found in either set, listed once.
A ∩ B = {x | x ∈ A and x ∈ B}
Only elements shared by both sets.
A ∖ B = {x | x ∈ A and x ∉ B}
Elements of the first set that are absent from the second. Direction matters.
A △ B = (A ∖ B) ∪ (B ∖ A)
Elements in exactly one set, excluding the intersection.
Aᶜ = U ∖ A
Elements of the universal set U that are not in A.
|A ∪ B| = |A| + |B| − |A ∩ B|
The shared elements are subtracted once because the first two counts include them twice.
Let A = {1, 2, 3, 5}, B = {2, 3, 4, 6}, and U = {1, 2, 3, 4, 5, 6, 7, 8}. The overlap is {2, 3}; values 1 and 5 belong only to A, while 4 and 6 belong only to B.
| Operation | Result | Cardinality |
|---|---|---|
| A ∪ B | {1, 2, 3, 5, 4, 6} | 6 |
| A ∩ B | {2, 3} | 2 |
| A ∖ B | {1, 5} | 2 |
| A △ B | {1, 5, 4, 6} | 4 |
| Aᶜ = U ∖ A | {4, 6, 7, 8} | 4 |
The identity check gives |A ∪ B| = 4 + 4 − 2 = 6, matching the six unique elements in the union.
The calculator splits each input at commas, semicolons, and line breaks; trims leading and trailing whitespace; normalizes equivalent Unicode compositions; and removes duplicates. Exact matching is the default. In case-insensitive mode, labels such as Blue and blue match, while the first spelling encountered is retained for display.
Set results preserve useful input order: union and symmetric difference start with qualifying A elements and then add qualifying B elements; complements follow U. The universal set is optional for the first five operations, but complements are shown only when U contains every element of A and B. Blank A or B input is a valid empty set.
Each input is limited to 20,000 characters and 1,000 unique elements. Result cards display the first 100 elements to keep very large inputs responsive; copy and CSV exports still include the complete calculated result. Quoted CSV parsing is not used, so commas, semicolons, and line breaks cannot be part of an element.
The definitions follow the standard treatment in OpenStax, Contemporary Mathematics, Section 1.4.
Editorial review: Operation identities, validation rules, and representative outputs checked by the Starlight Tools editorial team. Last reviewed: .
The union A ∪ B contains every element in A, B, or both. Each value appears only once.
The intersection A ∩ B contains only values shared by A and B. If there are none, the result is the empty set ∅.
A ∖ B keeps A-only elements; B ∖ A keeps B-only elements. Reversing the operands usually changes the result.
A △ B contains values that occur in exactly one set. It combines the two directional differences and excludes the intersection.
A complement is always relative to a universe. Aᶜ = U ∖ A, so changing U can change Aᶜ even when A stays the same.
Yes. Sets contain unique elements, so repeated input values collapse to one. The tool reports how many duplicates it removed from each input.
No. Inputs are text labels and stay in first-seen order. For example, 01, 1, and 1.0 are three distinct elements.
No. Parsing, operations, copying, and file creation run locally in your browser. The tool does not transmit or save entered values.