Functions and Relations — Complete Guide
A function is a special type of relation where each input value is paired with exactly one output value. This simple rule — one input, one output — is the foundation of all of mathematics, from algebra to calculus to data science. Understanding what makes a function (versus a general relation) unlocks a clear framework for studying mathematical behaviour.
This guide explains the difference between functions and relations, how to use the vertical line test, types of functions (linear, quadratic, rational, etc.), function notation, composition, and the properties that determine whether an inverse exists.
Relations vs Functions — The Key Distinction
A relation is any set of ordered pairs (x, y). A function is a relation where each x-value is paired with exactly one y-value.
Think of a function as a machine: you put in one input, you get one output. If the machine could give two different outputs for the same input, it would not be a function.
Example — is it a function?
Relation A: {(1,2), (2,4), (3,6), (4,8)} — each x has exactly one y. ✓ Function.
Relation B: {(1,2), (1,5), (2,4)} — x = 1 is paired with both y = 2 and y = 5. ✗ Not a function.
Relation C: {(1,3), (2,3), (3,3)} — three different x-values all map to y = 3. ✓ Function (multiple x→same y is allowed).
The rule: each x can appear at most once as a first element in the set of ordered pairs.
The Vertical Line Test
For a graph, a relation is a function if and only if no vertical line intersects the graph more than once. This directly enforces the "one output per input" rule — each x-coordinate corresponds to only one y-coordinate.
Passes test (function): y = x², y = √x, y = sin(x), any straight line except vertical lines.
Fails test (not a function): A circle x² + y² = 4 (a vertical line at x = 1 crosses at y = √3 and y = −√3). A sideways parabola x = y².
Special case — vertical lines: The equation x = 3 is a vertical line and fails the vertical line test — it is a relation (infinitely many y for x=3) but not a function of x. However, it can be written as a function of y: y can be anything.
Function Notation — f(x), g(x), h(x)
Function notation f(x), read "f of x," means: apply the rule f to the input x and return the output. f(x) is not f times x — it is the output value.
Evaluating: If f(x) = 3x² − 2x + 1, then f(4) = 3(16) − 2(4) + 1 = 48 − 8 + 1 = 41.
Evaluating at an expression: f(a+h) = 3(a+h)² − 2(a+h) + 1. This is used in the difference quotient [f(a+h) − f(a)]/h, the foundation of derivatives in calculus.
Why use f(x) instead of y? Function notation makes the variable explicit and enables composition. y = x² is the same curve as f(x) = x², but f(x) lets us write f(3) = 9 and f(g(x)) clearly. With just y, those expressions are less natural.
Common Types of Functions
Functions are classified by their algebraic form. Each type has characteristic domain, range, and shape:
| Type | Form | Domain | Shape |
|---|---|---|---|
| Constant | f(x) = c | (−∞,∞) | Horizontal line |
| Linear | f(x) = mx + b | (−∞,∞) | Straight line |
| Quadratic | f(x) = ax²+bx+c | (−∞,∞) | Parabola |
| Cubic | f(x) = ax³+… | (−∞,∞) | S-curve |
| Polynomial (degree n) | f(x) = aₙxⁿ+…+a₀ | (−∞,∞) | Up to n turns |
| Rational | f(x) = P(x)/Q(x) | Excludes zeros of Q | Has asymptotes |
| Square root | f(x) = √(g(x)) | g(x) ≥ 0 | Half-parabola |
| Logarithmic | f(x) = log(x) | (0, ∞) | Increasing, slow |
| Exponential | f(x) = aˣ | (−∞,∞) | J-curve |
| Absolute value | f(x) = |x| | (−∞,∞) | V-shape |
| Trigonometric | f(x) = sin(x) | (−∞,∞) | Wave |
| Piecewise | Different rules for different x | Depends | Multiple pieces |
One-to-One Functions and the Horizontal Line Test
A function is one-to-one (injective) if each y-value is produced by at most one x-value. Formally: if f(a) = f(b), then a = b.
The horizontal line test: A function is one-to-one if and only if no horizontal line intersects its graph more than once.
Examples:
f(x) = x³ — one-to-one (strictly increasing, passes horizontal line test). ✓
f(x) = x² — NOT one-to-one: f(2) = f(−2) = 4. Two inputs give the same output. ✗
f(x) = 2x + 1 — one-to-one (linear, passes horizontal line test). ✓
Why does this matter? Only one-to-one functions have a true inverse function. For f(x) = x², we restrict the domain to [0,∞) to make it one-to-one before defining the inverse √x.
Function Composition — f(g(x))
The composition (f∘g)(x) = f(g(x)) means apply g first, then apply f to the result. It is read "f composed with g of x."
Example: f(x) = x², g(x) = 3x+1. Then f(g(x)) = f(3x+1) = (3x+1)². And g(f(x)) = g(x²) = 3x² + 1.
Note f(g(x)) ≠ g(f(x)) in general: Composition is not commutative.
Domain of f∘g: x must be in the domain of g, and g(x) must be in the domain of f. Example: g(x) = x−1 and f(x) = √x. For f(g(x)) = √(x−1), need x−1 ≥ 0, so domain = [1, ∞).
Inverse functions are special compositions: If f⁻¹ is the inverse of f, then f(f⁻¹(x)) = x and f⁻¹(f(x)) = x. Composing a function with its inverse always gives the identity function.
Even and Odd Functions — Symmetry
Functions can have two types of algebraic symmetry:
Even function: f(−x) = f(x) for all x in the domain. The graph is symmetric about the y-axis. Examples: f(x) = x², f(x) = cos(x), f(x) = |x|.
Odd function: f(−x) = −f(x) for all x in the domain. The graph has rotational symmetry about the origin (180° rotation). Examples: f(x) = x³, f(x) = sin(x), f(x) = x.
Neither: Most functions are neither even nor odd. Example: f(x) = x² + x — test: f(−x) = x²−x ≠ f(x) and ≠ −f(x).
Testing: Replace x with −x and simplify. If you get the original function, it's even. If you get the negative of the original, it's odd. Otherwise, neither.
Why it matters: Even/odd symmetry simplifies integration, Fourier analysis, and identifying graph transformations.