Relations & Functions

Amari Cross & Matthew Williams
||7 min read
FunctionsRelations

Types of relations, functions, domain and range, and the vertical line test.

Relations and functions describe how inputs are paired with outputs. Every function is a relation, but not every relation is a function, because a function gives each input exactly one output.

In CSEC, this topic often asks you to move between representations: ordered pairs, mapping diagrams, tables, equations, and graphs. Keep track of the domain, codomain, and range, because those words describe the input choices, possible targets, and actual outputs.

A Relation Is a Connection

A relation is simply a connection between two sets of things. It pairs up elements from one set with elements from another set.

Real-world examples:

  • Each student paired with their test score
  • Each city paired with its temperature
  • Each book paired with its author
  • Each date paired with the day's closing stock price

Sets and Notation

Before we formalize relations, understand the vocabulary:

  • Set: A collection of objects (written in curly braces)

    • Example: A={1,2,3,4,5}A = \{1, 2, 3, 4, 5\} (the set of single digits 1-5)
    • Example: B={a,e,i,o,u}B = \{a, e, i, o, u\} (vowels)
  • Ordered pair: Two elements in a specific order, written as (x,y)(x, y)

    • (3,6)(3, 6) is different from (6,3)(6, 3)
    • First element: input
    • Second element: output
  • Cartesian product: All possible ordered pairs from two sets

    • If A={1,2}A = \{1, 2\} and B={a,b}B = \{a, b\}
    • Then A×B={(1,a),(1,b),(2,a),(2,b)}A \times B = \{(1,a), (1,b), (2,a), (2,b)\} (4 pairs total)

Defining a Relation Formally

A relation from set AA to set BB is a subset of the Cartesian product A×BA \times B.

In simpler terms: Pick some (but not necessarily all) ordered pairs from A×BA \times B.

Example

Let A={1,2,3}A = \{1, 2, 3\} (ages) and B={68,72,76}B = \{68, 72, 76\} (heights in inches)

The relation "RR: person of age xx has height yy" might be: R={(1,68),(2,72),(3,76)}R = \{(1, 68), (2, 72), (3, 76)\}

Or it could be any other subset, like {(1,72),(3,76)}\{(1, 72), (3, 76)\} (not all pairs need to be included).

Cartesian product A×BA \times B has 9 possible pairs total. Our relation RR uses only 3 of them.

Key Properties of Relations

Domain — The Input Set

The domain is the set of all first elements (inputs).

Example

For relation R={(2,5),(3,7),(4,9),(2,11)}R = \{(2, 5), (3, 7), (4, 9), (2, 11)\}:

Domain: {2,3,4}\{2, 3, 4\} (list each once, even if it appears multiple times)

Note: 2 is in the domain only once, even though it appears twice in the relation.

Codomain — The Target Set

The codomain is the set we're pairing TO (the "target" set we might use, whether we actually use all elements or not).

Range (or Image) — The Output Set

The range is the set of all second elements (outputs) that actually appear.

Example

For relation R={(2,5),(3,7),(4,9),(2,11)}R = \{(2, 5), (3, 7), (4, 9), (2, 11)\}:

If codomain is {5,6,7,8,9,10,11}\{5, 6, 7, 8, 9, 10, 11\}:

  • Codomain (target): {5,6,7,8,9,10,11}\{5, 6, 7, 8, 9, 10, 11\} (7 elements, some unused)
  • Range (actually used): {5,7,9,11}\{5, 7, 9, 11\} (4 elements, only the actual outputs)

Key difference: Codomain is "available to use," Range is "actually used."

Types of Relations

One-to-One (Injective)

Each input connects to exactly one output, and no two inputs connect to the same output.

Example: Student → Student ID (each student has one unique ID)

One-to-one: each input → unique output

Many-to-One

Multiple inputs can connect to the same output.

Example: City → Country (many cities in one country)

Many-to-one: 1→a, 2→a, 3→b

One-to-Many

One input connects to multiple outputs.

Example: Person → Hobbies (one person has many hobbies)

One-to-many: 1→a, 1→b, 2→c

Many-to-Many

Inputs and outputs can have multiple connections.

Example: Students → Subjects (many students in many subjects)

Many-to-many: 1→a, 1→b, 2→a, 2→b
Remember

Domain: Set of all FIRST elements (inputs) Range: Set of all SECOND elements (outputs actually used) Codomain: Target set (all possible outputs available)

Domain and Range are determined by the actual relation. Codomain is usually stated separately.


Part 2: Functions — Special Relations

What Makes a Function Special?

A function is a special type of relation with ONE strict rule:

Each input must have EXACTLY ONE output.

This means:

  • ✓ Input 3 connects to output 9 (good)
  • ✓ Input 5 connects to output 25 (good)
  • ✗ Input 3 connects to outputs 9 AND 10 (bad! not a function)
  • ✗ Input 5 connects to outputs 25 AND 5 (bad! not a function)

However: It's okay if two different inputs map to the same output (many-to-one is fine for functions).

Function Notation

When we have a function, we use special notation to show the rule.

Standard Notation

f:ABf: A \to B

Read as: "Function ff from set AA to set BB"

  • AA = domain (the inputs)
  • BB = codomain (the target outputs)
  • The rule defines which output goes with each input

Function Rule Notation

f(x)=formulaf(x) = \text{formula}

This means:

  • ff is the name of the function
  • xx is the input variable
  • f(x)f(x) is the output (what you get after applying the rule)

Examples:

  • f(x)=2x+1f(x) = 2x + 1 means: "Take the input xx, double it, and add 1"
  • g(x)=x2g(x) = x^2 means: "Take the input xx and square it"
  • h(t)=5th(t) = 5t means: "Take the input tt and multiply by 5"

Evaluating Functions — Finding Outputs

To evaluate a function at a specific value, substitute that value in for xx.

Example

Given f(x)=2x+1f(x) = 2x + 1, find f(3)f(3):

Step 1: Substitute 3 for every xx f(3)=2(3)+1f(3) = 2(3) + 1

Step 2: Calculate f(3)=6+1=7f(3) = 6 + 1 = 7

Meaning: When input is 3, output is 7. The point (3,7)(3, 7) is on the graph.

Example

Given g(x)=x22xg(x) = x^2 - 2x, find g(2)g(-2):

Step 1: Substitute -2 for every xx (use brackets!) g(2)=(2)22(2)g(-2) = (-2)^2 - 2(-2)

Step 2: Calculate carefully g(2)=4+4=8g(-2) = 4 + 4 = 8

Answer: g(2)=8g(-2) = 8

Functions vs. Relations — The Key Difference

The vertical line test distinguishes functions from non-functions:

Vertical line test rule: If you draw a vertical line at any xx-value on the graph, it crosses the graph at most ONCE, the relation is a function.

  • Crosses once: function ✓
  • Crosses twice or more: not a function ✗
  • Doesn't cross: that xx-value isn't in the domain
Vertical line test: y=x² passes (function); x=y² fails (not a function)
Example

Is y2=xy^2 = x a function?

Rearrange: y=±xy = \pm\sqrt{x}

This means for each x>0x > 0, there are TWO possible yy values (positive and negative square root).

Example: If x=4x = 4, then y=2y = 2 OR y=2y = -2 (two outputs for one input).

Answer: NOT a function. Fails the vertical line test.