← mapSet Theory

Functions as Mappings

⚗ Dr. Möbius, from the lab

You think you know what a function is. A formula, right? "f(x)=x2f(x) = x^2"? Wrong — that's a costume, and a sloppy one at that. A function is a special kind of relation, defined in the cold language of sets, with two iron rules that a sloppy formula can violate without you even noticing it's broken. Today we strip the formula off and look at the machine underneath — and then we learn the most underrated word in all of mathematics: well-defined. Buckle in, you beautiful disaster.

THE BIG IDEA

A function f: A→B is a relation that assigns to every input exactly one output — total and single-valued.

A function is a relation with discipline

Last node: a relation on AA is a subset of pairs. A function is a relation ff from a set AA to a set BB — a subset of A×BA \times B — that obeys two rules, no exceptions:

  1. Total: every input gets an output. For every aAa \in A, there is some bBb \in B with (a,b)f(a, b) \in f. Nobody in AA is left unmapped.
  2. Single-valued: every input gets exactly one output. If (a,b)f(a, b) \in f and (a,b)f(a, b') \in f, then b=bb = b'. No input maps to two places.

Together: every element of AA is assigned one and only one element of BB. We write f:ABf : A \to B, and f(a)=bf(a) = b means (a,b)f(a, b) \in f. That's the whole definition — no formula required. A function is a set of input-output pairs with the discipline that each input shows up exactly once. Nothing more, nothing less, no exceptions.

A formula like f(x)=x2f(x) = x^2 is just one convenient way to specify which pairs are in ff. But the function is the set of pairs {(x,x2)xA}\{(x, x^2) \mid x \in A\}, not the squiggle "x2x^2". The squiggle is not the thing — same fucking lesson as when we built numbers, and you'll keep hearing it until it's reflexive.

Domain, codomain, image — declared versus earned

Three sets travel with every function, and confusing them is a rite of passage you should skip.

  • Domain = AA, the set of all legal inputs. Every element of AA must get used (totality).
  • Codomain = BB, the declared set of possible outputs. You announce it when you write f:ABf : A \to B.
  • Image (or range) = the set of outputs that actually get hit: im(f)={f(a)aA}B\operatorname{im}(f) = \{\, f(a) \mid a \in A \,\} \subseteq B.

The crucial distinction: the codomain is declared; the image is earned. When you write f:RR, f(x)=x2f : \mathbb{R} \to \mathbb{R},\ f(x) = x^2, you declared the codomain to be all of R\mathbb{R}. But the image is only [0,)[0, \infty) — no negative number is ever an output of squaring. The codomain is a promise about where outputs might land; the image is the truth about where they do land. Always im(f)B\operatorname{im}(f) \subseteq B, and often the containment is strict. That gap between declared and earned is exactly where the next lesson's theorems live.

The vertical line test, unmasked

Here's a "rule" you were handed in school with no explanation: a graph is a function iff every vertical line hits it at most once. Why? Because the vertical line test is just "single-valued" in graph clothing.

A graph lives in A×BA \times B — it's literally the set of pairs (a,f(a))(a, f(a)). A vertical line is "all points with first coordinate aa". If that line hit the graph at two points (a,b)(a, b) and (a,b)(a, b') with bbb \ne b', then the input aa would map to two outputs — violating single-valuedness. So "at most one hit per vertical line" is the single-valued rule, drawn. (And for totality, every vertical line over the domain must hit at least once.) Not a magic rule — a picture of the definition.

Well-defined: the word that separates pros from amateurs

Now the deep one, and the real reason this lesson exists. Sometimes a "rule" for a function secretly depends on how you wrote the input, not on the input itself. When that happens, the rule might not even be a function — it's just a process that produces different answers depending on how you dress up the question. You must check that it's well-defined, and most textbooks skip this check entirely, which is why graduates of those programs get eaten alive when they hit quotient spaces.

The danger zone is defining functions on equivalence classes (from the last node — fractions, integers mod nn). An equivalence class has many names: the rational 12\tfrac{1}{2} is also 24\tfrac{2}{4} is also 36\tfrac{3}{6}. If you define a function by picking a representative and computing with it, you'd better get the same answer no matter which representative you grab — otherwise your "function" gives different outputs for the same input, violating single-valuedness.

Example of a rule that FAILS. Try to define g(ab)=a+bg\big(\tfrac{a}{b}\big) = a + b on the rationals. Test it on the same number written two ways: g ⁣(12)=1+2=3,g ⁣(24)=2+4=6.g\!\left(\tfrac{1}{2}\right) = 1 + 2 = 3, \qquad g\!\left(\tfrac{2}{4}\right) = 2 + 4 = 6. But 12=24\tfrac{1}{2} = \tfrac{2}{4} — the same input! The rule spat out 33 and 66 for one number. Not well-defined, not a function. It depended on the representation, not the value.

Example that SUCCEEDS. Define h(ab)=ab+1h\big(\tfrac{a}{b}\big) = \tfrac{a}{b} + 1. On 12\tfrac{1}{2}: get 32\tfrac{3}{2}. On 24\tfrac{2}{4}: get 24+1=64=32\tfrac{2}{4} + 1 = \tfrac{6}{4} = \tfrac{3}{2}. Same answer. It only used the value, so it's well-defined. The lesson: whenever a function's inputs have multiple names, prove that different names give the same output before you call it a function. Pros check; amateurs get burned — and they don't even know they're burned until two lessons later when everything mysteriously explodes.

Three views, one object

Finally, the same function wears three costumes, and fluency means switching between them without thinking:

  • As a machine: feed in aa, the box does something, f(a)f(a) comes out. Great for intuition.
  • As a graph: the set of points (a,f(a))(a, f(a)) plotted in A×BA \times B. Great for seeing behavior.
  • As a set of pairs: f={(a,f(a))aA}A×Bf = \{(a, f(a)) \mid a \in A\} \subseteq A \times B. The actual definition — great for proofs.

Drag the bastard xx-probe and watch the machine view (input \to output) and the graph view (the point riding the curve) be the same object from two angles:

function grapher
x = 1.2x^2 → 1.44

Machine, graph, set of pairs — one function, three angles. The proofs in the next two lessons (injective, surjective, inverse) all run in the set of pairs view, so get comfortable there. It's the bedrock; the rest is decoration.

🔬 SPECIMENS (worked examples)

Worked example 1 — domain, codomain, image, separated

For f:RRf : \mathbb{R} \to \mathbb{R} given by f(x)=x2+1f(x) = x^2 + 1, state the domain, codomain, and image.

Domain: declared as R\mathbb{R}. And squaring-plus-one is defined for every real, so totality holds — domain =R= \mathbb{R}.

Codomain: declared as R\mathbb{R} by writing f:RRf : \mathbb{R} \to \mathbb{R}. This is a promise about where outputs may live, nothing more.

Image: what values does x2+1x^2 + 1 actually take? Since x20x^2 \ge 0 for all real xx, we have x2+11x^2 + 1 \ge 1, and every value 1\ge 1 is achieved (e.g. 5=f(2)5 = f(2)). So im(f)=[1,).\operatorname{im}(f) = [1, \infty).

The image [1,)[1,\infty) is a strict subset of the codomain R\mathbb{R} — no output is ever below 11, so all of (,1)(-\infty, 1) is declared-possible but never-hit. Codomain declared, image earned. That gap is exactly what "surjective" (next lesson) will measure.

Worked example 2 — is this rule actually a function? (spoiler: no)

Consider the relation R={(1,5),(2,7),(1,9),(3,7)}R = \{(1, 5), (2, 7), (1, 9), (3, 7)\} on A={1,2,3}A = \{1, 2, 3\} to B=ZB = \mathbb{Z}. Is RR a function ABA \to B? If not, fix it minimally.

Run the two rules.

Total? Every element of A={1,2,3}A = \{1,2,3\} must appear as a first coordinate. We see 1,2,31, 2, 3 all present. ✓

Single-valued? Each first coordinate appears once. But 11 appears in both (1,5)(1, 5) and (1,9)(1, 9) — input 11 maps to two outputs, 55 and 99. ✗

So RR is not a function: it violates single-valuedness at the input 11. The vertical line x=1x = 1 would hit the graph twice.

Minimal fix: delete one of the conflicting pairs, say drop (1,9)(1, 9). Then {(1,5),(2,7),(3,7)}\{(1,5), (2,7), (3,7)\} has each input once — total and single-valued, so it's a function. (Note (2,7)(2,7) and (3,7)(3,7) sharing the output 77 is totally fine — two inputs may share an output; that's only ruled out for injective functions, next lesson. It's two outputs for one input that's forbidden.)

Worked example 3 — the well-defined trap on mod-n classes (one passes, one fails spectacularly)

Working mod 55, someone defines F([a])=[a2]F([a]) = [a^2] ("square the class"). Show this IS well-defined. Then show G([a])=aG([a]) = a (return the representative itself, as an integer) is NOT.

Recall a class [a][a] mod 55 has many names: [2]=[7]=[12]=[2] = [7] = [12] = \dots For a rule on classes to be a function, it must give the same answer for every name.

F([a])=[a2]F([a]) = [a^2] — check well-defined. Suppose [a]=[b][a] = [b], i.e. ab(mod5)a \equiv b \pmod 5, so 5(ab)5 \mid (a - b). We must show [a2]=[b2][a^2] = [b^2], i.e. 5(a2b2)5 \mid (a^2 - b^2). Factor: a2b2=(ab)(a+b).a^2 - b^2 = (a - b)(a + b). Since 5(ab)5 \mid (a - b), it divides the product, so 5(a2b2)5 \mid (a^2 - b^2), hence [a2]=[b2][a^2] = [b^2]. The output didn't depend on the representative. Well-defined. ✓ (Test: [2]2=[4][2]^2 = [4] and [7]2=[49]=[4][7]^2 = [49] = [4], since 49=59+449 = 5\cdot 9 + 4. Same.)

G([a])=aG([a]) = a — check well-defined. This tries to return the actual integer you happened to write. Test on one class, two names: [2]=[7][2] = [7] as classes, but G([2])=2,G([7])=7.G([2]) = 2, \qquad G([7]) = 7. Same input class, two different outputs 272 \ne 7. Not well-defined — it depends entirely on which representative you scribbled, not on the class itself. So GG isn't a function on classes at all.

The discipline: any time inputs carry multiple names, prove representation-independence. FF passed because squaring respects congruence; GG failed because "the literal integer" doesn't.

☠ KNOWN HAZARDS

  • Confusing codomain with image. For f:RRf:\mathbb{R}\to\mathbb{R}, f(x)=x2f(x)=x^2, the codomain is R\mathbb{R} but the image is only [0,)[0,\infty). Codomain is a declaration; image is what's actually hit. Confusing them will cause you pain in the next lesson.

  • Thinking a formula is automatically a function. It must be total (defined on every input — 1/x1/x isn't, at 00) and single-valued (no ±\pm ambiguity — y=±xy = \pm\sqrt{x} isn't a function of xx). A formula is a candidate, not a guarantee.

  • Skipping the well-defined check on classes. Defining anything on fractions or mod-nn classes by a representative requires proving the output doesn't depend on which representative you picked. Skip it and you may not have a function at all — you may have a broken machine that looks fine until it blows up.

  • Forgetting totality. A function must handle every input in its declared domain. A rule that breaks on some domain element isn't a function on that domain. It's just a rule with a hole in it.

TL;DR

  • A function f:ABf: A \to B is a relation that is total (every input used) and single-valued (each input maps to exactly one output).

  • Domain AA (legal inputs), codomain BB (declared possible outputs), image {f(a)}B\{f(a)\} \subseteq B (outputs actually hit). Codomain is declared; image is earned.

  • The vertical line test is just "single-valued" drawn: two hits on one vertical line means one input with two outputs — not a function.

  • Well-defined: when inputs have many names (equivalence classes, fractions), you must check the rule gives the same output for every name. g(ab)=a+bg(\tfrac{a}{b}) = a+b fails; it depends on representation.

  • One function, three views: machine, graph, and set of pairs {(a,f(a))}\{(a, f(a))\}. Proofs live in the set-of-pairs view.

unlocks