Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

How to Find a Cartesian Product

The Cartesian product A×BA \times B is the set of all ordered pairs (a,b)(a, b) with aa from AA and bb from BB. Pair each element of AA with every element of BB; there are ∣A∣⋅∣B∣|A| \cdot |B| pairs.

Recognize the task

The question asks for A×BA \times B, A×AA \times A or A2A^2, "all ordered pairs", the points of a grid, or the outcomes of two stages such as a coin and a die. Test: the result is a set of pairs in which order matters, so (1,x)(1, x) and (x,1)(x, 1) are different.
The size rule ∣A×B∣=∣A∣⋅∣B∣|A \times B| = |A| \cdot |B| is the multiplication rule, explained in the counting principles lesson; set notation is in the set theory notation section.

Two ways to do it

Row by rowusual
A×B={(a,b):a∈A, b∈B}A \times B = \{(a, b) : a \in A,\ b \in B\}
Fix one element of AA and run through all of BB, then move on to the next element of AA.
Tablegrid
∣A∣ rows×∣B∣ columns|A| \text{ rows} \times |B| \text{ columns}
Put AA down the side and BB across the top; each cell holds one pair.

Steps

StepOn A={1,2,3}A = \{1, 2, 3\}, B={x,y}B = \{x, y\}
1Fix the order of the factors. The first coordinate comes from the first set, so A×BA \times B and B×AB \times A are different sets.pairs (a,b)(a, b) with a∈Aa \in A, b∈Bb \in B
2Pair the first element of A with every element of B. Keep aa fixed and let bb run through BB.(1,x),(1,y)(1, x), (1, y)
3Repeat for each remaining element of A. One block of ∣B∣|B| pairs for every element of AA.(2,x),(2,y),(3,x),(3,y)(2, x), (2, y), (3, x), (3, y)
4Collect the pairs and check the count. There must be ∣A∣⋅∣B∣|A| \cdot |B| pairs.A×B={(1,x),(1,y),(2,x),(2,y),(3,x),(3,y)}A \times B = \{(1, x), (1, y), (2, x), (2, y), (3, x), (3, y)\}; 3⋅2=63 \cdot 2 = 6

Worked examples

Example 1 · swapping the factors

order matters
A={0,1}A = \{0, 1\}, B={p,q}B = \{p, q\}
two elements each
A×B={(0,p),(0,q),(1,p),(1,q)}A \times B = \{(0, p), (0, q), (1, p), (1, q)\}
first coordinate from A
B×A={(p,0),(p,1),(q,0),(q,1)}B \times A = \{(p, 0), (p, 1), (q, 0), (q, 1)\}
different pairs, same size 44

Example 2 · a set with itself

square
A={1,2}A = \{1, 2\}, A×A=A2A \times A = A^2
both coordinates from A
A2={(1,1),(1,2),(2,1),(2,2)}A^2 = \{(1, 1), (1, 2), (2, 1), (2, 2)\}
(1,2)≠(2,1)(1, 2) \neq (2, 1)

Example 3 · three sets

counting
∣A∣=2|A| = 2, ∣B∣=3|B| = 3, ∣C∣=4|C| = 4
triples (a,b,c)(a, b, c)
∣A×B×C∣=2⋅3⋅4|A \times B \times C| = 2 \cdot 3 \cdot 4
one factor per coordinate
2424 ordered triples
multiply

See it happen

Write AA down the left side of a table and BB along the top. Each cell is the pair (row label, column label), so the table has ∣A∣|A| rows of ∣B∣|B| cells each, ∣A∣⋅∣B∣|A| \cdot |B| cells in all. Swapping the sets turns the table on its side: the cells hold the same two labels in the opposite order, which is why A×B≠B×AA \times B \neq B \times A unless A=BA = B or one of the sets is empty.

Common mistakes

Writing sets instead of ordered pairs

✗ {1,x}∈A×B\{1, x\} \in A \times B
✓ (1,x)∈A×B(1, x) \in A \times B; in a pair the order is fixed

Treating the product as commutative

✗ {0,1}×{p,q}={p,q}×{0,1}\{0, 1\} \times \{p, q\} = \{p, q\} \times \{0, 1\}
✓ (0,p)(0, p) is in the first product, (p,0)(p, 0) in the second

Adding the sizes

✗ ∣A×B∣=3+2=5|A \times B| = 3 + 2 = 5
✓ each element of AA pairs with each element of BB: 3⋅2=63 \cdot 2 = 6

Forgetting the empty set

✗ {1,2}×∅={1,2}\{1, 2\} \times \emptyset = \{1, 2\}
✓ there is no second coordinate to choose: {1,2}×∅=∅\{1, 2\} \times \emptyset = \emptyset