Summer 09 Revision COMP10020 Maths Part 1: Functions

What is a function?

Functions are things that take inputs and produce outputs. All functions have a certain well defined set of inputs that can be accepted by the function, and when the function is run multiple times with the same input then it will always deliver the same output.

An example of a function is 2x. It has a well defined set of inputs (the set of all numbers) and if you run it multiple times with the same number you’ll always get the same output. 2->4, 3->6, 9->18, etc.

Function notation

The inputs and outputs of a function are both sets, referred to as the ’source’ and the ‘target’ respectively. (Or the ‘domain’ and the ‘codomain’). A function can be shown as follows: ƒ:S -> T where ƒ is the function, S is the source, and T is the target. The output value of the function ƒ given the input value of x can also be written as ƒ(x). The behaviour of the function can be written alongside the function as follows: x|->2x (For the function ƒ(x)=2x)

Function Equivalence

For two functions ƒ1:S1->T1 and ƒ2:S2->T2 to be equal (ƒ1=ƒ2), they must satisfy three conditions. They must have the same source, S1 = S2. They must also have the same target, T1 = T2. Finally, they must both have the same behaviour, ie. ƒ1(x)=ƒ2(x) for all possible input values.

Identity Function

For any possible input set there is a function ƒ:S->S, ie. every element of S, if input into function ƒ, will return itself. This is called the identity function, and can be denoted by 1s or ids.

Injection, Surjection, and Bijection

A function ƒ:S->T can have certain properties. Injectivity, surjectivity, and bijectivity are properties that functions can have.

A function is surjective if for every element in the target, there is at least one element in the source that maps onto the target.
A function is injective if for every element in the target there is at most one element in the source that maps onto the target.
A function is bijective if it is both injective and surjective, ie. for every element in the target there is one and only one element in the source that maps onto the target.

The following diagrams show an injective, a surjective, and a bijective function, respectively.

Examples

Assume that the source and the target are the sets of all real numbers.

Injective: ‘For every element in the target there is at most one element in the source that maps onto the target.’

  • ƒ(x) = 2x+1 (There is no number that can be output from two different inputs)
  • ƒ(x) = ex

Surjective: ‘For every element in the target there is at least one element in the source that maps onto the target.’

  • ƒ(x) = 2x+1 (For any possible output, there is always an input that can produce it)
  • ƒ(x) = x

Bijective: ‘For every element in the target there is one and only one element in the source that maps onto the target.’

  • ƒ(x) = 2x+1 (As you have seen above, it is both surjective and injective.)
  • ƒ(x) = x

Composition

If we take two functions, ƒ:R->S1 and g:S2->T, we can say they are ‘composable’ when S1 = S2. This means there is a composite function h:R->T. We can denote this by h = g ∘ ƒ. In terms of behavious, h(x) = g(ƒ(x)).  h(x) has the source R, which is also the source of ƒ, and the target T, which is also the target of g.  It can also be written as gƒ.

g∘ƒ:R->T. Note that it is now impossible to determine what set S was from the composite h.

A function composed with the identity function is equal to itself, that is to say that ƒ∘1S = ƒ.

Double Composites

Composite functions can be found for multiple functions as well. Consider the following functions: ƒ:S->L, g:L->R, h:R->T. It’s possible to find a single function that has a source of S and the target of T. This will be given by hg∘ƒ.

Composite functions are associative, ie. ((hg)∘ƒ) = (h∘(g∘ƒ)). For this reason, it is usually written without the brackets as hg∘ƒ.  Or even more commonly, just as hgƒ.

And if you want more notes, check out the notes of Badgerati.