The mathematical concept of a function expresses dependence between two quantities, one of which is known and the other which is produced. A function associates a single output to each input element drawn from a fixed set, such as the real numbers (
There are many ways to give a function: by a formula, by a plot or graph, by an algorithm that computes it, or by a description of its properties. Sometimes, a function is described through its relationship to other functions (see, for example, inverse function). In applied disciplines, functions are frequently specified by their tables of values or by a formula. Not all types of description can be given for every possible function, and one must make a firm distinction between the function itself and multiple ways of presenting or visualizing it.
One idea of enormous importance in all of mathematics is composition of functions: if z is a function of y and y is a function of x, then z is a function of x. We may describe it informally by saying that the composite function is obtained by using the output of the first function as the input of the second one. This feature of functions distinguishes them from other mathematical constructs, such as numbers or figures, and provides the theory of functions with its most powerful structure.
Functions play a fundamental role in all areas of mathematics, as well as in other sciences and engineering. However, the intuition pertaining to functions, notation, and even the very meaning of the term "function" varies among the fields. More abstract areas of mathematics, such as set theory, consider very general types of functions that may not be specified by a concrete rule or be governed by familiar principles. In the most abstract sense, the distinguishing feature of a function is that it relates exactly one output to each of its admissible inputs. Such functions need not involve numbers. For example, a function might associate each member of a set of words with its own first letter.
Functions in algebra are usually expressed in terms of algebraic operations. Functions studied in analysis, such as the exponential function, may have additional properties arising from continuity of space, but in the most general case cannot be defined by a single formula. Analytic functions in complex analysis may be defined fairly concretely through their series expansions. On the other hand, in lambda calculus, function is a primitive concept, instead of being defined in terms of set theory. The terms transformation and mapping are often synonymous with function. In some contexts, however, they differ slightly. In the first case, the term transformation usually applies to functions whose inputs and outputs are elements of the same set or more general structure. Thus, we speak of linear transformations from a vector space into itself and of symmetry transformations of a geometric object or a pattern. In the second case, used to describe sets whose nature is arbitrary, the term mapping is the most general concept of function.
In traditional calculus, a function is defined as a relation between two terms called variables because their values vary. Call the terms, for example, x and y. If every value of x is associated with exactly one value of y, then y is said to be a function of x. It is customary to use x for what is called the "independent variable," and y for what is called the "dependent variable" because its value depends on the value of x.
Restated, mathematical functions are denoted frequently by letters, and the standard notation for the output of a function ƒ with the input x is ƒ(x). A function may be defined only for certain inputs, and the collection of all acceptable inputs of the function is called its domain. The set of all resulting outputs is called the image of the function. However, in many fields, it is also important to specify the codomain of a function, which contains the image, but need not be equal to it. The distinction between image and codomain lets us ask whether the two happen to be equal, which in particular cases may be a question of some mathematical interest. The term range often refers to the codomain or to the image, depending on the preference of the author.
For example, the expression ƒ(x) = x2 describes a function ƒ of a variable x, which, depending on the context, may be an integer, a real or complex number or even an element of a group. Let us specify that x is an integer; thenthis function relates each input, x, with a single output, x2, obtained from x by squaring. Thus, the input of 3 is related to the output of 9, the input of 1 to the output of 1, and the input of −2 to the output of 4, and we write ƒ(3) = 9, ƒ(1)=1, ƒ(−2)=4. Since every integer can be squared, the domain of this function consists of all integers, while its image is the set of perfect squares. If we choose integers as the codomain as well, we find that many numbers, such as 2, 3, and 6, are in the codomain but not the image.
It is a usual practice in mathematics to introduce functions with temporary names like ƒ; in the next paragraph we might define ƒ(x) = 2x+1, and then ƒ(3) = 7. When a name for the function is not needed, often the form y = x2 is used.
If we use a function often, we may give it a more permanent name as, for example,
The essential property of a function is that for each input there must be a unique output. Thus, for example, the formula
As mentioned above, a function need not involve numbers. By way of examples, consider the function that associates with each word its first letter or the function that associates with each triangle its area.
Because functions are used in so many areas of mathematics, and in so many different ways, no single definition of function has been universally adopted. Some definitions are elementary, while others use technical language that may obscure the intuitive notion. Formal definitions are set theoretical and, though there are variations, rely on the concept of relation. Intuitively, a function is a way to assign to each element of a given set (the domain or source) exactly one element of another given set (the codomain or target).
One simple intuitive definition, for functions on numbers, says:
An example of such a function is y = 5x−20x3+16x5, where the value of y depends on the value of x. This is entirely satisfactory for parts of elementary mathematics, but is too clumsy and restrictive for more advanced areas. For example, the cosine function used in trigonometry cannot be written in this way; the best we can do is an infinite series,
Eventually the gradual transformation of intuitive "calculus" into formal "analysis" brought the need for a broader definition. The emphasis shifted from how a function was presented — as a formula or rule — to a more abstract concept. Part of the new foundation was the use of sets, so that functions were no longer restricted to numbers. Thus we can say that
Note that X and Y need not be different sets; it is possible to have a function from a set to itself. Although it is possible to interpret the term "associates" in this definition with a concrete rule for the association, it is essential to move beyond that restriction. For example, we can sometimes prove that a function with certain properties exists, yet not be able to give any explicit rule for the association. In fact, in some cases it is impossible to give an explicit rule producing a specific y for each x, even though such a function exists. In the context of functions defined on arbitrary sets, it is not even clear how the phrase "explicit rule" should be interpreted.
As functions take on new roles and find new uses, the relationship of the function to the sets requires more precision. Perhaps every element in Y is associated with some x, perhaps not. In some parts of mathematics, including recursion theory and functional analysis, it is convenient to allow values of x with no association (in this case, the term partial function is often used). To be able to discuss such distinctions, many authors split a function into three parts, each a set:
F (the graph) is a set of ordered pairs (x,y),
X (the source) contains all the first elements of F and perhaps more, and
Y (the target) contains all the second elements of F and perhaps more.The most common restrictions are that F pairs each x with just one y, and that X is just the set of first elements of F and no more. The terminology total function is sometimes used to indicate that every element of X does appear as the first element of an ordered pair in F; see partial function. In most contexts in mathematics, "function" is used as a synonym for "total function".
When no restrictions are placed on F, we speak of a relation between X and Y rather than a function. The relation is "single-valued" when the first restriction holds: (x,y1)∈F and (x,y2)∈F together imply y1 = y2. Relations that are not single valued are sometimes called multivalued functions. A relation is "total" when a second restriction holds: if x∈X then (x,y)∈F for some y. Thus we can also say that
The image of F, and of ƒ, is the set of all second elements of F; it is often denoted by im ƒ. The domain of F is the set of all first elements of F; it is often denoted by dom ƒ. There are two common definitions for the domain of ƒ some authors define it as the domain of F, while others define it as the source of F.
The target Y of ƒ is also called the codomain of ƒ, denoted by cod ƒ. The range of ƒ may refer to either the image of ƒ or the codomain ƒ, depending on the author, and is often denoted rng ƒ. The notation ƒ:X→Y indicates that ƒ is a function with domain X and codomain Y.
Some authors omit the source and target as unnecessary data. Indeed, given only the graph F, one can construct a suitable triple by taking dom F to be the source and rng F to be the target; this automatically causes F to be total. However, most authors in advanced mathematics prefer the greater power of expression afforded by the triple, especially the distinction it allows between image and codomain.
Incidentally, the ordered pairs and triples we have used are not distinct from sets; we can easily represent them within set theory. For example, we can use