Cartesian Products and Ordered Coordinates

A Cartesian product contains ordered pairs with one coordinate from each specified set.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Enumerate a small product
  2. Account for empty components
  3. Keep the two coordinates distinguishable
  4. Count independently chosen coordinates

Enumerate a small product

With two colors and three sizes, each color pairs with each size, giving six items. Pair order preserves which coordinate is color. Nested pair iteration visits all possibilities when the second traversal restarts for each first item.

Account for empty components

If there are no sizes, the product is empty even with several available colors. Test this when producing configurations. A function contract should describe whether no combinations means an empty result or invalid configuration.[1]

Keep the two coordinates distinguishable

With \(A=\{1,2\}\) and \(B=\{2,3\}\), the product \(A\times B\) contains \((1,2),(1,3),(2,2),(2,3)\). The pair \((3,1)\) belongs to the reversed product alone. Distinguish an ordered product from choosing an unordered two-element subset. See ordered choices without replacement.

First coordinate 1: (1,2), (1,3)
First coordinate 2: (2,2), (2,3)
A×B has 4 elements, including (2,2)

Count independently chosen coordinates

For each of \(|A|\) first components there are \(|B|\) second components. This gives the size formula and shows why a product with an empty factor is empty. Swapping coordinates is a bijection even when the products themselves differ.

References

  1. Eric Lehman, F. Thomson Leighton and Albert R. Meyer, Mathematics for Computer Science ↩