"Function"
Defined for
Mathematics and Programmimg

Excerpted from "wikipedia.com"


In mathematics, a function (also called map or mapping) expresses the dependence of one quantity on another quantity or quantities.

In programming, a function is a part of a program that can be called with certain arguments (or parameters) from inside the program or elsewhere, and returns a value. See function (programming)

The rest of the article develops the original (mathematical) meaning of function.

Definition

Traditionally, functions were specified as explicit rules or formulas that converted some input value (or values) into an output value. If f is the name for the function and x is a name for an input value, then f(x) denotes the output value corresponding to x under the rule f. An input value is also called an argument of the function, and an output value is called a value of the function. The graph of the function f is the collection of all pairs (x,f(x)) for x an argument of f.

For example, the circumference C of a circle depends on its diameter d according to the formula C = pi * d; therefore, one could say that the circumference is a function of the diameter, and the functional relationship is given by C(d) = pi * d. Equally well, the diameter can be considered a function of the circumference, with the relationship given by d(C) = d/pi; the functions C(d) and d(C) are inverse functions of each other. (It should be noted that the notation in this paragraph, while of long pedigree, is now considered insufficiently precise by mathematicians.)

One may also consider functions that expect several input values; for instance the volume V of a [right circular cone]? can be computed from the radius r of its base and its height h according to the rule V(r,h) = 1/3 * pi * r2 * h.

In modern mathematics, the insistance on specifying an explicit effective rule has been abandoned; all that is required is that a function f associate with every element of some set X a unique element of some set Y. This makes it possible to prove the existence of a function without being able to calculate its values explicitly for any element of the domain. Also, it allows one to prove general properties of functions independently of their form. The set X of all admissable arguments is called the domain of f; the set Y of all admissible values is called the codomain of f. We write f: XY.

For a precise definition from a set theoretic point of view, a function f from X to Y is a subset f of the Cartesian product X × Y (called a binary relation in set theory) which satisfies the following two properties:

  1. functional: if (x,y1) and (x,y2) are both elements of f, then y1 = y2.
  2. total: if x is any element of X, then there exists at least one element y of Y such that (x,y) is in f.
  3. We write f(x) = y instead of (x,y) ∈ f. Notice that the two conditions above are precisely what is needed for the symbol f(x) to be defined uniquely for any x in X. If a function f is defined by specifying it as a binary relation (either directly or indirectly), then we say that f is well defined if f actually satisfies these conditions.

    Observe that in set theory there is no distinction between a function f and its graph. In practice (for example, in analysis) one has the paradoxical situation that the set-theoretic formalism is used, but the language still reflects the classical definition. One rarely talks about functions in terms of the graph. However, considering the properties of the graph as a set can be a very powerful technique, and there are theorems formulated or proved most easily in terms of the graph as a set, such as the [closed graph theorem]?.

    A partial function is a subset of the cartesian product which only satisfies the first of the two properties (functionality). In other words, a partial function need not assign a value to all elements of its domain. But a partial function becomes a function when the domain is restricted to the set of values on which it is defined.

    The subset of Y that consists of all elements in Y that are associated with at least one element in X is called the range or image of the function. (See also "Image" below.)

    Examples of functions

    (More can be found at List of functions.)

  4. The relation wght between persons in the United States and their weights.
  5. The relation sqr between natural numbers n and their squares n2.
  6. The relation nlog between positive real numbers x and their natural logarithms ln(x). Note that the relation between real numbers and their natural logarithms is not a function because not every real number has a natural logarithm; that is, this relation is not total and is therefore only a partial function.
  7. The relation dist between points in the plane R2 and their distances from the origin (0,0).
  8. The relation grav between a point in the plane R2 and the vector describing the gravitational force that a certain mass at that point would experience from a certain other mass at the origin (0,0).
  9. If the domain of a function is a subset of the Cartesian product of n sets then the function is called an n-ary function. For example, the relation dist has the domain R × R and is therefore a binary function. In that case dist((x,y)) is simply written as dist(x,y).

    Image and preimage

    If f: XY is a function and A is a subset of X, then the image (or direct image) of A is the subset of Y defined by

    f(A) := {f(x) : xA}.

    If B is a subset of Y, we define its preimage (or inverse image) to be the subset of X defined by

    f −1(B) := {xX : f(x) ∈ B}.

    Some consequences that follow immediately from these definitions are:

  10. f(A1A2) = f(A1) ∪ f(A2).
  11. f(A1A2) ⊆ f(A1) ∩ f(A2).
  12. f −1(B1B2) = f −1(B1) ∪ f −1(B2).
  13. f −1(B1B2) = f −1(B1) ∩ f −1(B2).
  14. f(f −1(B)) ⊆ B.
  15. f −1(f(A)) ⊇ A.

The results relating images and preimages to the algebra of intersection and union work for any number of sets, not just for 2.

Notice that the range of f is the image f(X) of its domain.

Injective, surjective and bijective functions

Several types of functions deserve special names: injective (one-to-one) functions send different arguments to different values, surjective (onto) functions have their range equal to their codomain, and bijective functions are both injective and surjective. .

Specifying functions

Functions can be specified in several ways. In practice, most functions that relate (combinations of) numbers with numbers are specified by one or more equation. For example, the dist function can be specified with

dist(x,y) := (x2 + y2)1/2

or

z := (x2 + y2)1/2,

where z is called the dependent variable and x and y are called the independent variables. This type of specification is sometimes called specification by intension.

Another way of specifying functions is by specifying the the binary relation (also called the extension of the function) by either enumerating it or specifying it in set theory. The wght function, for example, might be specified by

wght := {(Larry,160), (Jimmy,165), (Ruth,125), (Cindy,120), ...}

and nlog might be specified by

nlog := {(x,y) ∈ R × R : x = ey}.

This type of specification is sometimes also called specification by extension.

A third way of specifying functions that is often used in computer science is specification by computation, where it is indicated how the result of the function is computed from the arguments. An example of this are Lambda expressions in Lambda calculus where the function max(a,b) with a and b integers might be specified as

max := λ (a,b) ∈ Z × Z . if a < b then b else a.

Combining functions

The functions f: XY and g: YZ can be composed by first applying f to an argument x and then applying g to the result. Thus one obtains a function g o f: XZ defined by (g o f)(x) := g(f(x)) for all x in X. As an example, suppose that a plane's height at time t is given by the function h(t) and that the oxygen concentration at height x is given by the function c(x). Then (c o h)(t) describes the oxygen concentration around the plane at time t.

If f: XR and g: XR are functions with common domain X and codomain the set R of real numbers, then one can define the sum function f + g: XR and the product function f * g: XR as follows:

(f + g)(x) := f(x) + g(x);
(f * g)(x) := f(x) * g(x);

for all x in X. This turns the set of all such functions into a commutative ring. By taking some other algebraic structure A in the place of R, we can turn the set of all functions from X to A into an algebraic structure of the same type in an analogous way.