TFT

Cartesian Product Calculator – Find A × B Online

Calculate the Cartesian product of any two sets with our free online calculator. Generate all ordered pairs (a, b) where a ∈ A and b ∈ B with clear notation.

Load example:

Understanding Cartesian Products

The Cartesian product is a fundamental operation in set theory that combines two sets to create a new set of ordered pairs. Named after the French mathematician René Descartes, this concept forms the foundation of coordinate geometry – every point on a graph is essentially an element of the Cartesian product of the real numbers with themselves.

When you take the Cartesian product of set A with set B (written as A × B), you're creating every possible pairing where the first item comes from A and the second comes from B. If A has 3 elements and B has 4 elements, the product A × B will have exactly 3 × 4 = 12 ordered pairs.

The word "ordered" is crucial here. The pair (1, 2) is different from (2, 1) because the order tells you which set each element came from. This is why A × B is generally different from B × A – you'd get the same pairs but with the elements reversed.

The Cartesian Product Formula

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

Read this as: "A cross B equals the set of all ordered pairs (a, b) such that a is an element of A and b is an element of B."

Size formula:|A × B| = |A| × |B|
The number of elements in the Cartesian product equals the product of the sizes of the two sets.

Key Properties

Not Commutative
A × B ≠ B × A (unless A = B or one is empty)
Empty Set Rule
A × ∅ = ∅ × A = ∅ (product with empty set is empty)
Distributive Laws
A × (B ∪ C) = (A × B) ∪ (A × C)

Real-World Applications

Database Queries
SQL JOIN operations create Cartesian products of tables
Probability
Sample spaces for combined events are Cartesian products
Computer Graphics
Screen pixels form a Cartesian product of x and y coordinates

Worked Examples

Example 1: Basic Numbers and Letters

Find A × B where A = {1, 2, 3} and B = {x, y}

Set A: {1, 2, 3} (3 elements)
Set B: {x, y} (2 elements)
Expected pairs: 3 × 2 = 6
A × B = {
(1, x), (1, y),
(2, x), (2, y),
(3, x), (3, y)
}
Each element from A is paired with each element from B, maintaining order.

Example 2: Rolling Two Dice

The sample space for rolling two six-sided dice is the Cartesian product of {1,2,3,4,5,6} with itself.

Set A (Die 1): {1, 2, 3, 4, 5, 6}
Set B (Die 2): {1, 2, 3, 4, 5, 6}
Total outcomes: 6 × 6 = 36
Sample Space (A × A):
(1,1)
(1,2)
(1,3)
(1,4)
(1,5)
(1,6)
(2,1)
(2,2)
(2,3)
(2,4)
(2,5)
(2,6)
(3,1)
(3,2)
(3,3)
(3,4)
(3,5)
(3,6)
(4,1)
(4,2)
(4,3)
(4,4)
(4,5)
(4,6)
(5,1)
(5,2)
(5,3)
(5,4)
(5,5)
(5,6)
(6,1)
(6,2)
(6,3)
(6,4)
(6,5)
(6,6)
This is why there are 36 possible outcomes when rolling two dice. The probability of rolling doubles (1,1), (2,2), etc. is 6/36 = 1/6.

Example 3: Coin Flip Combinations

Find all outcomes when flipping two coins (heads or tails).

Set A (Coin 1): {heads, tails}
Set B (Coin 2): {heads, tails}
Total outcomes: 2 × 2 = 4
A × B = {(heads, heads), (heads, tails), (tails, heads), (tails, tails)}
Notice (heads, tails) ≠ (tails, heads) – the first coin is different in each case. This is why there are 4 outcomes, not 3.

Example 4: Product Sizes and Colors

A store sells shirts in 3 sizes and 3 colors. How many size-color combinations exist?

Sizes: {small, medium, large}
Colors: {red, blue, green}
Total combinations: 3 × 3 = 9
Sizes × Colors = {
(small, red), (small, blue), (small, green),
(medium, red), (medium, blue), (medium, green),
(large, red), (large, blue), (large, green)
}
This is why the store needs to stock 9 different SKU combinations to offer all size-color options.

Quick Fact

René Descartes (1596-1650) gave his name to the Cartesian product and Cartesian coordinate system. Legend has it that he conceived the idea while watching a fly crawl across the ceiling of his room. He realized he could describe the fly's position using two numbers – its distance from two adjacent walls. This insight united algebra and geometry, creating analytic geometry and paving the way for calculus. The phrase "I think, therefore I am" (Cogito, ergo sum) is also his.

Frequently Asked Questions

Why is it called "Cartesian" product?

It's named after René Descartes, who developed the Cartesian coordinate system. In that system, every point is identified by an ordered pair (x, y) – exactly the structure of a Cartesian product. The entire coordinate plane is essentially ℝ × ℝ (the real numbers crossed with themselves).

Is A × B the same as B × A?

Generally, no. If A = {1} and B = {2}, then A × B = {(1, 2)} but B × A = {(2, 1)}. These are different ordered pairs. They're only equal if A = B (same set) or if one of the sets is empty (both products are empty).

What happens if one set is empty?

The Cartesian product with an empty set is always empty. If A = {1, 2} and B = ∅, then A × B = ∅. There's nothing in B to pair with elements from A, so no ordered pairs can be formed.

Can I take the Cartesian product of a set with itself?

Absolutely. A × A gives you all ordered pairs where both elements come from A. For A = {1, 2}, A × A = {(1,1), (1,2), (2,1), (2,2)}. This is common in probability (like rolling two identical dice) and relations (a relation on A is a subset of A × A).

What's the difference between Cartesian product and combinations?

Cartesian product creates ordered pairs from two different sets – order matters and elements come from specific sets. Combinations select items from a single set where order doesn't matter. For example, choosing 2 from {a,b,c} gives {a,b}, {a,c}, {b,c} (3 combinations), but {a,b} × {a,b} gives 4 ordered pairs.

How is Cartesian product used in databases?

In SQL, a CROSS JOIN creates the Cartesian product of two tables – every row from table A paired with every row from table B. If table A has 100 rows and table B has 50 rows, the result has 5,000 rows. This is rarely what you want, which is why JOINs usually include conditions to filter the product.

Can Cartesian products have more than two sets?

Yes! The Cartesian product of three sets A × B × C creates ordered triples (a, b, c). This extends to any number of sets. In fact, 3D space is ℝ × ℝ × ℝ – every point is an ordered triple (x, y, z). Computer scientists use n-tuples from Cartesian products extensively in data structures.

Other Free Tools

Union of Sets Calculator – Find A ∪ B Online

Calculate the union of any two or more sets with our free online union calculator. Returns all unique elements combined from each set with clear set notation.

Intersection of Sets Calculator – Find A ∩ B Online

Find the intersection of any two or more sets with our free online intersection calculator. Identifies all common elements shared between sets with clear notation.

Set Difference Calculator – Find A − B Online

Calculate the difference between any two sets with our free online set difference calculator. Find all elements that are in set A but not in set B instantly.

Complement of a Set Calculator – Find Set Complement Online

Find the complement of any set with respect to a universal set using our free online complement calculator. Get all elements in the universal set not present in the given set.

Subset Checker – Check if A is a Subset of B Online

Check whether a set is a subset or proper subset of another set with our free online subset checker. Instantly verify set containment relationships with clear explanations.

Power Set Generator – Find All Subsets of a Set Online

Generate the complete power set (all subsets) of any set with our free online power set generator. Lists every possible subset from empty set to the complete set.

Venn Diagram Tool – Create 2 & 3 Set Venn Diagrams Online

Create interactive Venn diagrams for 2 or 3 sets with our free online tool. Visualize union, intersection, and set differences with customizable labels and shading.

Probability Calculator – Calculate Probability of Events Online

Calculate the probability of any event with our free online probability calculator. Find simple, complementary, and conditional probabilities with formula explanations.