Set operations calculator
Find the union, intersection, differences and Cartesian product of two sets, with Jaccard similarity.
A clear answer. Here’s how.
Elements are trimmed, compared as text and kept in order of first appearance. The union A ∪ B holds everything in either set, the intersection A ∩ B everything in both, A − B what is only in A, and the symmetric difference A △ B what is in exactly one. The Cartesian product A × B is every ordered pair (a, b), with |A| × |B| members; the first 100 are listed. Jaccard similarity is |A ∩ B| ÷ |A ∪ B| and is defined as 1 when both sets are empty. A is a subset of B when A − B is empty, and the sets are disjoint when the intersection is empty.
How this is checked
4 reference checks passed These 4 cases were run when this page was built, on 20 October 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.
See the checks and where each expected answer comes from
Case 1
- Inputs
- Set A 1, 2, 3Set B 2, 3, 4Compare text insensitive
- Expected, and what Toolmoz gave
- Union size expected 4, Toolmoz 4Intersection size expected 2, Toolmoz 2Only in A expected 1, Toolmoz 1Only in B expected 1, Toolmoz 1Symmetric difference size expected 2, Toolmoz 2Jaccard similarity expected 0.5, Toolmoz 0.5Cartesian product size expected 9, Toolmoz 9A is a subset of B expected No, Toolmoz No
- Where the expected answer comes from
- A = {1, 2, 3}, B = {2, 3, 4}: union {1, 2, 3, 4}, intersection {2, 3}, Jaccard 2/4, product 3 × 3 (hand calculation)
- Allowed difference
- exact
Case 2
- Inputs
- Set A a, bSet B A, B, cCompare text insensitive
- Expected, and what Toolmoz gave
- Union size expected 3, Toolmoz 3Intersection size expected 2, Toolmoz 2A is a subset of B expected Yes, Toolmoz YesB is a subset of A expected No, Toolmoz No
- Where the expected answer comes from
- Ignoring case {a, b} ⊂ {a, b, c}
- Allowed difference
- exact
Case 3
- Inputs
- Set A a, bSet B A, B, cCompare text sensitive
- Expected, and what Toolmoz gave
- Union size expected 5, Toolmoz 5Intersection size expected 0, Toolmoz 0A and B are disjoint expected Yes, Toolmoz Yes
- Where the expected answer comes from
- With case mattering the two sets share nothing
- Allowed difference
- exact
Case 4
- Inputs
- Set A Set B Compare text sensitive
- Expected, and what Toolmoz gave
- Union size expected 0, Toolmoz 0Jaccard similarity expected 1, Toolmoz 1Cartesian product size expected 0, Toolmoz 0
- Where the expected answer comes from
- Two empty sets: Jaccard similarity is defined as 1 and the product is empty
- Allowed difference
- exact
What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- Set A
- 1, 2, 3
- Set B
- 2, 3, 4
- Compare text
- Ignoring case
Example result
| Set | Size | Elements |
|---|---|---|
| A | 3 | 1, 2, 3 |
| B | 3 | 2, 3, 4 |
| A ∪ B (union) | 4 | 1, 2, 3, 4 |
| A ∩ B (intersection) | 2 | 2, 3 |
| A − B (only in A) | 1 | 1 |
Elements are separated by commas, semicolons or new lines, trimmed, and repeated elements count once, in order of first appearance. Elements are compared as text, ignoring case. Jaccard similarity = |A ∩ B| ÷ |A ∪ B|, and is 1 when both sets are empty.