Functions and Relations (CSCI 2824, Spring 2015)

This page covers the following concepts.

  • Determining whether a function is injective

  • Determining whether a function is surjective

  • Proving a function is injective/surjective

These topics can be found in Section 4.3 of the textbook.

Injective and surjective functions

Recall the definition of injective and surjective functions.

Injective, surjective and bijective functions

A function F:Ato B is said to be

  • injective (or one-one) if for any distinct u,vin A, F(u)neq F(v);

  • surjective (or onto) if for any yin B, exists, xin A such that y=F(x).

  • bijective if F is both injective and surjective.

More descriptively,

  • F is injective if F maps every element of A to a unique element in B. In other words no element of B are mapped to by two or more elements of A.

    • (forall a,b in A) f(a) = f(b) Rightarrow a = b . (This is the contrapositive of the implication we have in the definition.)

  • F is surjective if every element of B is mapped to by some element of A. In other words, nothing is left out.

Example 1

Classify the following functions f_j: mathbb{N} rightarrow mathbb{N} between natural numbers as one-to-one and onto.

f_j One-to-One? Onto?
f_1(n) = n^2 Yes No
f_2(n) = n+3 Yes No
f_3(n) = lfloor sqrt{n} rfloor No Yes
f_4(n) = left{begin{array}{l} n-1, mbox{odd} n  n+1, mbox{even} n  end{array} right.. Yes Yes

It helps to visualize the mapping for each function to understand the answers.

Reasons
  • f_1 is not onto because it does not have any element n such that f_1(n)=3, for instance.

  • f_2 is not onto because no element n such that f_2(n) = 0, for instance.

  • f_3 is not one-to-one since f_3(2) = f_3(1) =1 .

Guessing whether a function f:mathbb{R}tomathbb{R} is injective/surjective

If a given function has both the domain and codomain being the set of real numbers mathbb{R}, then one visual way of guessing whether that function is injective/surjective can be done by using the graph. We imagine swiping a horizontal rule up or down and the number of intersection this horizontal rule makes with the graph.

  • A function is injective if and only if the horizontal rule intersects the graph at most once at any fixed y-value.

  • A function is surjective if and only if the horizontal rule intersects the graph at least once at any fixed y-value.

(As an aside, the vertical rule can be used to determine whether a relation is well-defined: at any fixed x-value, the vertical rule should intersect the graph of a function with domain mathbb{R} exactly once.)

Proving that a function is injective/surjective

Let f: Ato B be a function.

  • To prove that f is injective, we proceed like this…

    • Let y,zin A be such that f(y)=f(z).

    • Infer from the equality f(y)=f(z) and use the definition of f to show that y=z.

  • To prove that f is surjective, we proceed like this…

    • Fix any yin B.

    • Consider the equality y=f(x) and express x in terms of y.

    • Double check: plug in your expression for x into f, and evaluate f(x)=cdots=y.

Example 2

Prove that the function f:mathbb{R}_+tomathbb{R}: nmapsto n^2 is one-to-one.

Proof
  • Fix any m,ninmathbb{R} with f(m) = f(n).

  • Then f(m) = f(n) implies that m^2 = n^2.

  • Then m = pm n.

  • Splitting cases on ngeq0, we have

    • For n neq 0, -n notin mathbb{R}_+, therefore m = n for this case.

    • For n = 0, we have m = n =0.

  • Therefore, it follows that m = n for both cases.

  • This proves that f is one-to-one. QED.

Example 3

Prove that the function f:mathbb{R}_+tomathbb{R}_+: tmapsto frac{1}{1+t} is injective.

Proof
  • Fix any s,tinmathbb{R}_+ with f(s)=f(t).

  • Then f(s)=f(t) implies that frac{1}{1+s} = frac{1}{1+t}.

  • Inverting the fractions on both sides of the equality, we get 1+s=1+t.

  • Canceling 1 on both sides, we get s=t.

  • This proves that f is injective. QED.

Example 4

Prove that the function f:mathbb{R}tomathbb{R}: xmapsto -2x + 3 is surjective.

Proof
  • Fix any yinmathbb{R}.

  • Consider the equality y=f(x)=-2x+3. Expressing x in terms of y, we get x=frac{1}{2}(3-y).

  • Now note that x=frac{1}{2}(3-y)inmathbb{R} and f(x)= -2left(frac{1}{2}(3-y)right) +3 = y.

  • This shows that f is surjective. QED.

Example 5

Prove that the function f:mathbb{N}tomathbb{N}: nmapsto lfloor sqrt{n} rfloor is onto.

Proof
  • Fix any m in mathbb{N}.

  • Then m^2inmathbb{N}

  • and f(m^2)=lfloor sqrt{m^2} rfloor = lfloor m rfloor = m.

  • Therefore, all m in mathbb{N} are mapped onto.

  • Hence f is onto. QED.