~~Functions were originally the idealization of how a varying quantity depends on another quantity. For example, the position of a ~~planet is a *function* of time. Historically, the concept was elaborated with the infinitesimal calculus at the end of the 17th century, and, until the 19th century, the functions that were considered were differentiable (that is, they had a high degree of regularity). The concept of a function was formalized at the end of the 19th century in terms of set theory, and this greatly enlarged the domains of application of the concept.
A function is a process or a relation that associates each element x of a set X, the *domain* of the function, to a single element y of another set Y (possibly the same set), the *codomain* of the function. It is customarily denoted by letters such as $f$, $g$ and $h$.^{[1]}

If the function is called f, this relation is denoted by *y* = *f* (*x*) (which reads "f of x"), where the element x is the *argument* or *input* of the function, and y is the *value of the function*, the *output*, or the *image* of x by f.^{[2]} The symbol that is used for representing the input is the variable of the function (e.g., f is a function of the variable x).^{[3]}

A function is uniquely represented by the set of all pairs (*x*, *f* (*x*)), called the graph of the function.^{[note 2]}^{[4]} When the domain and the codomain are sets of real numbers, each such pair may be thought of as the Cartesian coordinates of a point in the plane. The set of these points is called the graph of the function; it is a popular means of illustrating the function.

Functions are widely used in science, and in most fields of mathematics. It has been said that functions are "the central objects of investigation" in most fields of mathematics.

Intuitively, a function is a process that associates each element of a set *X*, to a single element of a set *Y*.

Formally, a function *f* from a set *X* to a set *Y* is defined by a set G of ordered pairs (*x*, *y*) such that *x* ∈ *X*, *y* ∈ *Y*, and every element of *X* is the first component of exactly one ordered pair in G.^{[6]}^{[note 3]} In other words, for every *x* in *X*, there is exactly one element *y* such that the ordered pair (*x*, *y*) belongs to the set of pairs defining the function *f*. The set G is called the graph of the function. Formally speaking, it may be identified with the function, but this hides the usual interpretation of a function as a process. Therefore, in common usage, the function is generally distinguished from its graph.

Functions are also called *maps* or *mappings*, though some authors make some distinction between "maps" and "functions" (see section #Map).

In the definition of function, *X* and *Y* are respectively called the *domain* and the *codomain* of the function f.^{[7]} If (*x*, *y*) belongs to the set defining f, then y is the *image* of x under f, or the *value* of f applied to the *argument* x. In the context of numbers in particular, one also says that y is the value of f for the *value x of its variable*, or, more concisely, that y is the *value of* f *of* x, denoted as *y* = *f*(*x*).

Two functions f and g are equal, if their domain and codomain sets are the same and their output values agree on the whole domain. More formally, *f* = *g* if *f*(*x*) = *g*(*x*) for all *x* ∈ *X*, where *f*:*X* → *Y* and *g*:*X* → *Y*.^{[note 4]}

The domain and codomain are not always explicitly given when a function is defined, and, without some (possibly difficult) computation, one might only know that the domain is contained in a larger set. Typically, this occurs in mathematical analysis, where "a function from X to Y " often refers to a function that may have a proper subset^{[note 5]} of X as domain. For example, a "function from the reals to the reals" may refer to a real-valued function of a real variable, and this phrase does not mean that the domain of the function is the whole set of the real numbers, but only that the domain is a set of real numbers that contains a non-empty open interval; such a function is then called a partial function. For example, if f is a function that has the real numbers as domain and codomain, then a function mapping the value x to the value $g(x)={\tfrac {1}{f(x)}}$ is a function g from the reals to the reals, whose domain is the set of the reals x, such that *f*(*x*) ≠ 0.

The range of a function is the set of the images of all elements in the domain. However, *range* is sometimes used as a synonym of codomain, generally in old textbooks.^{[citation needed]}

### Relational approach

Any subset of the Cartesian product of two sets $X$ and $Y$ defines a binary relation $R\subseteq X\times Y$ between these two sets. It is immediate that an arbitrary relation may contain pairs that violate the necessary conditions for a function given above.

A binary relation is functional (also called right-unique) if

- $\forall x\in X,\forall y\in Y,\forall z\in Y,((x,y)\in R\land (x,z)\in R)\implies y=z.$

A binary relation is serial (also called left-total) if

- $g(x)={\tfrac {1}{f(x)}}$