# Finding function inverse

Hi,

This question is actually from KhanAcademy - Algebra 2. I managed to solve it using the rote method by swapping the x and y.

But I would like to find out the reason for swapping x and y for finding the function inverse.

Can anyone explain?

hint :suppose $f(x)=\left \{ (1,2),(2,4),(3,7) \right \}$ so $f^{-1}(x)$ must be $$f^{-1}(x)=\left \{ (2,1),(4,2),(7,3) \right \}$$ in the other hand :
when you put x=1 function return $f(1)=2$ so
when you put x=2 on $f^{-1}$ must return $f^{-1}(2)=1$ this is the reason for swapping $x,y$
You do not have to swap $x$ and $y$; the solution, as you may be able to see, would work equally well if you did not. The reason that teachers often have students do this is that they are used to solving for $y$. Often, if students start with the equation $$y = \frac{5x-3}{x-1}$$ and begin solving for $x$, at some point halfway through doing so, they will fall back into their old habits, and solve for $y$ instead of $x$. Swapping makes it so that you don't have to keep reminding yourself to solve for $x$ --- you can just solve for $y$ like you always do. Fewer mistakes are made, and students are generally less confused.