# Domain and Range of Inverse Function Confusion

I often see that books define a function f as $f: X\rightarrow Y$. Now, I thought that the inverse is defined as $f^{-1}: Y\rightarrow X$. Then, in many places where I see the inverse mentioned, they write it as $f^{-1}(x)=y$ (assuming here that $Y$ is the image. That makes their domain equivalent. I thought that the inverse function's domain is the original function's range/image? Heck, the way that one finds an inverse in early algebra is to swap x and y, rearrange to get a function of y, then re-flip the variables.