A function (or more strictly, a well-defined function) is a rule that assigns to every element in a set exactly one element, called the image, from another set . The set is called the domain, while the set is called the codomain. The subset of the codomain which precisely contains the set of all values that are assigned to some value in the domain is called the range
When defining a function with domain and codomain , it is common to denote it by .
For example, the function could be defined by the formula
Formally, a relation from a set to set is said to be a function if it satisfies the following properties:
The first condition asserts that every element in the domain has an image in the codomain, while the second states that such an image is unique. This definition, however, allows the following possibilities for a function:
- Two or more distinct elements in the domain may have the same image;
- One or more element in the codomain may not be the image of any element in the domain.
With those possibilities in mind, we may define a function to be one of these three types of functions:
- Injection, injective function, or one-to-one: for any , if then ;
- Surjection, surjective function, or onto: for any , there exists an such that ;
- one-to-one correspondence, bijection, bijective function, or invertible, if is both injective and surjective.
As a function from a set to a set is formally a relation, which itself is a subset of the cartesian product , the notations (viewing as a relation), and are valid. However, whenever given an arbitrary , it is cumbersome in writing to state that "there exists a unique such that ". Therefore, we will define the preferred notation to refer to the aforementioned unique . Therefore, the following notations are equivalent:
- , when viewing as a subset of the Cartesian product ;
- , when viewing as a relation from to ;
In practice, a function is completely determined through a formula that assigns the variables. For example:
is the depending variable and is the independent one.