Relations & Functions

Cartesian products, mappings, injections, surjections, and bijections

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.

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.

Cartesian Product Builder

Build the Cartesian product A × B and see all possible ordered pairs. Select subsets of these pairs to define relations.

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 \u2286 A x 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

Draw arrows from domain to codomain to define mappings. The visualizer checks whether your mapping satisfies the function property (each input has exactly one output).

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)

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

Classify functions by their mapping behavior. Toggle between injective (one-to-one), surjective (onto), and bijective (both) examples.

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)

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