Compute the Cartesian product of two or more sets. Enter elements separated by commas, and get all possible ordered tuples. Essential for combinatorics, database cross joins, probability, and discrete mathematics. Trusted by students and professionals.
The Cartesian product (named after René Descartes) of two sets A and B, denoted A × B, is the set of all ordered pairs (a, b) where a ∈ A and b ∈ B. More generally, the Cartesian product of n sets A₁, A₂, …, Aₙ is the set of all n‑tuples (a₁, a₂, …, aₙ) with aᵢ ∈ Aᵢ. This seemingly simple concept underpins coordinate geometry, relational databases, combinatorics, and virtually all of discrete mathematics.
Formal Definition
A × B = { (a, b) | a ∈ A ∧ b ∈ B }
Example: If A = {1, 2} and B = {x, y}, then A × B = {(1, x), (1, y), (2, x), (2, y)}.
Cardinality: |A × B| = |A| · |B|. For n sets, the total number of tuples is the product of the sizes.
René Descartes (1596–1650) introduced the coordinate system (the Cartesian plane) in his 1637 work La Géométrie. Every point in the plane is represented by an ordered pair (x, y) — essentially the Cartesian product ℝ × ℝ. This revolutionary idea connected algebra and geometry. Two centuries later, Georg Cantor (1845–1918) formalized set theory, and the notion of ordered pairs became a foundational building block. The term “Cartesian product” was later coined to honor Descartes’ insight.
Today, the Cartesian product is a fundamental operation in mathematics and computer science, appearing everywhere from product sets in probability to cross joins in SQL.
| Domain | Application | Example / Use Case |
|---|---|---|
| Database Systems | CROSS JOIN combines every row of one table with every row of another |
SELECT * FROM colors CROSS JOIN sizes; yields all color–size pairs.
|
| Software Testing | Exhaustive test case generation (pairwise testing) | Browser: Chrome, Firefox × OS: Win, Mac, Linux → 6 test configurations. |
| Probability | Sample space for independent events | Rolling a die (1‑6) and flipping a coin (H,T) → 12 elementary outcomes. |
| Combinatorial Design | Experimental factor combinations | Temperature (low, medium, high) × Pressure (1,2) × Catalyst (yes,no) → 12 runs. |
| Graph Theory | Cartesian product of graphs | Used to construct larger graphs (e.g., grid graphs) from smaller ones. |
| Formal Languages | Product of alphabets | Strings over alphabet Σ = {0,1} can be seen as elements of Σ × Σ × … |
The tool parses each input by splitting on commas (ignoring surrounding spaces). It then builds the Cartesian product using an iterative reduce algorithm: starting with a list containing one empty tuple, for each set it appends every element of that set to every existing tuple. This algorithm is both simple and efficient for moderate‑sized products. The time complexity is O(∏|Aᵢ|), which is optimal since that’s the size of the output.
a, , b → ["a", "", "b"]).
Examples of valid inputs: 1, 2, 3 · red, blue, green · true, false · New York, Paris, Tokyo
An online retailer sells T‑shirts in three sizes (S, M, L) and four colors (Red, Blue, Green, Black). By entering S, M, L as Set A and Red, Blue, Green, Black as Set B, the calculator instantly produces the 12 possible SKUs. The product manager copies the list and imports it into the inventory system, ensuring every variant is tracked. This process eliminated manual errors and reduced time from 30 minutes to 10 seconds.
A biologist studies how temperature (20°C, 30°C, 40°C), pH (6.5, 7.0, 7.5), and catalyst (present/absent) affect enzyme activity. Using three sets, the tool lists all 3×3×2 = 18 experimental conditions. The researcher uses the output to randomize runs and ensures full coverage of the parameter space. The ability to copy the list directly into a lab notebook (or statistical software) streamlines the workflow.
The tool supports any number of sets (click “Add another set”). The result is displayed as a table with columns corresponding to each set’s position. For three sets, each row is a triple (a, b, c). For four sets, a quadruple, etc. This is particularly useful for enumerating configurations in system design or multi‑factor experiments.
1, 1, 2 will treat the first set as having three elements: two 1s and one 2. This matches the behavior of lists/arrays, not pure sets. If you need distinct elements, remove duplicates manually before entering.
(a, b, c) per line. Paste into Excel, then use “Text to Columns” with comma as delimiter. Alternatively, you can manually select the table and paste; Excel often preserves the tabular structure.