What is the exact definition of an inverse function? I recently started reading a book which has challenged my understanding of functions and inverse functions quite a bit (mostly the format of the notations that are used); I know that we write a function $( f )$ that maps elements of its domain, $X$, to elements of its co-domain, $Y$, as:
$f:X\rightarrow Y \qquad x \mapsto y  \qquad \text{where} \quad x\in X \quad \text{and} \quad y=f(x) \in Y $ 
$\\$
This is the point where my understanding starts to deviate from the book's content. The book goes on to define the inverse of the function $f$ as the map 
$g:Y\rightarrow X \qquad y \mapsto x \quad \text{where} \quad y \in Y \quad x=g(y) \in X $
and then mentions that, since the map $g$ maps EVERY element of its domain ($Y$) onto its co-domain ($X$), it must be injective and since the same holds for the map $f$, we conclude that both $f$ and $g$ are bijective maps. 
The problem with this statement, I feel like, is that it excludes the possibility of the co-domain being larger than the image of $f$ (it restricts the co-domain into being the image of $f$)
$\\$
$f:[-\pi/2,\pi/2] \rightarrow \mathbb{R}    \quad \text{where} \quad x\mapsto f(x)=\sin x \qquad [1]$
this function is not invertible as it's not bijective (The co-domain isn't the same as the image of $f$)
whereas the function 
$f:[-\pi/2,\pi/2]  \rightarrow [-1,1]    \quad \text{where} \quad x\mapsto f(x)=\sin x \qquad [2]$
is invertible. Is this correct? If it is, then, are we to say that the functions [1] and [2] are different functions? If it isn't, then doesn't that go against our definition and conditions for inverse functions?
 A: Note.- By "relation" is meant  : a set of couples, that is, a set of ordered pairs. 
A relation from a set A to a set B is a subset of the cartesian product A cross B ( a subset of all the possible ordered pairs with first element in A and second element in B).  

A function is a relation, and every relation has an inverse relation. 
For all relation R, the inverse of R ( noted R^-1) is
{ (y, x) | (x,y) belong to R }. 
(In words, the inverse relation of relation R has , as elements, the " same" ordered pairs as R, but in reversed order.) 
But saying that any function has an inverse relation does not mean that this inverse relation is automatically a function. 
There are functions such that their inverse relation is also a function, and in that case, one can talk about their " inverse function". 
Example, function f such that f = { (1,2) , ( 3,4)} 
There are functions such that their inverse relation is not a function. 
Example, function g such that g = { (1,2), (3,2) } 
Other example : 
The set of all pairs of real numbers (x, y) such that y = x² is a function. 
It's inverse relation is the set of all pairs (x,y) such that x = y². 
A vertical line test will show you that this inverse relation is not a function. 

