TITLE: Understanding the difference between pre-image and inverse
QUESTION [7 upvotes]: I am a little confused as to what the difference between the pre-image and the inverse of a function are and how to find each given a particular function ( I had though they were essentially the same thing but I realise now I was mistaken in that thought ).
From Wikipedia the definitions given are :
Inverse
Let $f$ be a function whose domain is the set $X$, and whose image (range) is the set $Y$. Then $f$ is invertible if there exists a function $g$ with domain $Y$ and image $X$, with the property: 
$f ( x ) = y \iff g ( y ) = x . $
If $f$ is invertible, the function $g$ is unique, which means that there is exactly one function $g$ satisfying this property (no more, no less). That function $g$ is then called the inverse of $f$, and is usually denoted as $f ^{−1}$
Pre-image 
Let $f$ be a function from $X$ to $Y$. The preimage or inverse image of a set $B\subseteq Y$ under $f$ is the subset of $X$ defined by 
$f ^{− 1 }[ B ] = \{ x \in X \mid f ( x ) \in B \}$.
So using an example I want to see if I have this about right ( please correct any mistakes I make)
Example 1:
Lets say $f:\Bbb R \rightarrow \Bbb R$
$f(x)=x^2$
For this example, clearly $f$ cannot be invertible (hence no inverse) as there exists no function $g$ which will satisfy $ f ( x ) = y \iff g ( y ) = x$. (as it would only map to positive values of $\Bbb R$ (i.e. not the whole set))
The pre-image of this function I believe is related to the inverse except it does not require that we map to the whole set $\Bbb R$, but rather just a subset of it. Therefore we can find the function $f^{-1}$ in an analogous way to to finding the inverse we just have to be more considerate about what the co-domain of this function is. 
So if $f(x)=x^2 \Rightarrow y=x^2  $swap variables to get $x=y^2 \Rightarrow \sqrt{x}=y=f^{-1} $
So the pre-image is the set $f ^{− 1 }[ \Bbb R_+ ] = \{ x \in X \mid f ( x ) \in \Bbb R_+, f^{-1}=\sqrt{x} \}
$
Example 2:
An example of an invertible function would be $f:\Bbb R \rightarrow \Bbb R$
$f(x)=5x$, as a function $g(x)=x/5$ has domain $\Bbb R$ and range $\Bbb R$ and satisfies $f ( x ) = y ⇔ g ( y ) = x .$
The pre-image in this case will be equal to the inverse.
Could anyone please explain to me any mistakes I'm making here ?

REPLY [2 votes]: So, there's no such thing as the preimage of a function. Functions can have inverses; functions do not have preimages.
An inverse is something that certain functions have, and the inverse of a function is another function.
Given a function, a preimage is something that sets have, and the preimage of a set is another set.
Specifically:
Given a function $f : A \to B$, that function may or may not have an inverse. If it does, then that inverse is a function $B \to A$.
Given a function $f : A \to B$, and a set $s$ which is a subset of $B$, that set always has a preimage under $f$. That preimage is a subset of $A$.
That might clear up some of your confusion.