Jump to content

Function

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Bryan Derksen (talk | contribs) at 09:02, 2 February 2003 (×). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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.

Mathematical functions

In its most informal sense, a function is an explicit rule or formula, such as f(x) = x2, that converts some value or values into another value by substitution into the formula. The input value or values are often called the arguments of the function; and the value resulting from the substitution is often called the value of the function when it is evaluated at those specific arguments.

There is always some restriction on what constitutes a "legal" or sensible argument for a function; for example, given the function f(x) = x2, we cannot evaluate f for x = "Mary Queen of Scots"; x obviously is intended to be some number. The domain of a function f is the set of all mathematical objects for which the function has a defined value. In the previous example, a natural assumption would be to define the domain of f to be the real numbers; but since it could just as easily be the integers, or other more exotic mathematical objects such as isomorphisms, mathematicians always explictly (or implictly) define the domain of a function before making any statements about it.

Similarly, it is often useful to describe what sort of mathematical object we obtain when f is evaluated at some element in its domain. For example, consider the set Eng to be the set of all words in the English language (as given in the 2002 edition of the Oxford English Dictionary), and define the function Len(e) to be the number of letters in the word e, where the domain of Len is Eng. Then we say that the codomain of Len is the set of natural numbers; in other words, Len(e) is always some natural number.

Note that in this example, there will certainly be some "longest" english word; there is no element e in the domain which will have Len(e) = 1000, and so not every element of the codomain will be used. The term range (or image) of the function Len refers to the set of all of the elements r in the codomain for which there is some element e in the domain with Len(e) = r. The range is always a subset of the codomain.

Definition

These terms allow us to define a function without reference to some explicit "formula" for evaluating the function at any value in its domain. If f is some function with a domain of X and a codomain of Y, consider the set of all pairs (x, f(x)), where x is any element of X. Each x appears as the first element of a pair once and only once; so in the abstract, given this set of pairs, we can discard the "explicit formula", and consider the function f as being fully described by a set of pairs {(x, y)}, where there is exactly one pair whose first member is x for each x in X, and where for each pair, y is a member of Y.

We can then give a precise definition from a set theoretic point of view:

Define a function f with domain X and codomain Y (written as f: XY) as a subset of the Cartesian product X × Y (in other words, f is a set of ordered pairs {(x, y)} with x in X, y in Y, often called a binary relation); with the additional properties that f is:

  1. Functional: if there are two pairs (x, y) and (x, z) in f, then y = z.
  2. Total: for all x in X, there exists an ordered pair (x, y) in f for some y in Y.

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. We can then write f(x) to be the (unique) value y in Y which corresponds to the pair (x, y) in f; in other words, the statements f(x) = y and (x, y) in f are equivalent.

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.

Occasionly, functions as defined here are called total functions to distinguish them from partial functions which don't require condition 2 from above. In this encyclopedia, the terms "total function" and "function" are synonymous.

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. We then consider the domain of V to be the set of ordered pairs of reals (r, h); and we write that V:(R × R) → R.

This definition of function provides mathematicians with a number of useful advantages over the "explicit formula" definition:

  • Clearly, if we already have an explicit formula for f(x), we can construct the set of pairs f; so nothing is lost by this definition. The graph of the function f is the collection of all pairs (x, f(x)) for all x in X.
  • In many cases, there is no explicit formula which amounts to more than a "table" of arguments and values; the above definition accommodates these types of functions naturally.
  • We can talk about sets of functions without specifying them exactly; for example, given the domain R of real numbers, and the codomain N of natural numbers, we can talk about the set of all functions of the form f: RN, or some subset of these functions which satisfy other criteria. Mathematicians are often interested in such generalizations.
  • In some cases, it may be unclear whether or not some binary relation f is "truly" a function; the definition provides a way of proving the existence of a well-defined function without actually specifying an explicit formula.

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.

Examples of functions

(More can be found at List of functions.)

  • The relation wght between persons in the United States and their weights.
  • The relation sqr between natural numbers n and their squares n2.
  • 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.
  • The relation dist between points in the plane R2 and their distances from the origin (0,0).
  • The relation grav between a point in the punctured plane R2 \ {(0,0)} 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).

These are nearly all numerical functions; it would be nice to mix in examples which are not in any way numerical, to stress the difference.

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).

Injective, surjective and bijective functions

Several types of functions are very useful, deserve special names:

  • injective (one-to-one) functions send different arguments to different values; in other words, if x and y are members of the domain of f, then f(x) = f(y) if and only if x = y.
  • surjective (onto) functions have their range equal to their codomain; in other words, if y is any member of the codomain of f, then there exists at least one x such that f(x) = y.
  • bijective functions are both injective and surjective; they are often used to show that the sets X and Y are "the same" in some sense.

Images and preimages

If fX → Y 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) : x in A}.

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) := {x in X : f(x)&nbsp in  B}.

Note that the codomain of f -1 is not A, but the set of all subsets of A (also known as the power set of A).

Some consequences that follow immediately from these definitions are:

  • f(A1 ∪ A2) = f(A1) ∪ f(A2).
  • f(A1 ∩ A2) ⊆ f(A1) ∩ f(A2).
  • f −1(B1 ∪ B2) = f −1(B1) ∪ f −1(B2).
  • f −1(B1 ∩ B2) = f −1(B1) ∩ f −1(B2).
  • f(f −1(B)) ⊆ B.
  • 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.

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 set of ordered pairs that form the function's graph 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.

Also recurrences as a way of defining functions.

Combining functions

The functions fX → Y and gY → Z 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: X → Z 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 fX → R and gX → R are functions with common domain X and codomain the set R of real numbers, then one can define the sum function f + g: X → R and the product function f × g: X → R 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.