1. from one set X to another set Y. A relation R defined on the Cartesian product x × y in which for each element x in X there is precisely one element y in Y with the property that (x,y) is a member of R. It is then customary to talk about a function f, say, and to write
The unique association between elements
x and
y is denoted by
X is called the
domain of
f, Y the
codomain of
f. Further,
y is the
value of
f at the point
x or the
image of
x under
f. We say that
f is a
mapping or
transformation between sets
X and
Y or that
f maps
X into
Y, and that
f maps
x into
y. When the domain
X is the Cartesian product of
n sets then
f is a function of
n variables. Otherwise it is a function of one variable.
Examples of functions are readily obtained from the mathematical equivalents of standard functions and operations typically supplied in programming languages. The usual trigonometric functions sin, cos, and tan are functions of one variable. The rule for converting from characters into their integer codes or equivalents is a function.
Functions are often represented pictorially as graphs.
See also bijection, homomorphism, injection, operation, surjection.
2. A program unit that given values for input parameters computes a value. Examples include the standard functions such as sin(x), cos(x), exp(x); in addition most languages permit user-defined functions. A function is a ‘black box’ that can be used without any knowledge or understanding of the detail of its internal working. In some languages a function may have side effects.