Why do we replace y by x and then calculate y for calculating the inverse of a function? Why do we replace y by x and then calculate y for calculating the inverse of a function?
So, my teacher said that in order to find the inverse of any function, we need to replace y by x and x by y and then calculate y. The reason being inverse takes y as input and produces x as output.
My question is-
Why do we have to calculate y after swapping? I do not get this part.
 A: Good question , If $y=f(x)$ then for $x$ the function $f$ determines a unique $y$ .If there is an inverse function then for each $y$ the above equation determines a unique $x$ ,so that in principle (and in simple cases one can solve the equation for $x$ in terms of $y$ getting $x$ in terms of $y$ viz : $x=f^{-1}(y)$  showing for each $y$ how to calculate the unique $x$ . But now if you wanted to graph the two functions on the same graph paper and you do since the graph is the picture of the function ;then you have to use the same independent and dependent variables in both cases .
Traditionally  "x" is used for the independent and "y" the dependent variable . so you must switch them in the equation for the  inverse . 
   Often teachers and books trying to program you to get the right answer tell you to switch the $x$ and $y$ . at the beginning so you don't forget or something .I never liked that because it obscures what you are doing . 
  Even switching at the end is bad if $x$ and $y$ carry different units or geometric interpretation like $x$ miles and $y$ pounds or something -then you would pick neutral new variables for both $f$ and $f^{-1}$ at the very end . 
A: Let $f(x)=y$, we would like to find $f^{-1}(x)$, to do this note by definition:
$$f(f^{-1}(x))=x$$
If we for the moment call $f^{-1}(x)$ as $y$, then by solving,
$$f(y)=x$$
For $y$ we have found $f^{-1}(x)$. Note in the above we have switched $x$ with $y$ and vice versa.
Actually I think it is sloppy to call $f^{-1}(x)$ as $y$, because it was already defined before. In my opinion it's better to call it $u$ then solve,
$$f(u)=x$$
For $u$, which is doing the same thing.
If $g(x,y)=0$ with $y=f(x)$, then we plug in $f^{-1}(x)$ for $x$ to get,
$$g(f^{-1}(x),x)=0$$
Now for the moment call $f^{-1}(x)$ as $u$, then solving,
$$g(u,x)=0$$
For $u$ or equivalently, 
$$g(y,x)=0$$
For $y$ gives $f^{-1}(x)$. Notice again the equation we had to solve is the result of switching $x$ and $y$ in the original equation.
