The mathematical notion of function is not limited to computations using single numbers, or even numbers at all - a function may be any of a wide variety of mappings, maps or transformations. Because of this generality, functions appear in a wide variety of mathematical contexts, and several mathematical fields are based on the study of functions.

It should be noted that the words "function", "mapping" and "map" are usually used synonymously. Furthermore, functions may occasionally referred to as well-defined function or total function (See the section "Formal Definition" below).

As a mathematical term, "function" was coined by Leibniz, in 1694, to describe a quantityrelated to a curve; such as a curve's slope or a specific point of said curve. Functions related to curves are nowaday called differentiable functions and are still the most frequently type of functions encounted by non-mathematicians. For such kind of functions, one can talk about limits and derivatives, both are measurements of the change of output values with respect to the change of input values. They are the basics of calculus.

The word was later used by Euler during the mid-18th Century to describe an expression involving various arguments; ie: y = F(x). By boarden the definition of functions, mathematicians were then able to study much weird mathematical objects, for example: functions which are nowhere differentiable. Those functions, first thought as pure imaginary, are later found to be important in physical phenomenons like Brownian motion.

During the 19th Century, mathematicians starts to unify all the different mathematics branches under set theory and they tried to define every mathematical object as a set. It was Dirichlet who gave the modern "formal" definition of function.

Under Dirichlet's definition, a function is a mathematical relation which is also a set. In most cases, however, the differences between the modern definition and Euler's definition is negligible.

Occasionally, all three relations above are called functions. In this case, the function satisfies Conditions (1) and (2) is said to be a "well-defined function" or "total function". In this encyclopedia, the terms "well-defined function", "total function" and "function" are synonymous.

X, the set of input values, is called the domain of f and Y, the set of possible output values, is called the codomain. The range of f is the set of all actual outputs {f(x) : x in the domain}. Beware that sometimes the codomain is wrongly called the range because of a failure to distinguish between possible and actual values.

In computer science, specifying the datatypes of the arguments and return values sets the domain and codomain (respectively) of a subprogram. So the domain and codomain are constraints imposed initially on a function; on the other hand the range is to do with how things turn out in practice.

The graph of a functionf is the collection of all points(x, f(x)), for all x in set X. In the example of the discrete function, the graph of f is {(1,a),(2,d),(3,c)}. There are theorems formulated or proved most easily in terms of the graph, such as the closed graph theorem[?].

If X and Y are real lines, then this definition coincides with the familiar sense of graph. Below is the graph of a cubic function, which is a curve:

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. Our example is an injective function.

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.

The relation nlog between positivereal numbersx 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).

Functions in applications are often functions of several variables: the values they take depend on a number of different factors. From a mathematical point of view all the variables must be made explicit in order to have a functional relationship - no 'hidden' factors are allowed. Then, again from the mathematical point of view, there is no qualitative difference between functions of one and of several variables. A function of three real variables is just a function that applies to triples of real numbers. The following paragraph says this in more formal language.

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

Another name applied to some types of functions of several variables is operation. In abstract algebra, operators such as "*" are defined as binary functions; when we write a formula such as x*y in this context, we are implicitly invoking the function *(x,y), but writing it in a convenient infix notation.

An important theoretical paradigm, functional programming, takes the function concept as central. In that setting, the handling of functions of several variables becomes an operational matter, for which the lambda calculus provides the basic syntax. The composition of functions (see under composing functions immediately below) becomes a question of explicit forms of substitution, as used in the substitution rule of calculus. In particular, a formalism called currying can be used to reduce n-ary functions to functions of a single variable.

The functions f: X → Y and g: Y → Z can be composed by first applying f to an argument x and then applying g to the result.
Thus one obtains a function gof: X → Z defined by (gof)(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 (coh)(t) describes the oxygen concentration around the plane at time t.

If a function f:X→Y is bijective then preimages of any element y in the codomain Y is a singleton. A function taking y∈Y to its preimage f−1(y) is a well-defined function called the inverse of f and is denoted by f−1.

An example of an inverse function, for f(x) = x2, is f(x)−1 = √x. Likewise, the inverse of 2x is x/2. The inverse function is the function that "undoes" its original.

If f: X → R and g: X → R are functions with common domain X and codomain is a ringR, 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 ring. The binary operations in that ring have as domain ordered pairs of functions, and as codomain functions. This is an example of climbing up in abstraction, to functions of more complex types.

By taking some other algebraic structureA 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.