0.4  Functions

Sets are the objects of this chapter. The next question is how to move between them, and the tool is a function. Almost everything in linear algebra is a question about a function: a linear map is a function, a matrix will turn out to encode one, and “does Ax=b have a solution, and is it unique?” is a question about whether a function is surjective and injective. This section fixes the language of functions, composition and inverses, and proves the handful of facts about them that the rest of the book uses without comment.

0.4.1. What a function is

At school a function is usually a formula, such as x2+1. A formula alone is not enough. The same formula x2 behaves differently depending on which numbers we feed it and where we allow the answers to land, and whether an equation x2=c can be solved depends on exactly that information. So a function carries three pieces of data, not one.

A function is a machine with a fixed input set and a fixed target set that turns each input into exactly one output.

Definition 0.4.1 (Function)

Let X and Y be sets. A function (or map) f:X→Y is a rule that assigns to every element x∈X exactly one element f(x)∈Y. The set X is the domain of f, the set Y is its codomain, and f(x) is the value of f at x. We also write x↦f(x).

Two functions f:X→Y and g:X′→Y′ are equal if X=X′, Y=Y′, and f(x)=g(x) for every x∈X.

In words: the first clause says every input gets an output, so nothing in the domain is left out. The second says the output is unique, so the rule never hesitates between two values. The codomain is where outputs are allowed to land; nothing says every element of Y must be hit.

If you want a definition that avoids the vague word “rule”, use the Cartesian product (Definition 0.3.10): a function X→Y is a subset G⊆X×Y such that for every x∈X there is exactly one y∈Y with (x,y)∈G. The set G is the graph of f, and f(x) is that unique y. Nothing in this book depends on which version you prefer.

Example (First examples)

Check each of the following against the two clauses of Definition 0.4.1.

  • (a) f:R→R, f(x)=3x−5. Every real x gives one real number 3x−5.
  • (b) s:R2→R, s(x,y)=x+y. The domain is a Cartesian product; each pair gives one sum.
  • (c) ℓ:{finite strings of the letters a,b}→N, sending a string to its length. The empty string has length 0, which is why it matters that N contains 0.
  • (d) For any set X, the rule x↦x is a function X→X. It looks too simple to matter, but it will play the role that the number 1 plays for multiplication.
  • (e) For any set Y, there is exactly one function ∅→Y, the empty function. Both clauses are about elements of the domain, and there are none, so they hold vacuously. It is a degenerate case that makes statements like “for every set X” true without exceptions.

The failures are just as instructive. The rule “x↦ the real number y with y2=x” is not a function R→R. At x=−1 there is no such y, so the first clause fails. At x=4 there are two, y=2 and y=−2, so the second clause fails. Repairing both problems gives a genuine function [0,∞)→R, x↦x, where x means the non-negative root.

The equality clause says the codomain is part of the function. The functions R→R, x↦x2 and R→[0,∞), x↦x2 have the same values but are different functions. This is not pedantry: we will see in a moment that one of them is surjective and the other is not.

Quick check. Let f,g:R→R be f(x)=|x| and g(x)=x2. Are f and g equal?

Solution. Yes. They have the same domain and the same codomain, and for every real x we have x2=|x|, because |x| is the non-negative number whose square is x2. Different formulas can describe the same function; what counts is the values.

0.4.2. Images and preimages

Often we want to push a whole set through a function, or ask which inputs land in a given region. Both operations get a name.

Definition 0.4.2 (Image and preimage)

Let f:X→Y be a function, A⊆X and B⊆Y.

  • The image of A under f is f(A):={f(a):a∈A}⊆Y. The set f(X) is called the image of f.
  • The preimage of B under f is f−1(B):={x∈X:f(x)∈B}⊆X.

In words: f(A) collects the outputs of the inputs in A. The preimage f−1(B) collects every input whose output lies in B. So y∈f(A) means “y=f(a) for some a∈A”, while x∈f−1(B) means “f(x)∈B”, with no existential quantifier at all.

Example (Images and preimages of the squaring map)

Let q:R→R, q(x)=x2. Compute q([−1,2]), q−1([1,4]) and q−1([−5,−1]).

Solution. As x runs over [−1,2], the square x2 takes every value in [0,4]: values in [0,1] come from [0,1], values in [1,4] from [1,2], and no square is negative or exceeds 22=4 on this interval. Hence q([−1,2])=[0,4].

Next, x2∈[1,4] means 1≤|x|≤2. Hence q−1([1,4])=[−2,−1]∪[1,2].

Finally, no real square lies in [−5,−1], so q−1([−5,−1])=∅. A preimage may be empty; that is not an error.

Warning. The symbol f−1(B) is defined for every function, invertible or not; it does not mean that an inverse function exists. For the same reason, pushing forward and pulling back need not undo each other. With q(x)=x2 on R: for B=[−1,4] we get q−1(B)=[−2,2] and q(q−1(B))=[0,4]≠B; for A=[0,1] we get q(A)=[0,1] and q−1(q(A))=[−1,1]≠A.

What does survive is one inclusion in each direction.

Proposition 0.4.1 (Image and preimage inclusions)

Let f:X→Y, A⊆X and B⊆Y. Then f(f−1(B))⊆BandA⊆f−1(f(A)).

Proof. Let y∈f(f−1(B)). By Definition 0.4.2, y=f(x) for some x∈f−1(B), and x∈f−1(B) means f(x)∈B. Hence y∈B.

Let a∈A. Then f(a)∈f(A) by definition of the image, so a∈f−1(f(A)) by definition of the preimage. This proves both inclusions.

The warning shows both inclusions can be strict. In Exercise (C3: When images and preimages undo each other) you will find exactly which property of f turns each one into an equality.

0.4.3. Injective, surjective, bijective

Given f:X→Y and a target y∈Y, the most basic question is how many solutions the equation f(x)=y has. There are two separate issues: whether there is at least one solution, and whether there is at most one. In linear algebra these become “does Ax=b have a solution?” and “is the solution unique?”, and they are answered by different tools. So the two halves deserve separate names.

Injective means no two inputs collide; surjective means every target is hit; bijective means both, so every equation f(x)=y has exactly one solution.

Definition 0.4.3 (Injective, surjective, bijective)

Let f:X→Y be a function.

  • f is injective (one-to-one) if for all x1,x2∈X, f(x1)=f(x2) implies x1=x2.
  • f is surjective (onto) if for every y∈Y there exists x∈X with f(x)=y. Equivalently, f(X)=Y.
  • f is bijective if it is both injective and surjective.

In words: injectivity says that if two inputs give the same output, they were the same input. Equivalently, by the contrapositive (Theorem 0.1.1), distinct inputs give distinct outputs. Surjectivity says the image of f fills the whole codomain. The quantifiers matter: in surjectivity the x is allowed to depend on y.

Negating these, as in Example (What “not injective” means) and Example (What “not surjective” means), tells us what a counterexample looks like. The map f is not injective when there exist x1≠x2 with f(x1)=f(x2): one collision is enough. It is not surjective when there exists y∈Y that equals f(x) for no x∈X: one missed target is enough.

The standard moves. To prove f injective, write “Suppose f(x1)=f(x2)” and work towards x1=x2. To prove f surjective, write “Let y∈Y” and then produce an x, usually found backwards by solving f(x)=y on scrap paper, and check forwards that f(x)=y.

The picture below shows maps between three-element sets, drawn as arrows. A collision is two arrows landing on one point; a missed target is a point with no arrow.

Diagram. Labels: X, Y, collision at p, nothing reaches r:\\ neither injective nor surjective, exactly one arrow into each point:\\ bijective
Example (Deciding injectivity and surjectivity)

Determine which of the following functions are injective, surjective or bijective.

  • (a) f:R→R, f(x)=3x−5.
  • (b) g:Z→Z, g(n)=2n.
  • (c) s:R2→R, s(x,y)=x+y.
  • (d) idX:X→X, x↦x, for any set X.

Solution.

  • (a) Bijective. Suppose f(x1)=f(x2). Then 3x1−5=3x2−5, so 3x1=3x2, and dividing by 3≠0 gives x1=x2. Hence f is injective. Let y∈R. Solving 3x−5=y suggests x=(y+5)/3, and indeed f((y+5)/3)=(y+5)−5=y. Hence f is surjective.

  • (b) Injective, not surjective. Suppose 2n1=2n2; then n1=n2. But 1 is not hit: 2n=1 has no integer solution, since 2n is even. Note that the same formula x↦2x on R→R is surjective; the failure comes from the domain and codomain, not the formula.

  • (c) Surjective, not injective. Let t∈R; then s(t,0)=t, so s is surjective. But s(1,0)=1=s(0,1) while (1,0)≠(0,1), a collision, so s is not injective.

  • (d) Bijective. If idX(x1)=idX(x2) then x1=x2 directly, and every x∈X is hit by itself. This degenerate case is the model of a bijection and reappears as the identity function below.

The cleanest way to see that domain and codomain are part of the question is to keep the formula x↦x2 fixed and change only the sets. Write [0,∞) for the non-negative reals.

Function Injective? Surjective?
R→R no: (−1)2=12 no: −1 is not a square
R→[0,∞) no: (−1)2=12 yes: y=(y)2
[0,∞)→R yes no: −1 is not a square
[0,∞)→[0,∞) yes yes

For the injective rows: if x1,x2≥0 and x12=x22, then (x1−x2)(x1+x2)=0. Either x1=x2, or x1+x2=0, which for non-negative numbers forces x1=x2=0. In both cases x1=x2.

Read the table as a set of minimal changes. Shrinking the domain from R to [0,∞) removes the collision between −1 and 1, so the injectivity clause now holds. Shrinking the codomain removes the missed targets, so the surjectivity clause now holds. The formula never changed.

Warning. Do not confuse injectivity with the statement “x1=x2⇒f(x1)=f(x2)”. That implication is true for every function; it is the second clause of Definition 0.4.1. Injectivity is its converse, “f(x1)=f(x2)⇒x1=x2”, and x↦x2 on R satisfies the first but not the second.

Why these definitions. Surjectivity depends on the codomain, and injectivity on the domain, so neither is a property of a formula alone; this is why Definition 0.4.1 insists on both sets. The names are descriptive: “in-jective” throws the domain into the codomain without collisions, and “sur-jective” (French sur, onto) lands onto all of it. In Chapter 2 we will meet a fast test for linear maps: a linear map is injective exactly when the only input sent to 0 is 0. That test is special to linear maps and fails for general functions, which is one reason the general definitions come first.

0.4.4. Composition

If the outputs of one function can be fed into another, we can run them in sequence. This is the operation that matrix multiplication will describe in Chapter 4.

Definition 0.4.4 (Composition)

Let f:X→Y and g:Y→Z be functions. The composition g∘f:X→Z is defined by (g∘f)(x):=g(f(x))for every x∈X.

Read g∘f as “g after f”: the function written on the right acts first. The definition needs the codomain of f to equal the domain of g, so that g(f(x)) makes sense.

Example (Order matters)
  • (a) Let f,g:R→R be f(x)=x+3 and g(x)=2x. Compute g∘f and f∘g.

  • (b) Let q:R→[0,∞), q(x)=x2, and r:[0,∞)→R, r(y)=y. Compute r∘q and q∘r.

Solution.

  • (a) (g∘f)(x)=g(x+3)=2x+6, while (f∘g)(x)=f(2x)=2x+3. At x=0 these are 6≠3, so g∘f≠f∘g. Composition is not commutative, even when both orders make sense.

  • (b) r∘q:R→R is x↦x2=|x|. In the other order, q∘r:[0,∞)→[0,∞) is y↦(y)2=y. So q∘r does nothing, while r∘q forgets the sign of x. The two orders do not even have the same domain. We will return to this pair when we discuss one-sided inverses.

Although the order matters, the grouping does not. This is what lets us write h∘g∘f without brackets.

Theorem 0.4.2 (Associativity of composition)

Let f:X→Y, g:Y→Z and h:Z→W be functions. Then (h∘g)∘f=h∘(g∘f).

Proof. Both sides are functions X→W. Let x∈X. By Definition 0.4.4 applied twice on each side, ((h∘g)∘f)(x)=(h∘g)(f(x))=h(g(f(x)))=h((g∘f)(x))=(h∘(g∘f))(x). Since the values agree at every x, the two functions are equal by Definition 0.4.1.

Next, the properties of the previous subsection pass through composition.

Theorem 0.4.3 (Composition preserves injectivity and surjectivity)

Let f:X→Y and g:Y→Z be functions.

  • (a) If f and g are injective, then g∘f is injective.
  • (b) If f and g are surjective, then g∘f is surjective.
  • (c) If f and g are bijective, then g∘f is bijective.

Idea. For (a), start from a collision of g∘f and peel off one function at a time, outermost first: injectivity of g removes g, then injectivity of f removes f. For (b), run backwards: reach z from some y using g, then reach that y from some x using f.

Proof.

  • (a) Suppose (g∘f)(x1)=(g∘f)(x2), that is, g(f(x1))=g(f(x2)). Since g is injective, f(x1)=f(x2). Since f is injective, x1=x2. Hence g∘f is injective.

  • (b) Let z∈Z. Since g is surjective, there is y∈Y with g(y)=z. Since f is surjective, there is x∈X with f(x)=y. Then (g∘f)(x)=g(y)=z. Hence g∘f is surjective.

  • (c) If f and g are bijective, then g∘f is injective by (a) and surjective by (b), so it is bijective.

The converse of (a) is false, but half of it survives, and that half is surprisingly useful. Suppose g∘f is injective. A collision of f would be a collision of g∘f, so f must be injective; but g is only used on the image f(X), so g may still collide outside it. The surjective case is dual.

Theorem 0.4.4 (Partial converse for compositions)

Let f:X→Y and g:Y→Z be functions.

  • (a) If g∘f is injective, then f is injective.
  • (b) If g∘f is surjective, then g is surjective.

Proof.

  • (a) Suppose f(x1)=f(x2). Applying g to both sides gives (g∘f)(x1)=(g∘f)(x2). Since g∘f is injective, x1=x2. Hence f is injective.

  • (b) Let z∈Z. Since g∘f is surjective, there is x∈X with g(f(x))=z. Put y=f(x)∈Y; then g(y)=z. Hence g is surjective.

Remark. The other halves really fail. Take X=Z={1}, Y={1,2}, f(1)=1 and g(1)=g(2)=1. Then g∘f=id{1} is bijective, yet g is not injective (g(1)=g(2)) and f is not surjective (nothing maps to 2).

0.4.5. Identity and one-sided inverses

The function that does nothing deserves a name, because “undoing f” means “composing with f gives the function that does nothing”.

Definition 0.4.5 (Identity function)

For a set X, the identity function on X is idX:X→X, idX(x)=x.

For every f:X→Y we have f∘idX=f and idY∘f=f, since both sides send x to f(x). Notice the subscripts: on the right of f the identity lives on the domain, on the left on the codomain.

Now look again at Example (Order matters) (b). There q∘r=id[0,∞), but r∘q=|⋅|≠idR. So r undoes q from one side only. This one-sided behavior is common enough to need a word.

Definition 0.4.6 (Left and right inverses)

Let f:X→Y. A function g:Y→X is a left inverse of f if g∘f=idX, and a right inverse of f if f∘g=idY.

“Left” and “right” refer to where g is written in the composition. A left inverse recovers the input from the output: g(f(x))=x. A right inverse picks, for each target y, an input that reaches it: f(g(y))=y. In Example (Order matters) (b), r is a right inverse of q, and q is a left inverse of r. But r is not a left inverse of q, because r(q(−1))=1≠−1.

The descriptions “recovers the input” and “reaches every target” should remind you of injective and surjective. They are exactly that.

Theorem 0.4.5 (Left inverses and injectivity)

Let f:X→Y with X non-empty. Then f has a left inverse if and only if f is injective.

Idea. (⇒) is Theorem 0.4.4 with g∘f=idX, which is injective. For (⇐) we must define g(y) for every y∈Y. If y is in the image, injectivity gives a unique x with f(x)=y, and g(y) must be that x. If y is not in the image, the condition g∘f=idX says nothing about g(y), so we send y anywhere in X. That is where non-emptiness is used.

Proof. (⇒) Suppose g∘f=idX. The identity idX is injective, so f is injective by Theorem 0.4.4 (a).

(⇐) Suppose f is injective. Since X≠∅, we may fix some x0∈X. Define g:Y→X as follows. If y∈f(X), there is some x∈X with f(x)=y, and this x is unique because f is injective; set g(y)=x. If y∉f(X), set g(y)=x0. Every y receives exactly one value, so g is a function. For x∈X, the element y=f(x) lies in f(X), and the unique input sent to it is x, so g(f(x))=x. Hence g∘f=idX, as claimed.

The hypothesis X≠∅ is not decoration. The empty function ∅→{1} is injective (there are no two inputs to collide), but there is no function {1}→∅ at all, since 1 would have nowhere to go.

Theorem 0.4.6 (Right inverses and surjectivity)

Let f:X→Y. Then f has a right inverse if and only if f is surjective.

Proof. (⇒) Suppose f∘g=idY. The identity idY is surjective, so f is surjective by Theorem 0.4.4 (b).

(⇐) Suppose f is surjective. For each y∈Y the set f−1({y}) is non-empty, so we may choose one element of it and call it g(y). This defines g:Y→X with f(g(y))=y for every y∈Y, that is, f∘g=idY.

When Y is infinite, the step “choose one element from each of infinitely many non-empty sets at once” is an axiom of set theory, the axiom of choice; we use it freely and never mention it again in this chapter.

Unlike an inverse in the usual sense, one-sided inverses are rarely unique. For q:R→[0,∞), x↦x2, both y↦y and y↦−y are right inverses: each picks one of the two square roots.

Quick check. Give a function f:N→N that has a left inverse but no right inverse.

Solution. Take f(n)=n+1. It is injective, since n1+1=n2+1 gives n1=n2, so by Theorem 0.4.5 it has a left inverse; explicitly, g(m)=m−1 for m≥1 and g(0)=0 satisfies g(f(n))=n. It is not surjective, since n+1=0 has no solution in N. So by Theorem 0.4.6 it has no right inverse.

0.4.6. Inverses

When a function has an inverse on both sides, the two one-sided inverses turn out to coincide, and we get the notion of inverse we know from ex and ln⁡x.

Definition 0.4.7 (Inverse function)

Let f:X→Y. A function g:Y→X is an inverse of f if g∘f=idXandf∘g=idY. If f has an inverse, f is invertible.

Both conditions are needed: Example (Order matters) (b) shows a pair with one but not the other. The next theorem says which functions are invertible and that “the” inverse is justified.

Theorem 0.4.7 (Bijective if and only if invertible)

A function f:X→Y is invertible if and only if it is bijective. Moreover, an inverse of f, when it exists, is unique; we denote it f−1:Y→X.

Idea. For (⇐) one could combine the two one-sided theorems, but that route needs X≠∅ and a choice. A bijection makes both unnecessary: every y has exactly one preimage, so f−1(y) is forced. For uniqueness, the standard move is to assume two inverses g and h, and sandwich: g=g∘(f∘h)=(g∘f)∘h=h.

Proof. (⇒) Suppose g is an inverse of f. Since g∘f=idX is injective, f is injective by Theorem 0.4.4 (a). Since f∘g=idY is surjective, f is surjective by Theorem 0.4.4 (b). Hence f is bijective.

(⇐) Suppose f is bijective, and let y∈Y. Since f is surjective, some x∈X has f(x)=y, and since f is injective, this x is unique. Define g(y) to be this x. Then f(g(y))=y for every y∈Y, so f∘g=idY. For x∈X, the unique input sent to f(x) is x itself, so g(f(x))=x, and g∘f=idX. Hence g is an inverse of f.

(Uniqueness) Suppose g and h are both inverses of f. Then g=g∘idY=g∘(f∘h)=(g∘f)∘h=idX∘h=h, where the third equality is Theorem 0.4.2. This proves the theorem.

The uniqueness computation used only g∘f=idX and f∘h=idY. So it proves more: if f has a left inverse g and a right inverse h, then g=h, and this common function is the inverse. The same sandwich will prove that a matrix has at most one inverse.

Warning. The notation f−1 now has two meanings. The preimage f−1(B) of a set B⊆Y exists for every f. The inverse function f−1, applied to an element y∈Y, exists only for bijective f. Writing q−1(4) for q(x)=x2 on R is meaningless, while q−1({4})={−2,2} is fine. When f is bijective the two agree: f−1({y})={f−1(y)}.

Example (Finding inverses)

For each function, decide whether it is invertible, and if so find its inverse.

  • (a) f:R→R, f(x)=5−2x.
  • (b) t:R2→R2, t(x,y)=(y,x).
  • (c) g:R→R, g(x)=x2.
  • (d) h:[0,∞)→[0,∞), h(x)=x2.

Solution.

  • (a) Solving 5−2x=y gives x=(5−y)/2. Put k(y)=(5−y)/2. Check: k(f(x))=(5−(5−2x))/2=x and f(k(y))=5−(5−y)=y. So k is an inverse of f, and f−1(y)=(5−y)/2.

  • (b) t(t(x,y))=t(y,x)=(x,y), so t∘t=idR2. Hence t is its own inverse: t−1=t.

  • (c) Not invertible. g(−1)=g(1), so g is not injective, hence not bijective, and Theorem 0.4.7 says it has no inverse.

  • (d) Invertible. By the table in the previous subsection h is bijective, and the inverse is h−1(y)=y: indeed x2=x for x≥0 and (y)2=y for y≥0.

To undo two steps, undo the last one first. When you dress, the shirt goes on before the jacket; to undress, the jacket comes off first.

Theorem 0.4.8 (Inverse of a composition)

Let f:X→Y and g:Y→Z be bijective. Then g∘f is bijective and (g∘f)−1=f−1∘g−1.

Proof. Using Theorem 0.4.2 to regroup, (f−1∘g−1)∘(g∘f)=f−1∘(g−1∘g)∘f=f−1∘idY∘f=f−1∘f=idX, and in the same way (g∘f)∘(f−1∘g−1)=g∘(f∘f−1)∘g−1=g∘g−1=idZ. Hence f−1∘g−1 is an inverse of g∘f. By Theorem 0.4.7, g∘f is bijective and its unique inverse is f−1∘g−1, as claimed.

The same reversal will appear for matrices as (AB)−1=B−1A−1, and for the same reason.

0.4.7. Maps between finite sets

For functions between two finite sets of the same size, one of the two conditions comes for free. This is the pigeonhole principle, and it is the ancestor of a move used constantly from Chapter 2 on: instead of checking both injectivity and surjectivity, count, and check only one.

We write |X| for the number of elements of a finite set X. We use two counting facts about lists without proof: a list of n entries with a repeated entry contains at most n−1 distinct elements, and a subset of a finite set Y with |Y| elements is all of Y.

Theorem 0.4.9 (Injective iff surjective for finite sets of equal size)

Let X and Y be finite sets with |X|=|Y|, and let f:X→Y. Then f is injective if and only if f is surjective. In that case f is bijective.

Idea. List the elements of X as x1,…,xn; the image f(X) is then listed by f(x1),…,f(xn). Injective means this list has no repeats, so it has n distinct entries and must fill Y. Surjective means the list fills Y, which has n elements, so there is no room for a repeat.

Proof. Let n=|X|=|Y|, and write X={x1,…,xn} with the xi distinct. By Definition 0.4.2, f(X) consists of the entries of the list f(x1),…,f(xn).

(⇒) Suppose f is injective. Since the xi are distinct, the entries f(x1),…,f(xn) are distinct. Hence f(X) is a subset of Y with n=|Y| elements, so f(X)=Y, and f is surjective.

(⇐) We prove the contrapositive (Theorem 0.1.1). Suppose f is not injective. Then f(xi)=f(xj) for some i≠j, so the list f(x1),…,f(xn) has a repeated entry and f(X) has at most n−1 elements. Hence f(X)≠Y, and f is not surjective.

So if f is injective or surjective, the two directions show that it is both, that is, bijective.

For a finite set X, this applies to every f:X→X: such a map is injective if and only if it is surjective. In Chapter 2 the same shape of statement returns for linear maps V→V on a finite-dimensional space, with dimension playing the role of the number of elements.

Warning. The theorem needs finiteness. The map g:N→N, g(n)=2n, is injective but misses every odd number, so it is not surjective, even though domain and codomain are the same set. Infinite sets have room for an injection into a proper part of themselves.

0.4.8. Exercises

A. Check your understanding

Exercise (A1)
  • (a) State what it means for f:X→Y to be injective, and what it means to be surjective.
  • (b) True or false: the functions R→R, x↦x3 and R→R, x↦x⋅x⋅x are equal. Give a reason.
  • (c) True or false: if g∘f is injective, then g is injective. Give a reason.
  • (d) Write down the first line of a proof that a function f is injective, and the first line of a proof that it is surjective.
  • (e) True or false: the preimage f−1(B) is defined only when f is bijective.
  • (f) True or false: every injective function {1,2,3}→{1,2,3} is bijective. Name the result you use.

Solution.

  • (a) f is injective if for all x1,x2∈X, f(x1)=f(x2) implies x1=x2. It is surjective if for every y∈Y there exists x∈X with f(x)=y.

  • (b) True. They have the same domain and codomain, and x3=x⋅x⋅x for every real x. Equality of functions is about values, not formulas.

  • (c) False. In the remark after Theorem 0.4.4, g∘f=id{1} is injective but g(1)=g(2). Only f is forced to be injective.

  • (d) Injective: “Suppose x1,x2∈X satisfy f(x1)=f(x2).” Surjective: “Let y∈Y.”

  • (e) False. f−1(B)={x∈X:f(x)∈B} makes sense for every function; see Definition 0.4.2 and the warning after it.

  • (f) True, by Theorem 0.4.9: domain and codomain are finite with the same number of elements, so an injective map is surjective, hence bijective.

B. Practice

Exercise (B1: Injective or surjective?)

Determine whether each function is injective, and whether it is surjective. Justify your answers.

  • (a) f:Z→Z, f(n)=3n+1.
  • (b) g:R2→R2, g(x,y)=(x+y,x−y).
  • (c) h:N→N, h(n)=⌊n/2⌋, the largest integer not exceeding n/2.
  • (d) p:R→R2, p(t)=(t,t2).

Solution.

  • (a) Injective, not surjective. Suppose 3n1+1=3n2+1. Then 3n1=3n2, so n1=n2. But 0 is not hit: 3n+1=0 would give n=−1/3∉Z.

  • (b) Bijective. Suppose g(x1,y1)=g(x2,y2). Then x1+y1=x2+y2 and x1−y1=x2−y2. Adding the two equations gives 2x1=2x2, and subtracting gives 2y1=2y2, so (x1,y1)=(x2,y2). Hence g is injective. Let (u,v)∈R2. Then g(u+v2,u−v2)=(u+v2+u−v2, u+v2−u−v2)=(u,v). Hence g is surjective.

  • (c) Surjective, not injective. Let m∈N. Then h(2m)=⌊m⌋=m, so h is surjective. But h(0)=0=h(1), a collision, so h is not injective.

  • (d) Injective, not surjective. Suppose (t1,t12)=(t2,t22). Comparing first coordinates gives t1=t2. But (0,1) is not hit: p(t)=(0,1) forces t=0 and then t2=0≠1.

Exercise (B2: Inverses)
  • (a) Show that f:R→R, f(x)=7−4x, is invertible and find f−1.
  • (b) Let D=R∖{1} and define k:D→D by k(x)=x+1x−1. Show that k really takes values in D, and that k∘k=idD. Hence deduce that k is bijective and find k−1.
  • (c) With g as in B1(b), find g−1. Hence find the inverse of g∘g without computing g∘g first.

Solution.

  • (a) Put e(y)=(7−y)/4. Then e(f(x))=(7−(7−4x))/4=x and f(e(y))=7−(7−y)=y. So e is an inverse of f, and by Theorem 0.4.7 f is invertible with f−1(y)=(7−y)/4.

  • (b) For x∈D the denominator x−1 is non-zero, so k(x) is a real number. If k(x)=1, then x+1=x−1, that is, 1=−1, which is false. Hence k(x)∈D. Next, for x∈D, k(k(x))=x+1x−1+1x+1x−1−1=(x+1)+(x−1)(x+1)−(x−1)=2x2=x, where the second equality multiplies numerator and denominator by x−1≠0. So k∘k=idD. This says k is an inverse of itself, so k is invertible, hence bijective by Theorem 0.4.7, and k−1=k.

  • (c) The solution of B1(b) shows that e(u,v)=(u+v2,u−v2) satisfies g∘e=idR2. Also e(g(x,y))=e(x+y,x−y)=(2x2,2y2)=(x,y), so e∘g=idR2. Hence g−1=e. By Theorem 0.4.8, (g∘g)−1=g−1∘g−1,g−1(g−1(u,v))=g−1(u+v2,u−v2)=(u2,v2). (As a check, g(g(x,y))=g(x+y,x−y)=(2x,2y), which (u,v)↦(u/2,v/2) indeed undoes.)

Exercise (B3: Images of unions and intersections)

Let f:X→Y and A1,A2⊆X.

  • (a) Prove that f(A1∪A2)=f(A1)∪f(A2).
  • (b) Prove that f(A1∩A2)⊆f(A1)∩f(A2).
  • (c) Using q(x)=x2 on R, give an example where the inclusion in (b) is strict.

Solution.

  • (a) We use double inclusion (Theorem 0.3.1).

    (⊆) Let y∈f(A1∪A2). Then y=f(a) for some a∈A1∪A2. If a∈A1, then y∈f(A1); if a∈A2, then y∈f(A2). In either case y∈f(A1)∪f(A2).

    (⊇) Let y∈f(A1)∪f(A2). If y∈f(A1), then y=f(a) for some a∈A1⊆A1∪A2, so y∈f(A1∪A2). The case y∈f(A2) is the same with the roles of A1 and A2 swapped. This proves the equality.

  • (b) Let y∈f(A1∩A2). Then y=f(a) for some a∈A1∩A2. Since a∈A1, y∈f(A1), and since a∈A2, y∈f(A2). Hence y∈f(A1)∩f(A2).

  • (c) Take A1={−1} and A2={1}. Then A1∩A2=∅, so q(A1∩A2)=∅, while q(A1)∩q(A2)={1}∩{1}={1}. The inclusion is strict. The collision q(−1)=q(1) is what goes wrong; for an injective f, equality holds in (b).

C. Going deeper

Exercise (C1: Left inverses are not unique)
  • (a) Let f:X→Y be injective but not surjective, with X having at least two elements. Prove that f has at least two different left inverses.
  • (b) Find two different left inverses of f:N→N, f(n)=n+1.
  • (c) Explain why a bijective function has exactly one left inverse.

Hint for (a): look at the proof of Theorem 0.4.5 and ask where it made a free choice.

Solution.

  • (a) Since f is not surjective, there is y0∈Y∖f(X). Since X has at least two elements, there are x0≠x1 in X. As in the proof of Theorem 0.4.5, for y∈f(X) let y¯ be the unique x∈X with f(x)=y. Define g0,g1:Y→X by gi(y)=y¯ for y∈f(X), and gi(y)=xi for y∉f(X). The proof of Theorem 0.4.5 shows that each gi is a left inverse of f, since gi(f(x))=x uses only the values on f(X). But g0(y0)=x0≠x1=g1(y0), so g0≠g1.

  • (b) The only element missed by f is 0. Define g0(m)=m−1 for m≥1 and g0(0)=0; define g1(m)=m−1 for m≥1 and g1(0)=5. Both satisfy gi(n+1)=n for every n∈N, and g0(0)≠g1(0).

  • (c) Let f be bijective, and let g be any left inverse. By Theorem 0.4.7, f has an inverse f−1, which in particular is a right inverse. By the observation following that theorem, a left inverse and a right inverse of the same function are equal, so g=f−1. Hence every left inverse equals f−1. Conversely, f−1 is itself a left inverse, since f−1∘f=idX. So f has exactly one left inverse.

Exercise (C2: Self-maps of finite and infinite sets)
  • (a) Let X be a finite set and f:X→X injective. Prove that f is bijective.
  • (b) Show that (a) fails for X=N: give an injective f:N→N that is not bijective.
  • (c) Give a surjective h:N→N that is not bijective.
  • (d) Let X be finite and f,g:X→X with g∘f=idX. Prove that f∘g=idX as well.

Hint for (d): first show that f is bijective.

Solution.

  • (a) The domain and codomain are the same finite set, so |X|=|X|. By Theorem 0.4.9, the injective map f is bijective.

  • (b) f(n)=n+1 is injective, since n1+1=n2+1 gives n1=n2, but 0 is not of the form n+1 with n∈N. Hence f is not surjective, so not bijective.

  • (c) Take h(n)=⌊n/2⌋. By B1(c) it is surjective but not injective.

  • (d) Since g∘f=idX is injective, f is injective by Theorem 0.4.4 (a). By (a), f is bijective, so it has an inverse f−1 by Theorem 0.4.7. Then g=g∘idX=g∘(f∘f−1)=(g∘f)∘f−1=idX∘f−1=f−1, using Theorem 0.4.2. Hence f∘g=f∘f−1=idX, as claimed. (For X=N this fails: with f(n)=n+1 and g0 from C1(b), g0∘f=idN but f(g0(0))=1≠0. The matrix version of (d), “AB=I implies BA=I for square matrices”, is proved in Chapter 3.)

Exercise (C3: When images and preimages undo each other)

Let f:X→Y.

  • (a) Prove that f(f−1(B))=B for every B⊆Y if and only if f is surjective.
  • (b) Prove that f−1(f(A))=A for every A⊆X if and only if f is injective.

Hint: for each direction you need only one well-chosen set; try a one-element set.

Solution.

  • (a) (⇒) Suppose the equality holds for every B, and let y∈Y. Taking B={y} gives f(f−1({y}))={y}, so y∈f(f−1({y})). Hence y=f(x) for some x, and f is surjective.

    (⇐) Suppose f is surjective, and let B⊆Y. The inclusion f(f−1(B))⊆B is Proposition 0.4.1. For the reverse, let y∈B. Since f is surjective, y=f(x) for some x∈X. Then f(x)∈B, so x∈f−1(B), and hence y=f(x)∈f(f−1(B)). By Theorem 0.3.1, f(f−1(B))=B.

  • (b) (⇒) Suppose the equality holds for every A, and suppose f(x1)=f(x2). Taking A={x1} gives f−1({f(x1)})={x1}. Since f(x2)=f(x1), we have x2∈f−1({f(x1)})={x1}, so x2=x1. Hence f is injective.

(⇐) Suppose f is injective, and let A⊆X. The inclusion A⊆f−1(f(A)) is Proposition 0.4.1. For the reverse, let x∈f−1(f(A)). Then f(x)∈f(A), so f(x)=f(a) for some a∈A. Since f is injective, x=a∈A. By Theorem 0.3.1, f−1(f(A))=A.

Found a typo or a mistake? Report it, or read this page’s source

The text of this book is licensed under CC BY-NC-SA 4.0.