SECTION 4.1 Introduction to Functions
Given a function f, and sets A and B:
If A and B are finite sets, an arrow diagram shows a function f from A to B by drawing an arrow from each element in A to the corresponding element of B.
Two properties must be held in the arrow diagram according to the definition of function:
1. Every element of A has an arrow coming out of it.
2. No one element of A has two arrows coming out of it that point to two different elements of B.
These two properties must be held because the definition of function says that each element of A is sent to a unique element of B.
An example of an arrow diagram is shown below:

Functions can be thought of machines. Suppose f is a function
from A to B and an input a of A is given.
f can be imagined as a machine that processes a
in a certain way to produce the output f(a). For instance,
if f : R
R
is a cubing function, given an input n, f will
produce an output f(n) = n3.
Consider the following examples:
1. The Logarithmic Function
Let z be a positive real number. For each positive real number x, the logarithm with base z of x, written logzx, is the exponent to which z must be raised to obtain x.
| logzx = y |
The logarithmic function with base z : R+
R,
means that it takes each positive real number x to logz
x.
Try to find log2(1/8) and click here for answer.
Let X be any set. The identity function on X is
ix : X
X
and it is defined by the rule
a
X,
ix(a) = a.
3. The Hamming Distance Function
The Hamming distance function was invented by the computer scientist Richard W. Hamming. It gives a measure of the "difference" between two strings of 0's and 1's that have the same length.
Let
=
{0, 1} and n
Z+;
then
is
the set of all strings of 0's and 1's of length n. Define
a function H :
x
Z+
as follows: for each pair of strings (s, t)
x
,
H(s, t) = the number of positions in which s and t have different values
Let n = 6, so that
6
is the set of strings comprised of any combination of six 0's and 1's.
Applying the distance function H to 2 strings in the set
as follows;
H(110001, 110010) = 2
because 110001 and 110010 differ only in the last two positions.