Tutorials › Real Analysis › Identity Functions

Sets and Functions · Tutorial 67 of 1000

Identity Functions

An identity function sends every element of a set back to itself and leaves a function unchanged when composed in the appropriate position.

Beginner 10 min read

What You'll Learn

  • How to define the identity function on a set
  • Why the identity function depends on its underlying set
  • How identity functions behave under composition
  • How to prove that an identity function is bijective
  • How to use domain and codomain to check identity-function notation

A Function That Leaves Every Element Unchanged

Composition lets us apply one function after another. Some functions have a particularly simple effect: they return every input unchanged. These mappings are called identity functions. Their importance is not that they provide complicated examples, but that they make the basic composition laws precise. In particular, composing a function with the appropriate identity function on either side leaves its values unchanged.

The notation must retain the set on which the identity acts. If \(A\) is a set, its identity function maps \(A\) to \(A\). An identity function on one set is not automatically an identity function on another set: the domain and codomain are part of the function’s specification.

Definition (Identity Function). Let \(A\) be a set. The identity function on \(A\), denoted \(\operatorname{id}_A\), is the function from \(A\) to \(A\) defined by $$ \operatorname{id}_A:A\to A,\qquad \operatorname{id}_A(a)=a \quad\text{for every }a\in A. $$ Its graph is the set \(\{(a,a):a\in A\}\).

For each input \(a\), the output is the same object \(a\). The output belongs to the codomain \(A\) because the input already belongs to \(A\). This rule defines a function even when \(A\) is empty: there are then no inputs requiring assigned outputs, and the function condition holds.

The subscript records the set. The notation \(\operatorname{id}_A\) specifies both the domain and codomain as \(A\). Although two identity functions may have similar-looking rules, their stated sets determine which compositions are defined and what types those compositions have.

Recognizing an Identity Function

An identity function should be distinguished from a rule that merely resembles it. For example, the formula \(x\mapsto x\) defines an identity function from \(\mathbb R\) to \(\mathbb R\). The same formula can also specify a function from \([0,1]\) to \(\mathbb R\), but that function is not the identity function on \(\mathbb R\): its domain is only \([0,1]\), and its codomain is \(\mathbb R\). It is the identity rule restricted to the smaller domain, with a different function type.

Likewise, if \(A\subseteq B\), the inclusion map \(i:A\to B\) given by \(i(a)=a\) leaves each input unchanged as an object, but it is not \(\operatorname{id}_A\) unless its codomain is also \(A\). The distinction matters when composing mappings. The identity function that leaves a function \(f:A\to B\) unchanged on its output side is \(\operatorname{id}_B\), while the one that leaves its input unchanged on the input side is \(\operatorname{id}_A\).

Worked Example: Identity on a Finite Set

Let \(A=\{p,q,r\}\). The identity function on \(A\) has the assignments $$ \operatorname{id}_A(p)=p,\qquad \operatorname{id}_A(q)=q,\qquad \operatorname{id}_A(r)=r. $$ Thus its graph is $$ \operatorname{id}_A=\{(p,p),(q,q),(r,r)\}. $$ Every element of the domain appears once as a first coordinate and is paired with itself as the second coordinate. Its domain and codomain are both \(A\), and its range is \(\{p,q,r\}=A\).

The assignment \(\{(p,p),(q,q)\}\) would not be the identity function on \(A\), because it does not assign any value to the domain element \(r\). A function from \(A\) must assign exactly one value to every element of \(A\).

Worked Example: Identity on an Interval

Let \(I=[-2,3]\). Define \(j:I\to I\) by \(j(x)=x\). For instance, $$ j(-2)=-2,\qquad j\!\left(\frac12\right)=\frac12,\qquad j(3)=3. $$ The rule applies to every \(x\in I\), and each output remains in \(I\), so \(j=\operatorname{id}_I\). Its range is all of \(I\), since each \(x\in I\) is the output \(j(x)\).

If instead the same rule were specified as \(k:I\to\mathbb R\), then \(k\) would have the same values at all its inputs but a different codomain. It would not be the identity function on \(\mathbb R\), whose domain must be all of \(\mathbb R\), nor would it be \(\operatorname{id}_I\) with the stated codomain. The type of a function is part of its specification, not an optional label.

Identity Functions Are Bijective

The identity function on \(A\) is both injective and surjective. For injectivity, equal outputs are equal inputs because each output is just the input itself. For surjectivity, every element of \(A\) is attained by using that element as the input. These statements include the case \(A=\varnothing\): the injectivity condition has no pair of domain elements to check, and the surjectivity condition has no codomain elements requiring preimages.

Theorem (Identity Functions Are Bijective). For every set \(A\), the identity function \(\operatorname{id}_A:A\to A\) is bijective.

Proof. We first prove injectivity using the equal-output criterion for injective functions. Let \(x,y\in A\), and suppose \(\operatorname{id}_A(x)=\operatorname{id}_A(y)\). By the definition of the identity function, \(x=y\). Therefore \(\operatorname{id}_A\) is injective.

Next, let \(a\in A\) be arbitrary. The element \(a\in A\) itself is a preimage of \(a\), because \(\operatorname{id}_A(a)=a\). Thus every element of the codomain \(A\) belongs to the range of \(\operatorname{id}_A\), so the function is surjective. A function that is both injective and surjective is bijective. If \(A\) is empty, the same arguments hold: there are no \(x,y\in A\) or \(a\in A\), and both defining conditions are satisfied. Hence \(\operatorname{id}_A\) is bijective for every set \(A\). \(\square\)

In particular, the range of \(\operatorname{id}_A\) equals \(A\). More generally, bijectivity says that every codomain element is attained and no two distinct inputs share an output. For the identity function, both properties follow directly from the rule that an input is returned unchanged.

Identity Functions and Composition

Suppose \(f:A\to B\). To compose \(f\) with an identity function after it, the identity must act on \(B\), the set containing all outputs of \(f\). To compose an identity function before \(f\), it must act on \(A\), the set containing all inputs of \(f\). The resulting identities are $$ \operatorname{id}_B\circ f=f \qquad\text{and}\qquad f\circ\operatorname{id}_A=f. $$ These equations express two different composition orders. The first changes nothing after \(f\) has produced its output; the second changes nothing before \(f\) receives its input.

Theorem (Identity Laws for Composition). Let \(f:A\to B\). Then $$ \operatorname{id}_B\circ f=f \qquad\text{and}\qquad f\circ\operatorname{id}_A=f. $$

Proof. The compositions are defined: the codomain of \(f\) is \(B\), the domain of \(\operatorname{id}_B\), and the codomain of \(\operatorname{id}_A\) is \(A\), the domain of \(f\). Both compositions are functions from \(A\) to \(B\).

Let \(a\in A\) be arbitrary. By the definition of composition and then the definition of the identity function, $$ (\operatorname{id}_B\circ f)(a) =\operatorname{id}_B(f(a)) =f(a). $$ Therefore \(\operatorname{id}_B\circ f\) and \(f\) have equal values at every element of \(A\). By the Pointwise Equality Criterion for functions, \(\operatorname{id}_B\circ f=f\).

For the other composition, $$ (f\circ\operatorname{id}_A)(a) =f(\operatorname{id}_A(a)) =f(a). $$ Again, the functions \(f\circ\operatorname{id}_A\) and \(f\) have equal values at every \(a\in A\), so the Pointwise Equality Criterion gives \(f\circ\operatorname{id}_A=f\). If \(A\) is empty, both compositions are functions with empty domain and the pointwise equality criterion still applies, since there are no inputs at which their values could differ. This proves both identities. \(\square\)

Worked Example: Composing with the Correct Identities

Define \(f:\{m,n\}\to\{0,1,2\}\) by \(f(m)=2\) and \(f(n)=0\). The identity that can be composed after \(f\) is \(\operatorname{id}_{\{0,1,2\}}\), because its domain is the codomain of \(f\). For each input, $$ (\operatorname{id}_{\{0,1,2\}}\circ f)(m) =\operatorname{id}_{\{0,1,2\}}(2)=2=f(m), $$ and $$ (\operatorname{id}_{\{0,1,2\}}\circ f)(n) =\operatorname{id}_{\{0,1,2\}}(0)=0=f(n). $$ Thus \(\operatorname{id}_{\{0,1,2\}}\circ f=f\).

The identity that can be composed before \(f\) is \(\operatorname{id}_{\{m,n\}}\). Indeed, $$ (f\circ\operatorname{id}_{\{m,n\}})(m)=f(m)=2,\qquad (f\circ\operatorname{id}_{\{m,n\}})(n)=f(n)=0. $$ The codomain of \(f\) has an element \(1\) not attained by \(f\), but that does not prevent composition with \(\operatorname{id}_{\{0,1,2\}}\): compatibility requires the outputs of \(f\) to lie in its domain, not that every element of that domain be attained.

Reading the Identity Laws with Their Types

The identity laws look symmetric, but their subscripts are not interchangeable. For \(f:A\to B\), the expression \(\operatorname{id}_B\circ f\) uses the identity on the output set, while \(f\circ\operatorname{id}_A\) uses the identity on the input set. Replacing either subscript without checking the composition may produce an expression that is not defined.

For example, if \(A\) and \(B\) are different sets, \(\operatorname{id}_A\circ f\) is not the composition covered by the first identity law: \(\operatorname{id}_A\) has domain \(A\), while \(f\) has codomain \(B\). That composition is guaranteed by the stated setup only when the needed sets match. The formulas of the functions alone do not fix a type mismatch.

Keep the matching set at each end. For \(f:A\to B\), use \(\operatorname{id}_A\) on the right of \(f\) in \(f\circ\operatorname{id}_A\), and use \(\operatorname{id}_B\) on the left in \(\operatorname{id}_B\circ f\). Composition is read from right to left, so these identities preserve the input set and output set of \(f\).

These laws are consistent with associativity of composition established earlier in this course. Associativity permits regrouping a compatible chain, while the identity laws remove an identity function at either end without changing the resulting mapping. Neither law permits changing the order of the other functions.

1
Start with the function type: write \(f:A\to B\), identifying its domain and codomain.
2
Choose the matching identity: use \(\operatorname{id}_A\) before \(f\), or \(\operatorname{id}_B\) after \(f\).
3
Check the composition: verify that the codomain of the right-hand function matches the domain of the left-hand function.
4
Evaluate at an arbitrary input: apply the composition definition and then \(\operatorname{id}_A(a)=a\) or \(\operatorname{id}_B(b)=b\).
5
Conclude function equality: use the Pointwise Equality Criterion once the two values agree for every input.

The central idea is simple, but its careful use reinforces several distinctions developed in the study of functions. An identity function has a specified domain and codomain; a function’s range need not equal its codomain; and equal formulas do not by themselves establish equality of functions when their domains or codomains differ. The next topic, inverse functions, will use bijections to define a mapping that reverses the effect of a function. The identity function is the natural reference point for those compositions: applying a function and then undoing it should return each original input unchanged.

Check Your Understanding

  1. For a set \(A\), state the domain, codomain, and value rule for \(\operatorname{id}_A\).
  2. If \(f:A\to B\), which identity function appears in \(\operatorname{id}\circ f=f\), and why?
  3. Prove that \(\operatorname{id}_A\) is surjective by identifying a preimage for an arbitrary \(a\in A\).
  4. If \(f:A\to B\), state both identity laws for composition, with the correct subscripts.
  5. Why does the formula \(x\mapsto x\), specified from \([0,1]\) to \(\mathbb R\), not define \(\operatorname{id}_{\mathbb R}\)?