Learn
Lesson · Sets, Relations, and Functions · Functions

Functions

A function is a relation from A to B in which every element of A appears exactly once as a first coordinate. Domain, codomain and image are three different sets, and confusing the last two causes most of the trouble.

f : A → B every a ∈ A has EXACTLY ONE f(a) ∈ B domain A where inputs come from codomain B where outputs are DECLARED to live image f(A) ⊆ B where outputs ACTUALLY live
Three sets, not two

Core ideas

What this lesson establishes

Two conditions define a function: every input is used, and none is used twice. Everything else is vocabulary.

1

Totality and single-valuedness

Every element of the domain must have an image (total), and only one (well defined). A rule failing either is not a function.

2

Codomain is declared, image is derived

f : ℝ → ℝ with f(x) = x² has codomain ℝ and image [0, ∞). Surjectivity in “Injective, Surjective, Bijective” is exactly the question of whether they coincide.

3

The codomain is part of the function

x ↦ x² from ℝ to ℝ and from ℝ to [0, ∞) are different functions, and one is surjective while the other is not.

The material

What a function is

The definition as a relation, then the vocabulary and the standard traps.

Definition · Function

A function f : A → B is a relation f ⊆ A × B such that for every a ∈ A there is exactly one b ∈ B with (a, b) ∈ f. That b is written f(a).

The definition packs two conditions. At least one output for each input makes the function total — a rule undefined somewhere on its stated domain is not a function on that domain. At most one makes it well defined — a rule giving two answers for one input is not a function at all.

Definition · Domain, codomain, image

In f : A → B, A is the domain, B the codomain, and f(A) = {f(a) : a ∈ A} ⊆ B the image (or range).

Example · The same rule, three functions

f : ℝ → ℝ, f(x) = x² has image [0, ∞) ≠ ℝ. g : ℝ → [0, ∞), g(x) = x² has image equal to its codomain. h : [0, ∞) → [0, ∞), h(x) = x² is in addition one-to-one. Same formula, three different functions, three different answers in “Injective, Surjective, Bijective”.

Two ways a rule fails to be a function

  • Not total. f : ℝ → ℝ with f(x) = 1/x is not a function on ℝ: nothing is assigned to 0. It is a function on ℝ \ {0}, and stating the domain correctly is the fix.
  • Not single-valued. "f(x) is a square root of x" assigns two values to 4. Choosing the non-negative one makes it a function; leaving both does not.

A third failure is subtler and appears whenever a function is defined through a representative. "Define f([a]) = a mod 2 on classes mod 4" must be checked: [1] = [5], so f must give the same answer for 1 and 5, and it does. Had the rule been f([a]) = a mod 3, then 1 mod 3 = 1 and 5 mod 3 = 2, and f would not be well defined.

Definition · Image and preimage of a set

For S ⊆ A, f(S) = {f(a) : a ∈ S}. For T ⊆ B, the preimage f⁻¹(T) = {a ∈ A : f(a) ∈ T}. The preimage notation does not presuppose an inverse function.

That last remark matters. f⁻¹(T) is defined for every function and every T; it may be empty. The inverse function f⁻¹ exists only when f is a bijection, which is “Composition and Inverse Functions”.

Definition · Some standard functions

⌊x⌋ is the largest integer ≤ x; ⌈x⌉ the smallest integer ≥ x. The identity id_A(a) = a. A sequence is a function ℕ → A, which is why Induction and Recursion's recurrences are functions on the naturals.

Interactive

Injective, surjective, bijective

Built by hand, classified by counting

f : A → BChoose where each element of A is sent
hit oncehit twice or morenever hit

Method

Checking a rule is a function

Two conditions, plus a third when classes are involved.

1

Is every element of the domain assigned a value?

Division, square roots and logarithms are the usual places a rule quietly fails. Either restrict the domain or the rule is not a function on it.

2

Is the value unique?

One input, one output. If the rule offers a choice, the function is not specified until the choice is made.

3

If inputs are classes, check well-definedness

Compute the rule on two representatives of the same class. Different answers mean the rule is not a function on classes at all.

4

State the codomain deliberately

It is part of the function. Declaring f : ℝ → ℝ rather than f : ℝ → [0,∞) changes the answer to “Injective, Surjective, Bijective”'s question.

Functions

Score 0 / 0

Is it a function?

Four candidate rules, with the domain stated in each case.

1. f : ℝ → ℝ, f(x) = 2x + 1 YES 2. f : ℝ → ℝ, f(x) = 1/x NO — undefined at 0 f : ℝ\{0} → ℝ, f(x) = 1/x YES 3. f : ℝ → ℝ, f(x)² = x NO — two values for x = 4, and none for x = −1 4. f : ℤ/4ℤ → ℤ/2ℤ, f([a]₄) = [a]₂ YES — well defined: if a ≡ b (mod 4) then 4 | (a−b), so 2 | (a−b), so a ≡ b (mod 2)

Case 4 is the one that needs an argument rather than an inspection. The rule is stated through a representative, so it is a function only because any two representatives of the same class mod 4 agree mod 2 — and that had to be proved, not assumed.

Common mistakes

1
Treating image and codomain as the same setThey coincide exactly when the function is surjective, which is “Injective, Surjective, Bijective”'s question. Assuming they coincide answers it without asking.
2
Ignoring the domain when a rule is undefined somewhere1/x is a perfectly good function — on ℝ \ {0}. The rule and the domain together make the function.
3
Defining a function on classes without checking well-definednessAny rule stated through a representative owes this check. It is the most commonly skipped step in Number Theory and Cryptography.

Check your understanding

✓
Finish when you can state domain, codomain and image separately for any function you meet.

For f : ℤ → ℤ with f(n) = n², name all three, and then say what changes if the codomain is narrowed to the set of perfect squares. That narrowing is the whole difference “Injective, Surjective, Bijective” measures.

Note: A function is formally a set of pairs, so two functions are equal when they have the same domain, the same codomain and the same value at every point. Two formulas that agree everywhere define one function; the same formula with different codomains defines two.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.