Relations & Functions

Cartesian products, mappings, injections, surjections, and bijections

Relations & Functions

A function sends each input to exactly one output. Build pairs, draw arrows, and see which mappings make the cut.

Cartesian Product Builder

Enter the elements of A and B, then click pairs in the grid to pick out a relation. Notice the grid always has |A| × |B| cells.

Cartesian Product A x B

The grid shows all ordered pairs (a, b) where a is from A and b is from B. Click cells to select pairs and define a relation R from A to B.

A \\ B123
a
b
c

|A x B|

9 pairs

Selected (relation R)

0 pairs

Relation R ⊆ A x B =

{ ∅ }

Go deeper:Relations & Functions

A relation between sets A and B is any subset of the Cartesian product A × B -- a collection of ordered pairs (a, b). A function is a special kind of relation where each element of A maps to exactly one element of B.

Key insight: The Cartesian product A × B contains every possible pairing of elements from A with elements from B. If |A| = m and |B| = n, then |A × B| = mn. Every relation is a subset of this product.

Function Visualizer

Click an element of A, then an element of B, to draw an arrow. The checklist tells you when your arrows form a function: one output for every input.

Function Visualizer (Arrow Diagram)

Click an element in A (left), then click an element in B (right) to draw an arrow. Click the same pair again to remove it. The system classifies your mapping automatically.

ABabc123

Current mapping:

f(a) = ?f(b) = ?f(c) = ?

Not a function

✗Every element in A has an arrow
✓No element in A has more than one arrow
✗No two elements in A map to the same element in B (injective)
✗Every element in B is mapped to (surjective)
Go deeper:Function Visualizer

Key insight: A function f: A → B assigns to each element of A exactly one element of B. The "vertical line test" in graphing is really checking this single-output property.

Injective, Surjective, Bijective

Step through the examples, or change any arrow by clicking a domain element and then a codomain element. Watch the three checks decide injective, surjective, or bijective.

Injective / Surjective / Bijective

Browse preset examples, or modify any mapping by clicking domain then codomain elements.

Bijective

1 of 5

ABabc123

Each element in A maps to a unique element in B, and every element in B is covered. This is both injective and surjective.

Classification Checklist

Every element in A has exactly one arrow?Yes
No two elements in A map to the same element?Yes
Every element in B is mapped to by some element?Yes

Result: Bijective (one-to-one correspondence)

Go deeper:Injective, Surjective, Bijective

Functions are classified by how they map: injections (one-to-one) never repeat outputs, surjections (onto) hit every target, and bijections do both -- establishing a perfect correspondence between sets.

Key insight: A bijection is both injective and surjective -- it pairs every element of A with a unique element of B, with nothing left over on either side. Bijections are the key to comparing the sizes of sets.

Key Takeaways

  • Relations as subsets -- a relation from A to B is any subset of A × B
  • Functions are special -- each input maps to exactly one output
  • Injectivity -- no two inputs share the same output (one-to-one)
  • Bijections -- perfect pairings that establish equal cardinality between sets

Spot a mistake or have an idea?

Search