Why does an inverse function's range have to be its entire codomain? (Noob question.)
I'm working through Khan Academy, and one of the criteria that Sal mentioned for a function to be invertible is that its range must be equal to its entire codomain, which means that one of the criteria is that the function must be surjective.
So for a function like $f(x)=e^x$ which is a mapping from ℝ^1 to ℝ^1, does it mean that $e^x$ is not invertible because the image (range) of $e^x$ is not the entire codomain ℝ^1?
For example, $e^x$ can never equal a negative number, and so automatically we know that $e^x$ does not span its codomain (the function's range is smaller than the codomain), which is  ℝ^1.
However, we know that $e^x$ does have an inverse, and that inverse is $\ln\left(x\right)$.
Does this go against what the definition of a function being invertible? What am I getting wrong here?
Help would be appreciated.
 A: Every function must have a specified domain and codomain, and an inverse function's domain is the codomain of the original function.
If you view $e^x$ as a function from $\mathbb{R}$ to $\mathbb{R}$, then it is indeed not invertible, for the reason you mention, viz. it is not surjective. A function must be able to accept any input from its domain, and your proposed inverse $\log x$ does not accept nonpositive numbers. $\log x$ is not defined as a function on all of $\mathbb{R}$, and so is not an inverse function for $e^x$ as a function to all of $\mathbb{R}$.
However to state the problem is to solve it. You may instead choose to view $e^x$ as a function from $\mathbb{R}$ to $\mathbb{R}^+$ (the positive reals). Then it is surjective, and it has an inverse $\log x$, which is a function from $\mathbb{R}^+$ to $\mathbb{R}$
To reiterate, a function must be surjective in order to have an inverse, because if it were not, then any point in its codomain which is not in its range, is a point in the domain of the inverse function where the inverse function is undefined. And one of the defining requirements for a function to be a function is that it is never undefined at any point of its domain.
A: $\def\R{\mathbf{R}}$
Mathematicians do not place much stead in the difference between the co-domain and the range. In other words, most people would consider $f:\R\to\R$ defined as $f(x)=e^x$, and the function $g:\R\to(0,\infty)$ defined by $g(x):=e^x$ to be the same function (even though strictly speaking they are different functions). This should be contrasted to how we treat difference in domains. If in the previous two functions, the domain of $f$ was changed to $[0,1]$, then we would consider $f$ and $g$ to be different functions.
In this vein, really, the only requirement one needs for a function to be invertible is that it be one to one, not surjective. Since all the inverse function is doing is that it is mapping the range back to the domain.
If we had a one to one function $h:A\to B$ where $A,B\subseteq\R$, then if the range did equal the co-domain, we could simply write its inverse as $h^{-1}:B\to A$. If the range was a subset of the co-domain however, we'd have to write something like $h^{-1}: h[A]\to B$, where $h[A]$ means the range of $h$.
In other words, mathematicians in the strictest sense do require functions to be injective as well as surjective in order to be invertible, to avoid the case where some members of the co-domain don't get mapped to anything in the domain, and hence are undefined.
In the end, this distinction is usually not an issue, since we normally know our range and co-domain, and can use these two notions of inverses as we wish.
