# Inverse function

In mathematics, the inverse function of a function f (also called the inverse of f) is a function that undoes the operation of f. The inverse of f exists if and only if f is bijective, and if it exists, is denoted by $f^{-1}.$
For a function $f\colon X\to Y$, its inverse $f^{-1}\colon Y\to X$ admits an explicit description: it sends each element $y\in Y$ to the unique element $x\in X$ such that f(x) = y.
As an example, consider the real-valued function of a real variable given by f(x) = 5x − 7. One can think of f as the function which multiplies its input by 5 then subtracts 7 from the result. To undo this, one adds 7 to the input, then divides the result by 5. Therefore, the inverse of f is the function $f^{-1}\colon \mathbb {R} \to \mathbb {R}$ defined by $f^{-1}(y)={\frac {y+7}{5}}.$

## Definitions

Let f be a function whose domain is the set X, and whose codomain is the set Y. Then f is invertible if there exists a function g from Y to X such that $g(f(x))=x$ for all $x\in X$ and $f(g(y))=y$ for all $y\in Y$.
If f is invertible, then there is exactly one function g satisfying this property. The function g is called the inverse of f, and is usually denoted as f$^{−1}$, a notation introduced by John Frederick William Herschel in 1813.
The function f is invertible if and only if it is bijective. This is because the condition $g(f(x))=x$ for all $x\in X$ implies that f is injective, and the condition $f(g(y))=y$ for all $y\in Y$ implies that f is surjective.
The inverse function f$^{−1}$ to f can be explicitly described as the function
    $f^{-1}(y)=({\text{the unique element }}x\in X{\text{ such that }}f(x)=y)$.

### Inverses and composition

Recall that if f is an invertible function with domain X and codomain Y, then
    $f^{-1}\left(f(x)\right)=x$, for every $x\in X$ and $f\left(f^{-1}(y)\right)=y$ for every $y\in Y$.
Using the composition of functions, this statement can be rewritten to the following equations between functions:
    $f^{-1}\circ f=\operatorname {id} _{X}$ and $f\circ f^{-1}=\operatorname {id} _{Y},$
where id$_X$ is the identity function on the set X; that is, the function that leaves its argument unchanged. In category theory, this statement is used as the definition of an inverse morphism.
Considering function composition helps to understand the notation f$^{−1}$. Repeatedly composing a function f: X→X with itself is called iteration. If f is applied n times, starting with the value x, then this is written as f$^n$(x); so f$^2$(x) = f (f (x)), etc. Since f$^{−1}$(f (x)) = x, composing f$^{−1}$ and f$^n$ yields f$^{n−1}$, "undoing" the effect of one application of f.

### Notation

While the notation f$^{−1}$(x) might be misunderstood, (f(x))$^{−1}$ certainly denotes the multiplicative inverse of f(x) and has nothing to do with the inverse function of f. The notation $f^{\langle -1\rangle }$ might be used for the inverse function to avoid ambiguity with the multiplicative inverse.
In keeping with the general notation, some English authors use expressions like sin$^{−1}$(x) to denote the inverse of the sine function applied to x (actually a partial inverse; see below). Other authors feel that this may be confused with the notation for the multiplicative inverse of sin (x), which can be denoted as (sin (x))$^{−1}$. To avoid any confusion, an inverse trigonometric function is often indicated by the prefix "arc" (for Latin arcus). For instance, the inverse of the sine function is typically called the arcsine function, written as arcsin(x). Similarly, the inverse of a hyperbolic function is indicated by the prefix "ar" (for Latin ārea). For instance, the inverse of the hyperbolic sine function is typically written as arsinh(x). The expressions like sin$^{−1}$(x) can still be useful to distinguish the multivalued inverse from the partial inverse: $\sin ^{-1}(x)=\{(-1)^{n}\arcsin(x)+\pi n:n\in \mathbb {Z} \}$. Other inverse special functions are sometimes prefixed with the prefix "inv", if the ambiguity of the f$^{−1}$ notation should be avoided.

## Examples
### Squaring and square root functions

The function f: R → [0,∞) given by f(x) = x$^2$ is not injective because $(-x)^{2}=x^{2}$ for all $x\in \mathbb {R}$. Therefore, f is not invertible.
If the domain of the function is restricted to the nonnegative reals, that is, we take the function $f\colon [0,\infty )\to [0,\infty );\ x\mapsto x^{2}$ with the same rule as before, then the function is bijective and so, invertible. The inverse function here is called the (positive) square root function and is denoted by $x\mapsto {\sqrt {x}}$.

### Standard inverse functions

The following table shows several standard functions and their inverses:
Inverse arithmetic functions :
| Function f(x) | Inverse f$^{−1}$(y) | Notes |
| x + a | y − a | |
| a − x | a − y | |
| mx | ⁠y/m⁠ | m ≠ 0 |
| ⁠1/x⁠ (i.e. x$^{−1}$) | ⁠1/y⁠ (i.e. y$^{−1}$) | x, y ≠ 0 |
| x$^p$ | ${\sqrt[{p}]{y}}$ (i.e. y$^{1/p}$) | integer p > 0; x, y ≥ 0 if p is even |
| a$^x$ | log$_a$ y | y > 0 and a > 0 and a ≠ 1 |
| xe$^x$ | W (y) | x ≥ −1 and y ≥ −1/e |
| trigonometric functions | inverse trigonometric functions | various restrictions (see table below) |
| hyperbolic functions | inverse hyperbolic functions | various restrictions |

### Formula for the inverse

Many functions given by algebraic formulas possess a formula for their inverse. This is because the inverse $f^{-1}$ of an invertible function $f\colon \mathbb {R} \to \mathbb {R}$ has an explicit description as
    $f^{-1}(y)=({\text{the unique element }}x\in \mathbb {R} {\text{ such that }}f(x)=y)$.
This allows one to easily determine inverses of many functions that are given by algebraic formulas. For example, if f is the function
    $f(x)=(2x+8)^{3}$
then to determine $f^{-1}(y)$ for a real number y, one must find the unique real number x such that (2x + 8)$^3$ = y. This equation can be solved:
    ${\begin{aligned}y&=(2x+8)^{3}\\{\sqrt[{3}]{y}}&=2x+8\\{\sqrt[{3}]{y}}-8&=2x\\{\dfrac {{\sqrt[{3}]{y}}-8}{2}}&=x.\end{aligned}}$
Thus the inverse function f$^{−1}$ is given by the formula
    $f^{-1}(y)={\frac {{\sqrt[{3}]{y}}-8}{2}}.$
Sometimes, the inverse of a function cannot be expressed by a closed-form formula. For example, if f is the function
    $f(x)=x-\sin x,$
then f is a bijection, and therefore possesses an inverse function f$^{−1}$. The formula for this inverse has an expression as an infinite sum:
    $f^{-1}(y)=\sum _{n=1}^{\infty }{\frac {y^{n/3}}{n!}}\lim _{\theta \to 0}\left({\frac {\mathrm {d} ^{\,n-1}}{\mathrm {d} \theta ^{\,n-1}}}\left({\frac {\theta }{\sqrt[{3}]{\theta -\sin(\theta )}}}\right)^{n}\right).$

## Properties

Since a function is a special type of binary relation, many of the properties of an inverse function correspond to properties of converse relations.

### Uniqueness

If an inverse function exists for a given function f, then it is unique. This follows since the inverse function must be the converse relation, which is completely determined by f.

### Symmetry

There is a symmetry between a function and its inverse. Specifically, if f is an invertible function with domain X and codomain Y, then its inverse f$^{−1}$ has domain Y and image X, and the inverse of f$^{−1}$ is the original function f. In symbols, for functions f:X → Y and f$^{−1}$:Y → X,
    $f^{-1}\circ f=\operatorname {id} _{X}$ and $f\circ f^{-1}=\operatorname {id} _{Y}.$
This statement is a consequence of the implication that for f to be invertible it must be bijective. The involutory nature of the inverse can be concisely expressed by
    $\left(f^{-1}\right)^{-1}=f.$
The inverse of a composition of functions is given by
    $(g\circ f)^{-1}=f^{-1}\circ g^{-1}.$
Notice that the order of g and f have been reversed; to undo f followed by g, we must first undo g, and then undo f.
For example, let f(x) = 3x and let g(x) = x + 5. Then the composition g ∘ f is the function that first multiplies by three and then adds five,
    $(g\circ f)(x)=3x+5.$
To reverse this process, we must first subtract five, and then divide by three,
    $(g\circ f)^{-1}(x)={\tfrac {1}{3}}(x-5).$
This is the composition (f$^{−1}$ ∘ g$^{−1}$)(x).

### Self-inverses

If X is a set, then the identity function on X is its own inverse:
    ${\operatorname {id} _{X}}^{-1}=\operatorname {id} _{X}.$
More generally, a function f : X → X is equal to its own inverse, if and only if the composition f ∘ f is equal to id$_X$. Such a function is called an involution.

### Graph of the inverse

If f is invertible, then the graph of the function
    $y=f^{-1}(x)$
is the same as the graph of the equation
    $x=f(y).$
This is identical to the equation y = f(x) that defines the graph of f, except that the roles of x and y have been reversed. Thus the graph of f$^{−1}$ can be obtained from the graph of f by switching the positions of the x and y axes. This is equivalent to reflecting the graph across the line y = x.

### Inverses and derivatives

By the inverse function theorem, a continuous function of a single variable $f\colon A\to \mathbb {R}$ (where $A\subseteq \mathbb {R}$) is invertible on its range (image) if and only if it is either strictly increasing or decreasing (with no local maxima or minima). For example, the function
    $f(x)=x^{3}+x$
is invertible, since the derivative f′(x) = 3x$^2$ + 1 is always positive.
If the function f is differentiable on an interval I and f′(x) ≠ 0 for each x ∈ I, then the inverse f$^{−1}$ is differentiable on f(I). If y = f(x), the derivative of the inverse is given by the inverse function theorem,
    $\left(f^{-1}\right)^{\prime }(y)={\frac {1}{f'\left(x\right)}}.$
Using Leibniz's notation the formula above can be written as
    ${\frac {dx}{dy}}={\frac {1}{dy/dx}}.$
This result follows from the chain rule (see the article on inverse functions and differentiation).
The inverse function theorem can be generalized to functions of several variables. Specifically, a continuously differentiable multivariable function f : R$^n$ → R$^n$ is invertible in a neighborhood of a point p as long as the Jacobian matrix of f at p is invertible. In this case, the Jacobian of f$^{−1}$ at f(p) is the matrix inverse of the Jacobian of f at p.

## Real-world examples

* Let f be the function that converts a temperature in degrees Celsius to a temperature in degrees Fahrenheit, $F=f(C)={\tfrac {9}{5}}C+32;$ then its inverse function converts degrees Fahrenheit to degrees Celsius, $C=f^{-1}(F)={\tfrac {5}{9}}(F-32),$ since ${\begin{aligned}f^{-1}(f(C))=&f^{-1}\left({\tfrac {9}{5}}C+32\right)={\tfrac {5}{9}}\left(({\tfrac {9}{5}}C+32)-32\right)=C,\\&{\text{for every value of }}C,{\text{ and }}\\[6pt]f\left(f^{-1}(F)\right)=&f\left({\tfrac {5}{9}}(F-32)\right)={\tfrac {9}{5}}\left({\tfrac {5}{9}}(F-32)\right)+32=F,\\&{\text{for every value of }}F.\end{aligned}}$
* Suppose f assigns each child in a family its birth year. An inverse function would output which child was born in a given year. However, if the family has children born in the same year (for instance, twins or triplets, etc.) then the output cannot be known when the input is the common birth year. As well, if a year is given in which no child was born then a child cannot be named. But if each child was born in a separate year, and if we restrict attention to the three years in which a child was born, then we do have an inverse function. For example, ${\begin{aligned}f({\text{Allan}})&=2005,\quad &f({\text{Brad}})&=2007,\quad &f({\text{Cary}})&=2001\\f^{-1}(2005)&={\text{Allan}},\quad &f^{-1}(2007)&={\text{Brad}},\quad &f^{-1}(2001)&={\text{Cary}}\end{aligned}}$
* Let R be the function that leads to an x percentage rise of some quantity, and F be the function producing an x percentage fall. Applied to $100 with x = 10%, we find that applying the first function followed by the second does not restore the original value of $100, demonstrating the fact that, despite appearances, these two functions are not inverses of each other.
* The formula to calculate the pH of a solution is pH = −log$_{10}$[H$^+$]. In many cases we need to find the concentration of acid from a pH measurement. The inverse function [H$^+$] = 10$^{−pH}$ is used.

## Generalizations
### Partial inverses

Even if a function f is not one-to-one, it may be possible to define a partial inverse of f by restricting the domain. For example, the function
    $f(x)=x^{2}$
is not one-to-one, since x$^2$ = (−x)$^2$. However, the function becomes one-to-one if we restrict to the domain x ≥ 0, in which case
    $f^{-1}(y)={\sqrt {y}}.$
(If we instead restrict to the domain x ≤ 0, then the inverse is the negative of the square root of y.)

### Full inverses

Alternatively, there is no need to restrict the domain if we are content with the inverse being a multivalued function:
    $f^{-1}(y)=\pm {\sqrt {y}}.$
Sometimes, this multivalued inverse is called the full inverse of f, and the portions (such as √x and −√x) are called branches. The most important branch of a multivalued function (e.g. the positive square root) is called the principal branch, and its value at y is called the principal value of f$^{−1}$(y).
For a continuous function on the real line, one branch is required between each pair of local extrema. For example, the inverse of a cubic function with a local maximum and a local minimum has three branches (see the adjacent picture).

### Trigonometric inverses

The above considerations are particularly important for defining the inverses of trigonometric functions. For example, the sine function is not one-to-one, since
    $\sin(x+2\pi )=\sin(x)$
for every real x (and more generally sin(x + 2πn) = sin(x) for every integer n). However, the sine is one-to-one on the interval [−⁠π/2⁠, ⁠π/2⁠], and the corresponding partial inverse is called the arcsine. This is considered the principal branch of the inverse sine, so the principal value of the inverse sine is always between −⁠π/2⁠ and ⁠π/2⁠. The following table describes the principal branch of each inverse trigonometric function:
| function | Range of usual principal value |
| arcsin | −⁠π/2⁠ ≤ sin$^{−1}$(x) ≤ ⁠π/2⁠ |
| arccos | 0 ≤ cos$^{−1}$(x) ≤ π |
| arctan | −⁠π/2⁠ < tan$^{−1}$(x) < ⁠π/2⁠ |
| arccot | 0 < cot$^{−1}$(x) < π |
| arcsec | 0 ≤ sec$^{−1}$(x) ≤ π |
| arccsc | −⁠π/2⁠ ≤ csc$^{−1}$(x) ≤ ⁠π/2⁠ |

### Left and right inverses

Function composition on the left and on the right need not coincide. In general, the conditions
* "There exists g such that g(f(x))=x" and
* "There exists g such that f(g(x))=x"
imply different properties of f. For example, let f: R → [0, ∞) denote the squaring map, such that f(x) = x$^2$ for all x in R, and let g: [0, ∞) → R denote the square root map, such that g(x) = √x for all x ≥ 0. Then f(g(x)) = x for all x in [0, ∞); that is, g is a right inverse to f. However, g is not a left inverse to f, since, e.g., g(f(−1)) = 1 ≠ −1.

#### Left inverses

If f: X → Y, a left inverse for f (or retraction of f ) is a function g: Y → X such that composing f with g from the left gives the identity function $g\circ f=\operatorname {id} _{X}{\text{.}}$ That is, the function g satisfies the rule
    If f(x)=y, then g(y)=x.
The function g must equal the inverse of f on the image of f, but may take any values for elements of Y not in the image.
A function f with nonempty domain is injective if and only if it has a left inverse. An elementary proof runs as follows:
* If g is the left inverse of f, and f(x) = f(y), then g(f(x)) = g(f(y)) = x = y.
* If nonempty f: X → Y is injective, construct a left inverse g: Y → X as follows: for all y ∈ Y, if y is in the image of f, then there exists x ∈ X such that f(x) = y. Let g(y) = x; this definition is unique because f is injective. Otherwise, let g(y) be an arbitrary element of X.For all x ∈ X, f(x) is in the image of f. By construction, g(f(x)) = x, the condition for a left inverse.
In classical mathematics, every injective function f with a nonempty domain necessarily has a left inverse; however, this may fail in constructive mathematics. For instance, a left inverse of the inclusion {0,1} → R of the two-element set in the reals violates indecomposability by giving a retraction of the real line to the set {0,1}.

#### Right inverses

A right inverse for f (or section of f ) is a function h: Y → X such that
    $f\circ h=\operatorname {id} _{Y}.$
That is, the function h satisfies the rule
    If $\displaystyle h(y)=x$, then $\displaystyle f(x)=y.$
Thus, h(y) may be any of the elements of X that map to y under f.
A function f has a right inverse if and only if it is surjective (though constructing such an inverse in general requires the axiom of choice).
    If h is the right inverse of f, then f is surjective. For all $y\in Y$, there is $x=h(y)$ such that $f(x)=f(h(y))=y$.
    If f is surjective, f has a right inverse h, which can be constructed as follows: for all $y\in Y$, there is at least one $x\in X$ such that $f(x)=y$ (because f is surjective), so we choose one to be the value of h(y).

#### Two-sided inverses

An inverse that is both a left and right inverse (a two-sided inverse), if it exists, must be unique. In fact, if a function has a left inverse and a right inverse, they are both the same two-sided inverse, so it can be called the inverse.
    If $g$ is a left inverse and $h$ a right inverse of $f$, for all $y\in Y$, $g(y)=g(f(h(y))=h(y)$.
A function has a two-sided inverse if and only if it is bijective.
    A bijective function f is injective, so it has a left inverse (if f is the empty function, $f\colon \varnothing \to \varnothing$ is its own left inverse). f is surjective, so it has a right inverse. By the above, the left and right inverse are the same.
    If f has a two-sided inverse g, then g is a left inverse and right inverse of f, so f is injective and surjective.

### Preimages

If f: X → Y is any function (not necessarily invertible), the preimage (or inverse image) of an element y ∈ Y is defined to be the set of all elements of X that map to y:
    $f^{-1}(y)=\left\{x\in X:f(x)=y\right\}.$
The preimage of y can be thought of as the image of y under the (multivalued) full inverse of the function f.
The notion can be generalized to subsets of the range. Specifically, if S is any subset of Y, the preimage of S, denoted by $f^{-1}(S)$, is the set of all elements of X that map to S:
    $f^{-1}(S)=\left\{x\in X:f(x)\in S\right\}.$
For example, take the function f: R → R; x ↦ x$^2$. This function is not invertible as it is not bijective, but preimages may be defined for subsets of the codomain, e.g.
    $f^{-1}(\left\{1,4,9,16\right\})=\left\{-4,-3,-2,-1,1,2,3,4\right\}$.
The original notion and its generalization are related by the identity $f^{-1}(y)=f^{-1}(\{y\}),$ The preimage of a single element y ∈ Y – a singleton set {y}  – is sometimes called the fiber of y. When Y is the set of real numbers, it is common to refer to f$^{−1}$({y}) as a level set.