6.1 What is a function?

Mathematicians use functions to describe relationships between quantities. Examples of functions you may seen before are:

  • quadratic functions, e.g. f(x)=3x21f(x)=3x^{2}-1;

  • trigonometric functions: e.g. cos\cos, sin\sin and tan\tan;

  • exponential functions, e.g. f(x)=2xf(x)=2^{x} and exp\exp; and

  • logarithmic functions, e.g. log10\log_{10} and ln\ln.

We give a more formal definition of a function and then discuss how this aligns with the intuitive ideas you will have learned in your previous studies.

Definition 6.1 (Function, domain, codomain, graph).

A function is an object consisting of three sets:

  1. (i)

    a set DD called its domain;

  2. (ii)

    a set CC called its codomain; and

  3. (iii)

    a subset GG of D×CD\times C called its graph.

These three sets must have the properties:

  1. (a)

    for every xDx\in D, there exists yCy\in C such that (x,y)G(x,y)\in G; and

  2. (b)

    if (x,y)G(x,y)\in G and (x,z)G(x,z)\in G then y=zy=z.

Note, we typically give the function a name such as ff. Writing ‘f(x)=yf(x)=y’ means that (x,y)G(x,y)\in G. The two defining properties (a) and (b) of a function in Definition 6.1 state that each element of the domain is matched with exactly one element of the codomain. [Check that you see why.]

Example 6.2.

You may have seen statements like ‘f(x)=3x21f(x)=3x^{2}-1’ in your previous studies. Let’s discuss what this means in terms of the formal definition above.

The variable xx in ‘f(x)=3x21f(x)=3x^{2}-1’ can be any real number. So the domain could be D=D=\mathbb{R}.

The result of calculating f(x)f(x) for a real number xx will also be a real number. So in this example the codomain could be C=C=\mathbb{R}.

Here we define the graph as the set G={(x,3x21):x}G=\{(x,3x^{2}-1):x\in\mathbb{R}\} in Definition 6.1. Since elements of GG are pairs of real numbers, these can be plotted on a pair of coordinate axes to create a geometric object in the plane.

This geometrical representation of the graph is consistent with how you will have used the term in the past.

Note from the graph that f(x)1f(x)\geq-1 for all real xx, and so we could define the codomain of the function ff to be C=[1,)C=[-1,\infty) instead of the whole of \mathbb{R}.

Definition 6.3 (Function notation).

The notation ‘f:DCf:D\to C’ means ff is a function with domain DD and codomain CC. We say ‘ff maps DD to CC’. In this situation the graph is not yet specified.

The notation ‘f(x)f(x)’ means the element of the codomain corresponding to xx in the domain under ff. In other words, y=f(x)y=f(x) if and only if (x,y)G(x,y)\in G. We say ‘yy is the value of the function ff at xx’.

When xx is a variable, f(x)f(x) can be thought of as a formula that specifies how to calculate the element of the codomain corresponding to any xx in the domain.

The notation ‘f:xyf:x\mapsto y’ can be used to mean the same thing as f(x)=yf(x)=y. We say ‘ff sends (or maps) xx to yy’.

When referring to a function, you should use its name (e.g. ff) and not the value at a point, e.g. f(x)f(x). If you want to refer to the value of a function evaluated for a specific element of the domain aDa\in D then you should use f(a)f(a).

There are several ways of visualising what a function is; Figure 6.1 shows the two most common ones. In Figure 6.1(a), we visualise a function ff as a machine that takes an element aDa\in D as an input, processes it, and then outputs f(a)f(a). In Figure 6.1(b), we visualise a function ff as a mapping from its domain to its codomain.

(a) A function as a machine
(b) A function as a mapping
Figure 6.1: Two ways of picturing a function ff

You will sometimes see functions defined loosely using just a formula with no mention of a domain or codomain. For example, you may see phrases such as ‘let f(x)=x2f(x)=x^{2}’. This informality rarely causes problems, but you should remember that a function always has a domain and codomain.

When a domain is not stated explicitly, you can infer the implied domain from the context. For now, we define it to be the largest subset of \mathbb{R} for which the formula makes sense. The implied codomain is usually \mathbb{R}. However, to avoid ambiguity, it is good practice always to state the domain and codomain explicitly.

Exercise 6.4.

What is the implied domain of the function f(x)=1/xf(x)=1/x? Following Definition 6.1, write down a domain, codomain and graph of ff. Sketch the graph of ff.

Solution (please try for yourself before looking)

The expression 1/x1/x is undefined when x=0x=0 and so 0 cannot be in the domain of ff defined by f(x)=1/xf(x)=1/x. The (implied) domain of ff is {0}\mathbb{R}\setminus\{0\}.

The codomain could be \mathbb{R}. The codomain could also be {0}\mathbb{R}\setminus\{0\} since there is no xx\in\mathbb{R} such that f(x)=0f(x)=0.

With f:{0}f:\mathbb{R}\setminus\{0\}\to\mathbb{R} the graph is the set

{(x,1/x):x{0}}.\bigl{\{}(x,1/x):x\in\mathbb{R}\setminus\{0\}\bigr{\}}.
Exercise 6.5.

What is the implied domain of the function tan(x)=sin(x)/cos(x)\tan(x)=\sin(x)/\cos(x)?

Solution (please try for yourself before looking)

The fraction sin(x)/cos(x)\sin(x)/\cos(x) is undefined whenever cos(x)=0\cos(x)=0, i.e. when x{nππ2:n}x\in\bigl{\{}n\pi-\frac{\pi}{2}:n\in\mathbb{Z}\bigr{\}}. So the implied domain of tan\tan is {nππ2:n}\mathbb{R}\setminus\bigl{\{}n\pi-\tfrac{\pi}{2}:n\in\mathbb{Z}\bigr{\}}.

Two functions are said to be equal when their domains, codomains and graphs are equal as sets.

Example 6.6.

  1. (a)

    Functions f:f:\mathbb{R}\to\mathbb{R} with f(x)=x2f(x)=x^{2} and g:g:\mathbb{Z}\to\mathbb{R} with g(x)=x2g(x)=x^{2} are not equal, even though they are defined by the same formula, because their domains (and therefore also their graphs) are different.

  2. (b)

    If we consider the functions p(x)=x+1p(x)=x+1 and q(x)=(x+1)(x1)x1q(x)=\dfrac{(x+1)(x-1)}{x-1} with their implied domains, these functions are not equal because the implied domain of qq cannot contain the value 11, whereas the implied domain of pp is \mathbb{R} which does contain 1. However, the functions p:{1}p:\mathbb{R}\setminus\{1\}\to\mathbb{R} and q:{1}q:\mathbb{R}\setminus\{1\}\to\mathbb{R} with the above definitions are equal because their domains, codomains and graphs

    {(x,x+1):x{1}}\{(x,x+1):x\in\mathbb{R}\setminus\{1\}\}

    and

    {(x,(x+1)(x1)x1):x{1}}\left\{\left(x,\frac{(x+1)(x-1)}{x-1}\right):x\in\mathbb{R}\setminus\{1\}\right\}

    are equal.

When defining a function, it is our job to choose an appropriate domain for whatever purpose the function is serving. For example, if we wish to prove something about integers, then it may make more sense to define function gg rather than function ff in the example above.

The importance of the codomain may not yet be clear. For now, you can think of the codomain as specifying the sort of object that a function outputs. Paying attention to the codomain becomes more important when we start to think about composing functions in Section 6.4.

Exercise 6.7.

Let C=D=C=D=\mathbb{R} and consider the set

G:={(x,y):xC,yD,x2+y2=1}.G:=\{(x,y):x\in C,y\in D,x^{2}+y^{2}=1\}.
  1. 1.

    Sketch the set GG. [You may wish to start by listing some elements of GG.]

  2. 2.

    The definition of a function f:DCf:D\to C with graph GG in Definition 6.1 has two conditions on the sets, namely:

    1. (a)

      for every xDx\in D, there exists yCy\in C such that (x,y)G(x,y)\in G; and

    2. (b)

      if (x,y)G(x,y)\in G and (x,z)G(x,z)\in G then y=zy=z.

    Explain why CC, DD and GG in this example do fit the definition of a function.

Solution (please try for yourself before looking)
  1. 1.

    You may recognise the set GG as a unit circle centred at (0,0)×(0,0)\in\mathbb{R}\times\mathbb{R}.

  2. 2.

    Consider the conditions that must be satisfied by a function:

    1. (i)

      for every xDx\in D, there exists yCy\in C such that (x,y)G(x,y)\in G; and

    2. (ii)

      if (x,y)G(x,y)\in G and (x,z)G(x,z)\in G then y=zy=z.

    Condition (i) is not satisfied because for any x<1x<-1 or x>1x>1 there is no yy such that (x,y)G(x,y)\in G. This can be seen from the sketch of the graph.

    Condition (ii) is not satisfied because, for example, (0,1)(0,-1) and (0,1)(0,1) both belong to GG, but 11-1\neq 1.