Cartesian Product Calculator

Calculate the Cartesian product A x B of sets to get all ordered pairs.

Define Sets

|A| = 3

|B| = 2

Cardinality

|A × B| = |A| × |B| = 3 × 2 = 6

A × B = B × A?NO

Cartesian product is generally NOT commutative

A × B

6 ordered pairs

(1, a)(1, b)(2, a)(2, b)(3, a)(3, b)

B × A

6 ordered pairs

(a, 1)(a, 2)(a, 3)(b, 1)(b, 2)(b, 3)

A × A

9 ordered pairs

(1, 1)(1, 2)(1, 3)(2, 1)(2, 2)(2, 3)(3, 1)(3, 2)(3, 3)

About Cartesian Product

Definition

A × B = {(a, b) | a ∈ A and b ∈ B} - the set of all ordered pairs where the first element comes from A and second from B.

Properties

  • Not commutative: A × B ≠ B × A (usually)
  • |A × B| = |A| × |B|
  • A × ∅ = ∅ × A = ∅

What Is a Cartesian Product?

The Cartesian product of two sets A and B, denoted A × B, is the set of all ordered pairs (a, b) where a ∈ A and b ∈ B. For example, {1,2} × {a,b} = {(1,a), (1,b), (2,a), (2,b)}. This calculator supports up to three sets, allowing Cartesian products of 2 or 3 sets. The size of the product is the product of the sizes: |A × B| = |A| × |B|.

Cartesian products are the foundation of relational databases (every table is a subset of a Cartesian product), coordinate geometry (R × R = R² gives the Cartesian plane), and combinatorics (counting ordered selections from multiple sets).

Cartesian Product Formula

Cartesian Product

A × B = {(a, b) | a ∈ A, b ∈ B} |A × B| = |A| × |B|

Where:

  • A= First set — comma-separated values like '1, 2, 3'
  • B= Second set — comma-separated values like 'a, b'

How to Use

  1. Enter sets: Type comma-separated values for up to three sets. Duplicates are automatically removed.
  2. Choose number of sets: Select 2 or 3 depending on how many sets you need to combine.
  3. Read the product: All ordered pairs (or triples) are displayed in a grid, with the total count shown.

Applications

Cartesian products underpin relational databases — joining two tables produces their Cartesian product filtered by a condition. In game design, combining character classes with races gives a Cartesian product of all possible character types. In product configuration, combining options for size × color × material generates all possible product variants. The Cartesian plane R² = R × R is the entire framework of 2D coordinate geometry.

Worked Examples

Two Sets

Problem:

Find the Cartesian product of {1, 2, 3} and {a, b}.

Solution Steps:

  1. 1Enter Set A: 1, 2, 3; Set B: a, b.
  2. 2Size: 3 × 2 = 6 ordered pairs.
  3. 3Product: {(1,a),(1,b),(2,a),(2,b),(3,a),(3,b)}.

Result:

|A × B| = 6 ordered pairs. Each element of A pairs with each element of B.

Three Sets

Problem:

A × B × C with A={x,y}, B={1}, C={red,blue}.

Solution Steps:

  1. 1Enter 3 sets: Set A: x, y; Set B: 1; Set C: red, blue.
  2. 2Size: 2 × 1 × 2 = 4 triples.
  3. 3Result: (x,1,red), (x,1,blue), (y,1,red), (y,1,blue).

Result:

4 ordered triples. With |B| = 1, the product has the same structure as A × C.

Tips & Best Practices

  • The total number of ordered pairs equals the product of the set sizes — use this to verify your result.
  • Duplicate elements in inputs are automatically removed — a set contains each element only once.
  • For large sets, the output can be very large — |A × B| = |A| × |B| grows multiplicatively.
  • The Cartesian product of n identical sets R × R × ... × R = R^n — this is the n-dimensional Euclidean space.

Frequently Asked Questions

No. A × B ≠ B × A generally because (a,b) ≠ (b,a) as ordered pairs — the first element comes from the first set, the second from the second. However, |A × B| = |B × A| because multiplication of sizes is commutative.
The calculator removes duplicates from each input set. {1, 1, 2, 2} becomes {1, 2}, so the Cartesian product reflects the unique elements only. This matches the mathematical definition where sets don't contain duplicates.
A SQL CROSS JOIN produces the Cartesian product of two tables. For example, SELECT * FROM A CROSS JOIN B returns every row of A paired with every row of B. Most joins (INNER, LEFT, etc.) start with the Cartesian product and then filter by a condition.

Sources & References

Last updated: 2026-06-06

💡

Help us improve!

How would you rate the Cartesian Product Calculator?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: Handbook of Mathematical Functions

by Abramowitz & Stegun

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.