In mathematics, an **identity function**, also called an **identity relation**, **identity map** or **identity transformation**, is a function that always returns the same value that was used as its argument. That is, for f being identity, the equality *f*(*X*) = *X* holds for all X.

Formally, if *M* is a set, the identity function *f* on *M* is defined to be that function with domain and codomain *M* which satisfies

*f*(*X*) =*X*for all elements*X*in*M*.^{[1]}

In other words, the function value *f*(*X*) in *M* (that is, the codomain) is always the same input element *X* of *M* (now considered as the domain). The identity function on M is clearly an injective function as well as a surjective function, so it is bijective.^{[2]}

The identity function *f* on *M* is often denoted by id_{M}.

In set theory, where a function is defined as a particular kind of binary relation, the identity function is given by the identity relation, or *diagonal* of *M*.^{[3]}

If *f* : *M* → *N* is any function, then we have *f* ∘ id_{M} = *f* = id_{N} ∘ *f* (where "∘" denotes function composition). In particular, id_{M} is the identity element of the monoid of all functions from *M* to *M* (under function composition).

Since the identity element of a monoid is unique,^{[4]} one can alternately define the identity function on *M* to be this identity element. Such a definition generalizes to the concept of an identity morphism in category theory, where the endomorphisms of *M* need not be functions.

- The identity function is a linear operator when applied to vector spaces.
^{[5]} - In an n-dimensional vector space the identity function is represented by the identity matrix
*I*_{n}, regardless of the basis chosen for the space.^{[6]} - The identity function on the positive integers is a completely multiplicative function (essentially multiplication by 1), considered in number theory.
^{[7]} - In a metric space the identity function is trivially an isometry. An object without any symmetry has as its symmetry group the trivial group containing only this isometry (symmetry type C
_{1}).^{[8]} - In a topological space, the identity function is always continuous.
^{[9]} - The identity function is idempotent.
^{[10]}