A function is bijective if it is both injective and surjective. A bijective function *f*:**A** → **B** has an inverse function, *f*^{-1}: **B** → **A**, such that for all `a` in **A**, *f*^{-1}(*f*(`a`)) = `a`, and for all `b` in **B**, *f*(*f*^{-1}(`b`)) = `b`.

It is worth noting that since for every function *f* there exists a similar function *g* such that *g*(`x`) = *f*(`x`) for every `x` in the domain, and the range of *g* is restricted to the codomain (and so is surjective), every injective function has a corresponding function *g*^{-1} such that for all `a` in **A**, *g*^{-1}(*f*(`a`)) = `a`, and for all `c` in the codomain of *f*, *f*(*g*^{-1}(`c`)) = `c`. This function is very nearly the inverse of *f*, except the domain of g^{-1} is the *codomain* of f, rather than the domain of f.