Cartesian product and graph

The Cartesian product A × B pairs every element of A with every element of B, and those ordered pairs are exactly the points you plot on a graph.

9 min read · 12 cards · 3 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

The canteen combo question

The canteen offers 2 drinks {tea, coffee} and 3 snacks {samosa, vadapav, sandwich}. How many different (drink, snack) combos exist?

You can feel the answer: each drink goes with each snack, 2 × 3 = 6.

Mathematics calls the full list of combos a Cartesian product, and this one idea is how graphs, relations, and database joins are built.

Theory

Every row meets every column

Picture a table: drinks down the side, snacks across the top. Every cell of the table is one pairing. The Cartesian product IS that table, written as a set of pairs. This is also why the count multiplies: rows × columns cells.

Theory

The definition

For sets A and B, the Cartesian product is:

A × B = the set of all ordered pairs (a, b) with a ∈ A and b ∈ B

Example: A = {1, 2}, B = {x, y}

A × B = {(1, x), (1, y), (2, x), (2, y)}

"Ordered" is the key word: the first slot always comes from A, the second from B.

Theory

Order matters, twice

Two consequences of "ordered":

  • Inside a pair: (1, x) and (x, 1) are different objects.
  • Between products: B × A = {(x, 1), (y, 1), (x, 2), (y, 2)}, which is NOT A × B.

And the count: if A has m elements and B has n, then A × B has exactly m·n pairs, because each of the m firsts meets each of the n seconds.

Quiz

A has 4 elements and B has 3. How many elements does B × A have?

  1. 7
  2. 12
  3. It cannot be determined, since B × A is not A × B
  4. 64
Show the answer

12

Size multiplies regardless of order: 3 × 4 = 12. B × A and A × B contain different pairs but always the same number of them. Option A adds instead of multiplying, and option D computes 4³, neither is how pairing works.

Think first

C = {0, 1} and D = {a, b, c}.

List C × D in your head, then count before tapping.

Show the answer

C × D = {(0, a), (0, b), (0, c), (1, a), (1, b), (1, c)}: six pairs, matching 2 × 3.

Notice the systematic listing: fix 0 first, walk through all of D, then fix 1 and repeat. Listing in this row-by-row order means you never miss or duplicate a pair in exams.

Theory

From pairs to graphs

Now let both sets be numbers. A pair like (2, 3) is exactly a point: x-coordinate 2, y-coordinate 3.

So the Cartesian plane you have drawn since school IS a Cartesian product: ℝ × ℝ, every possible (x, y). Same Descartes, same name. Plotting a line or curve just means marking which pairs from ℝ × ℝ satisfy some equation.

Theory

The bridge to relations

Take A = {1, 2, 3} and build A × A (nine pairs). Now keep only the pairs where the first number is less than the second:

{(1, 2), (1, 3), (2, 3)}

That chosen subset is called a relation. Every relation from A to B is just a subset of A × B. Plot those three pairs and they all sit above the line y = x, so even "less than" has a picture.

Quiz

A relation from A to B is best described as:

  1. Any subset of A × B
  2. The whole of A × B, always
  3. Any subset of A ∪ B
  4. A pair of elements, one from each set
Show the answer

Any subset of A × B

A relation selects whichever pairs of A × B satisfy some condition, from none of them up to all of them. The union (option C) contains elements, not pairs, and a single pair (option D) is just one member of the product, not a relation by itself.

Watch out

The two pair traps

Trap 1: writing {1, x} with curly brackets instead of (1, x). Curly brackets ignore order, round brackets keep it; pairs must be round. Trap 2: claiming A × B = B × A. Equal sizes, different pairs. Both mistakes are graded harshly because they show order was ignored.

Theory

Where you will meet this again

SQL's CROSS JOIN of two tables literally computes their Cartesian product, and every (x, y) point a game engine draws lives in ℝ × ℝ. Next topics take today's subset idea further: relations in detail, then functions, which are relations with the one-output rule.

Summary

Key takeaways

  • A × B is the set of all ordered pairs with the first element from A, the second from B.
  • Order matters inside pairs and between products: A × B ≠ B × A in general.
  • |A| = m and |B| = n gives exactly m·n pairs; list them row by row to miss none.
  • Numeric pairs are points, so the xy plane is ℝ × ℝ, and a relation is any chosen subset of a product.
  • Memory hook: every row meets every column.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Set Theory

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Cartesian product and graph · Mathematics (Multi-Disciplinary Course) · Gri-Learn