What is a Cartesian Product?
In mathematics, the Cartesian product of two sets A and B, written
A × B, is the set of all ordered pairs
(a, b) where a is from A and b is from B.
If A has m elements and B has n elements, then
A × B has m × n pairs.
Unlike union, intersection, and difference, the Cartesian product builds
combinations across sets rather than merging or filtering individual elements.
Cartesian Product
The Cartesian product lists every way to pick one item from the first set and one from the second.
Think of it as a complete grid of options.
For example, suppose a store offers shirt colors:
and shirt sizes:
Every color–size combination is:
- (red, S), (red, M), (red, L),
- (blue, S), (blue, M), and (blue, L)
That list is the Cartesian product of the two sets!
Try it!
Key properties
Order matters
Pairs are ordered: (a, b) is different from (b, a).
Swapping the two input sets produces a different product (unless the sets are equal and you only care about pair content after reordering).
Empty set
If either set is empty, the product is empty. There is no way to form a pair when one side has no elements.
Duplicates
This calculator treats each input as a set: duplicate items in a list are counted once before pairs are generated.