kota's memex

Functions are central to math. A function is an object that sets up an input-output relationship. A function takes an input and produces an output. If f is a function whose output value is b when the input value is a, we write: f(a) = b.

A function is also called a mapping, and if f(a) = b, we say that f maps a to b. For example, the absolute value function abs takes a number x as input and returns x if x is positive and -x if x is negative. Thus abs(2) = abs(-2) = 2. Addition is another example of a function, written add. The input to the addition function is an ordered pair of numbers and the output is a sum of those numbers.

domain

The set of all possible inputs to a function is called its domain. The outputs of a function come from a set called its range. The notation for saying that f is a function with domain D and range R is: f: D → R.

In the case of the function abs, if we are working with integers, the domain and range are both ℤ, so we write abs: ℤ → ℤ. In the case of the addition function for integers, the domain is the set of pairs of integers ℤ * ℤ and the range is ℤ, so we would write add: ℤ * ℤ → ℤ. Note that the function may not necessarily use all elements of the specified range. The function abs never takes on the value -1 even though -1 ∈ ℤ. A function that does use all elements of the range is said to be onto the range.

describe

We may describe a specific function in several ways. One way is with a procedure for computing an output from a specified input. Another way is with a table that lists all possible inputs and gives the output for each input. Consider the function f: {0,1,2,3,4} → {0,1,2,3,4}.

n | f(n)
--|-----
0 | 1
1 | 2
2 | 3
3 | 4
4 | 0

This function adds 1 to its input and then outputs the result modulo 5. A number modulo m is the remainer after the division by m. For example, the minute hand on a clock face counts modulo 60. When we do modulo arithmetic, we define ℤₘ = {0,1,2,...,m - 1}. With this notation, the aforementioned function f has the form f: ℤ₅ → ℤ₅.

Sometimes a two-dimensional table is used if the domain of the function is the Cartesian product of two sets. Here is another function, g: ℤ₄ * ℤ₄ → ℤ₄. The entry at the row labeled i and the column labeled j in the table is the value g(i,j).

g | 0 1 2 3
--|--------
0 | 0 1 2 3
1 | 1 2 3 0
2 | 2 3 0 1
3 | 3 0 1 2

The function g is the addition function modulo 4.