A func­tion is a rule that takes each mem­ber of one set and gives it exactly one part­ner in another set. The idea runs through the whole of higher math­e­mat­ics: every graph you will draw in this chap­ter, every for­mula such as f(x)=x2+3x+5f(x) = x^2 + 3x + 5, and every log­a­rithm and mod­u­lus you meet later is a func­tion. This les­son sets out what a func­tion is, how to recog­nise one from an arrow dia­gram, and the words used to describe it: image, pre-image, domain, codomain and range.

Rela­tions and func­tions

In the chap­ter on sets and rela­tions you met a rela­tion from a set AA to a set BB: a col­lec­tion of ordered pairs (a,b)(a, b) with a∈Aa \in A and b∈Bb \in B. A rela­tion can be shown as an arrow dia­gram, with an arrow from aa to bb for every pair (a,b)(a, b).

A func­tion is a spe­cial kind of rela­tion.

Def­i­n­i­tion. A rela­tion ff from AA to BB is called a func­tion if each and every ele­ment of AA is asso­ci­ated with a unique (exactly one) ele­ment of BB. We write

f:A→Bf : A \to B

and read it as "ff maps AA to BB".

So two con­di­tions must both hold:

  1. Every ele­ment of AA has an arrow leav­ing it. No ele­ment of AA is left out.
  2. No ele­ment of AA has two or more arrows leav­ing it.

Noth­ing is said about BB. An ele­ment of BB may receive sev­eral arrows, or none at all.

Exam­ple 1

Let A={1,2,3,4}A = \{1, 2, 3, 4\} and B={a,b,c,d}B = \{a, b, c, d\}, and let ff be the rela­tion with arrows 1→a1 \to a, 2→a2 \to a, 3→b3 \to b, 4→c4 \to c. Is ff a func­tion?

Check the two con­di­tions. Every ele­ment of AA (that is 11, 22, 33 and 44) has an arrow. Each has only one arrow. So f:A→Bf : A \to B is a func­tion.

Notice two things that do not spoil it. Both 11 and 22 go to the same ele­ment aa; that is allowed. The ele­ment dd of BB receives no arrow; that is allowed too.

As a set of ordered pairs, f={(1,a),(2,a),(3,b),(4,c)}f = \{(1, a), (2, a), (3, b), (4, c)\}.

Exam­ple 2

Let B={1,2,3}B = \{1, 2, 3\} and C={a,b,c,d}C = \{a, b, c, d\}, and let gg have arrows 1→a1 \to a and 2→a2 \to a only. Is gg a func­tion from BB to CC?

The ele­ment 33 of BB has no arrow. Con­di­tion 1 fails, so gg is not a func­tion from BB to CC.

Exam­ple 3

Let C={1,2,3}C = \{1, 2, 3\} and D={a,b,c,d}D = \{a, b, c, d\}, and let hh have arrows 1→a1 \to a, 1→b1 \to b, 2→c2 \to c, 3→d3 \to d. Is hh a func­tion from CC to DD?

The ele­ment 11 has two arrows, one to aa and one to bb. Its part­ner is not unique, so con­di­tion 2 fails. hh is not a func­tion.

A quick way to remem­ber both tests: in an arrow dia­gram of a func­tion, every ele­ment on the left sends out exactly one arrow.

Image and pre-image

If f:A→Bf : A \to B is a func­tion and (a,b)∈f(a, b) \in f, that is, the arrow from aa lands on bb, then

  • bb is called the image of aa, and we write b=f(a)b = f(a);
  • aa is called a pre-image of bb.

In Exam­ple 1, the image of 33 is bb, so f(3)=bf(3) = b. The ele­ment aa of BB has two pre-images, 11 and 22. The ele­ment dd has no pre-image at all.

An ele­ment of the domain always has exactly one image. An ele­ment of the codomain may have one pre-image, sev­eral, or none.

Domain, codomain and range

If f:A→Bf : A \to B is a func­tion, then

  • AA is called the domain of ff;
  • BB is called the codomain of ff;
  • the set of all images of the ele­ments of AA is called the range of ff. It is writ­ten f(A)f(A).

The range is always a sub­set of the codomain: f(A)⊆Bf(A) \subseteq B.

Exam­ple 4

For the func­tion of Exam­ple 1, write the domain, codomain and range.

Domain=A={1,2,3,4}\text{Domain} = A = \{1, 2, 3, 4\}

Codomain=B={a,b,c,d}\text{Codomain} = B = \{a, b, c, d\}

The images are f(1)=af(1) = a, f(2)=af(2) = a, f(3)=bf(3) = b, f(4)=cf(4) = c. Col­lect­ing them, and writ­ing each only once,

Range=f(A)={a,b,c}\text{Range} = f(A) = \{a, b, c\}

The codomain is the set the arrows are allowed to land in; the range is the set they actu­ally land in.

Func­tions given by a for­mula

Most func­tions in this chap­ter are given by a rule writ­ten as a for­mula. The rule tells you how to find the image of any ele­ment of the domain.

Exam­ple 5

Let A={−2,−1,0,1,2}A = \{-2, -1, 0, 1, 2\} and let f:A→Zf : A \to \mathbb{Z} be given by f(x)=x2f(x) = x^2. Find the range of ff, the pre-images of 44 and the pre-images of 33.

Work out each image:

f(−2)=4,f(−1)=1,f(0)=0,f(1)=1,f(2)=4f(-2) = 4, \quad f(-1) = 1, \quad f(0) = 0, \quad f(1) = 1, \quad f(2) = 4

Each ele­ment of AA has exactly one image, so ff is a func­tion. The range is {0,1,4}\{0, 1, 4\}.

The pre-images of 44 are the ele­ments whose image is 44: these are −2-2 and 22.

No ele­ment of AA has image 33, so 33 has no pre-image. That is no prob­lem: 33 belongs to the codomain Z\mathbb{Z} but not to the range.

Exam­ple 6

Let f:R→Rf : \mathbb{R} \to \mathbb{R} be given by f(x)=3x−2f(x) = 3x - 2. Find the image of 44 and the pre-image of 1313.

The image of 44 is f(4)=3×4−2=10f(4) = 3 \times 4 - 2 = 10.

For the pre-image of 1313, solve f(x)=13f(x) = 13:

3x−2=133x=15x=5\begin{aligned} 3x - 2 &= 13 \\ 3x &= 15 \\ x &= 5 \end{aligned}

So the pre-image of 1313 is 55.

Exam­ple 7

Let A={1,4,9}A = \{1, 4, 9\} and B={−3,−2,−1,1,2,3}B = \{-3, -2, -1, 1, 2, 3\}. A rela­tion sends each xx in AA to every num­ber in BB whose square is xx. Is this a func­tion?

The num­ber 44 is sent to 22 and also to −2-2, since both square to 44. One ele­ment has two part­ners, so the rela­tion is not a func­tion.

Prac­tice

  1. Let A={1,2,3}A = \{1, 2, 3\} and B={x,y,z}B = \{x, y, z\}. Is {(1,x),(2,y),(3,z)}\{(1, x), (2, y), (3, z)\} a func­tion from AA to BB?
  2. With the same sets, is {(1,x),(2,x),(3,x)}\{(1, x), (2, x), (3, x)\} a func­tion from AA to BB?
  3. With the same sets, is {(1,x),(1,y),(2,z),(3,z)}\{(1, x), (1, y), (2, z), (3, z)\} a func­tion from AA to BB? Give a rea­son.
  4. With the same sets, is {(1,y),(3,z)}\{(1, y), (3, z)\} a func­tion from AA to BB? Give a rea­son.
  5. Let ff be defined on A={0,1,2,3}A = \{0, 1, 2, 3\} by f(x)=2x+1f(x) = 2x + 1. Find the range of ff.
  6. Let ff be defined on A={−2,−1,0,1,2}A = \{-2, -1, 0, 1, 2\} by f(x)=x2−1f(x) = x^2 - 1. Find the range of ff and the pre-images of 33.
  7. For f:R→Rf : \mathbb{R} \to \mathbb{R}, f(x)=3x−2f(x) = 3x - 2, find the image of −1-1 and the pre-image of −8-8.
  8. A func­tion ff has domain {1,2,3,4}\{1, 2, 3, 4\} and codomain {5,6,7,8}\{5, 6, 7, 8\}, with f(1)=5f(1) = 5, f(2)=5f(2) = 5, f(3)=6f(3) = 6, f(4)=8f(4) = 8. Write its range, and name the ele­ment of the codomain that has no pre-image.
  9. Let A={1,4,9}A = \{1, 4, 9\} and B={1,2,3}B = \{1, 2, 3\}. Each xx in AA is sent to the num­ber in BB whose square is xx. Is this a func­tion? If so, write it as a set of ordered pairs.

Answers

Show answers
  1. Yes. Every ele­ment of AA has exactly one image.
  2. Yes. Every ele­ment has exactly one image; all images hap­pen to be xx.
  3. No. The ele­ment 11 has two images, xx and yy.
  4. No. The ele­ment 22 has no image.
  5. f(0)=1f(0) = 1, f(1)=3f(1) = 3, f(2)=5f(2) = 5, f(3)=7f(3) = 7, so the range is {1,3,5,7}\{1, 3, 5, 7\}.
  6. The images are 3,0,−1,0,33, 0, -1, 0, 3, so the range is {−1,0,3}\{-1, 0, 3\}. The pre-images of 33 are −2-2 and 22.
  7. f(−1)=3×(−1)−2=−5f(-1) = 3 \times (-1) - 2 = -5. For the pre-image, 3x−2=−83x - 2 = -8 gives 3x=−63x = -6, so x=−2x = -2.
  8. Range ={5,6,8}= \{5, 6, 8\}. The ele­ment 77 has no pre-image.
  9. Yes. Now only pos­i­tive square roots are avail­able, so each ele­ment has exactly one part­ner: {(1,1),(4,2),(9,3)}\{(1, 1), (4, 2), (9, 3)\}.