Functions

In High School we met some functions, such as

linear functions like y=f(x)=2x+1

quadratic functions like f(x)=3x2+4x+1

trigonometric functions like f(x)=sin(x)

and others.

Here we generalise and abstract this idea.

The key features of these functions is that they take a value (x) which is an element of a set ( which happens to be ℝ), and the function gives us another value ( y, f(x) ) which is also a member of a set (again, ℝ ).

We keep this idea of pairing up an element of a set with another element. We drop the restriction that the two sets have to be the same, or that they must be ℝ.

So we think informally of a function as a set of ordered pairs (x,y) where x and y are elements of sets, which may be the same or different.

Definition of function

A function concerns two sets, and it pairs up each element of one set with one element of another set. The ‘from’ set is called the domain, and the ‘to’ set is the co-domain

The definition is:

A function from a domain D to a co-domain C is a set of ordered pairs (x,y) with x∊C and y∊D, such that

there is a pair (x,y) for every xϵD, and

if ordered pairs (x,a) and (x,b) exist, then a=b

The conditions just mean the function is defined for every domain element, and we cannot have one x going to two different y’s.

We might write for example f:ℝ→ℤ f(x)=floor(x)

which means f is a function from domain ℝ to co-domain ℤ, such that an element x of ℝ maps to floor(x) in ℤ. ( floor(x) is the largest integer not greater than x. So floor(3.9) = 3 and floor(-2.1)=-3 )

In this example, floor(x) is the formula of the function.

A function may have a piece-wise definition. For example

f(x)=0 if x<0

f(x)=x if x ≥0

Functions need not be of numbers. For example if we have a vector (say (x,y,z) ) then the magnitude of it corresponds to its length, which is √(x2+y2+z2). Then this is a function whose domain is the set of vectors, and the co-domain is ℝ.

Example function

Suppose the domain is the set {A,B,C,D}, and the co-domain is {Q, E, C, R, D, Z}

Then the set of ordered pairs:

{ (A,E), (B,C), (C,R) (D,D) }

is a function.

We can visualize it as shown.

What are A, B, C and so on? Just labels for the elements of the sets. What are those elements? It makes no difference to the function. The function just connects some elements in pairs.

Example relation not a function

The set

{ (A,E), (B,C), (B,D) }

is not a function, since

it is not defined for every domain element

B maps to two co-domain elements

But this is a function:

Applying a function

This means to ‘use’ the function, in the sense of selecting a domain element and obtaining the corresponding co-domain element. So if we have for example f:ℝ→ℝ f(x)=2x+1, then if we apply f to 3 we have

f(3) = 7

Cartesian products and graphs

Recall that the Cartesian product of two sets, D X C, is the set of all ordered pairs (x,y) such that xϵD and yϵC.

But a function from a domain D to a co-domain C is a set of ordered pairs (x,y) with x∊D and y∊C, such that there is a pair (x,y) for every xϵD, and if ordered pairs (x,a) and (x,b) exist, then a=b

So a function is a subset of the Cartesian product.

This is a more sophisticated way of looking at a graph of a function. The x axis is the domain, the real number line ℝ, and the y axis is the co-domain.

The Cartesian product D X C is the set of every possible co-ordinate point (x,y).

The graph of the function is the subset (x, f(x) ) of this.

If the function is ℝ→ℝ, these points are infinitely many. If it is ℕ→ℕ, for example, we have a small number of points which are not continuous.

Bear in mind the domain and co-domain may not be numbers, in which case we cannot draw a conventional Cartesian graph of it. Even if the sets are numbers, there may not be a formula for the function.

Even if the function is ℝ→ℝ, it may not be possible to draw its graph. As an example, consider the function f defined as

f(x) = 0 if x is rational

f(x) = 1 if x is irrational.

Could you draw its graph?

Vertical line test

Each domain element maps to only one co-domain element. This means that on a graph, a vertical line can only cross the function line once.

If it crosses it more than once, it is not a function.

The diagram shows f(x)=√x, and it fails the vertical line test. For example √1 is +1 and -1.

Image

Definition of image

The image of a function f:D→C is the set {y} where there exists at least one x∊D such that y=f(x)

In other words the image of a function is the subset of the co-domain mapped to by the domain.

The image might be equal to the co-domain, or be a proper subset of it.

There is another term, range. Older texts use range to mean co-domain. Modern texts take range to mean image. Because it is confusing, we do not use it at all.

Injective functions

A function f:D→C is injective if there exist elements of f (a,y) and (b,y), then a=b

In other words we cannot have 2 different elements of D mapping to the same element of C

Examples injective functions

The function f:ℝ→ℝ f(x)=x2 is not injective, since 22=4 and (-2)2=4

The function f:ℝ→ℝ f(x)=2x+3 is injective. If f(x)=y, then x=(y-3)/2 : just one value

Horizontal line test

Looking at the graph of a function, it is injective if any horizontal line crosses the graph at most once.

So for an injective function, it might cross it 0 times (if not in image), or once – but not twice or more

The graph here shows that y=x2 is not injective.

One-to-one

Injective functions are sometimes called one-to-one functions.

The name is misleading. It suggests that if you pick a domain element, it goes to just one co-domain element (not two, or zero). But in fact that is true of all functions. No function can be one-to-two.

In fact a one-to-one function really means not two to one.

Surjective

A function is surjective if the image is equal to the range.

For example the function f:ℝ→ℝ f(x)=x2 is not surjective, since the image is y≥0, and no x maps to a negative f(x).

But f:ℝ→ℝ≥0 f(x)=x2 is surjective ( ℝ≥0 being the set of non-negative reals), because then the image is equal to the co-domain.

f:ℝ→ℝ f(x)=2x+1 is surjective

f:ℝ→ℝ f(x)=ex is not surjective ( the image is only ℝ≥0 )

Onto

A surjective function is sometimes called onto.

Bijective

A bijective function is injective and surjective.

In other words it is one-to-one and onto.

Identity function

On a set S, the function f:S→S f(x)=x

is the identity function, which maps each domain element to itself

Composition of functions

Suppose we have two functions, and the co-domain of one is the domain of the other. Then we can create a new function, by applying the first, then applying the second to the intermediate result.

So we have a function f, and when we apply it we get f(x). Then we apply another function g to this, to get g( f(x) ). This is called the composition of f and g, and is another function.

For example, suppose f is x+1, and g = x2.

Then the composition of g and f is g( f(x) ) = g(x+1) = (x+1)2 = x2+2x+1

Commutativity of composition

In other words is f( g(x) ) the same as g( f(x) ) ?

We try it out using the last example

g( f(x) ) = g(x+1) = (x+1)2 = x2+2x+1

f( g(x) ) = f( x2 ) = x2+1

So these do not commute.

Some functions do. For example f=x+1 and g=x+2:

g( f(x) ) = g( x+1 ) = x+1 +2 = x+3

f( g(x) ) = f(x+2) = x+2 +1 = x+3

Associativity of composition

Suppose we have 3 functions h g and f. We will write the composition of g and h as g⚬h, meaning we apply h, then g.

Then is

f ⚬(g ⚬h) the same as

(f⚬g) ⚬h ?

In

f ⚬(g ⚬h)

we have combined g and h, applied it, then applied f

In

(f⚬g) ⚬h

we have combined f and g. Then we apply h, then the combined f and g.

Do we get the same result?

In other words is the composition of functions associative?

We have this situation:

We have four sets, A B C and D (which may not be distinct. For example g might be B→B. No matter)

g⚬h is the composition of h and g – in other words g(h(x)) where xϵA. Picking one element of A, named a, g⚬h maps a to c, where h(a) = b and g(b)=c

Similarly f⚬g is the function that maps a b to d, where c=g(b) and d=f(c)

f ⚬(g ⚬h) means we first apply g⚬h, and get from a to c, then apply f, taking us to d

(f⚬g) ⚬h means we first apply h, going from a to b, then apply f⚬g, taking b to d.

In both cases we go from a to d, so composition is associative.

Example of associativity

Suppose f = x+1

g = x2

h = x+2

then g⚬h = (x+2)2 = x2+4x + 4

f⚬(g⚬h) = f( x2+4x + 4 +1) = x2+4x + 5

f⚬g = f(x2) = x2+1

so (f⚬g)⚬h = (x+2)2 + 1 = x2+4x + 5

Powers

If the domain and co-domain are the same, we can apply a function more than once. For example if f:ℝ→ℝ f(x)=2x, then

f(f(x))= f(2x)=4x

This is the composition of a function with itself, so f(f(x)) = f⚬f

We could do this again to get f⚬f⚬f.

Because composition is associative, f⚬(f⚬f) = (f⚬f)⚬f

and we can just write this as f3, with no ambiguity as to how this is applied.

Clearly the ‘law of powers’ applies, so fm⚬fn = fm+n

As for numbers, it makes sense to say f1 = f, so that for example f⚬f2 = f1⚬f2 = f3

and f0 = the identity function, so that f0⚬fn = fn

For example if f(x)=x+3, then fn(x)=x+3n

Inverse function

Some functions have a ‘reverse’ version. A function maps a domain element to a co-domain, and the inverse maps the co-domain back to the original.

For example if f(x)=x+3, the inverse is g(x)=x-3

Then g(f(x)=g(x+3) = x+3-3 = x

So the inverse composed with a function is the identity function.

For this reason, the inverse of f is written f-1, and

f-1(f(x)) = x

But if a function is not injective (so it is two-to-one) there is no inverse. Two domain elements go to one co-domain. When we reverse this, one co-domain goes to two domain – so it is not a function.

An example is the absolute value. So if

f:ℝ→ℝ f(x) = |x|

then 2→2 and -2→2. So the reverse, 2→2 and -2 – so this is not a function, and there is no inverse.

Also if a function is not surjective (not onto) there will be co-domain elements which do not ‘go back’ to anything.

For example

f:ℝ→ℝ f(x) = x2

Here the image is R≥0. There is no inverse f-1, because f-1(-2) does not exist in ℝ

So only bijective functions have an inverse.

The set of all functions

If we think about functions of a real variable, this seems absurd – we have trig, hyperbolic functions, their inverses, log and exp, all polynomials, all combinations – what use would be the set of all functions?

But if we think about this in the context of small sets, it is not so meaningless.

Suppose we have domain

D = { a, b }

and image

R = { c, d, e }

Then each function D to R is a subset of D X R. For example


e

d
true
ctrue

ab

This is the function { (a,c), (b,d) }

The set of all functions would be all patterns like this, with the constraint that there must be one, and no more than one, selection in each column (since a function cannot be one-many).

The set of all functions D to R is written RD.

Leave a comment