Does the function $f(x)=\frac{1}{x}$ have an inverse function?

Solution 1:

Two things. First, when you are talking about the inverse of a function it is crucial that you specify what the codomain is.

  • if the codomain is $\mathbb{R}$ then there is a left-inverse but not a right inverse
  • if the codomain is $\mathbb{R} \setminus \{0\}$ then there is a two-sided inverse

Second, the "horizontal line test"—if you want to think about it like that—has two parts:

  1. if no horizontal line intersects the graph more than once, then the function has a left inverse (injective)
  2. if every horizontal line intersects the graph at least once, then the function has a right inverse (surjective)

Therefore, if every horizontal line intersects the graph exactly one time, then the function has a two-sided inverse (bijective).

Solution 2:

The horizontal line test only tells us the function is injective. Anyway, before we start talking about injectivity/surjectivity/biijectivity, we should always specify domains and target spaces.

The function $f_1:\Bbb{R}\setminus\{0\}\to\Bbb{R}$, $f_1(x)=\frac{1}{x}$ is injective, but not surjective.

The function $f_2:\Bbb{R}\setminus\{0\}\to\Bbb{R}\setminus \{0\}$, $f_2(x)=\frac{1}{x}$ is bijective, and $(f_2)^{-1}=f_2$.

The function $f_3:(0,\infty)\to \Bbb{R}$, $f_3(x)=\frac{1}{x}$ is injective but not surjective.

The function $f_4:(0,\infty)\to (0,\infty)$, $f_4(x)=\frac{1}{x}$ is bijective, and $(f_4)^{-1}=f_4$.

And so on. But note that typically, if we have a function $f:A\to B$ which is injective, it usually doesn't hurt to restrict it's target space to equal the image, and then that resulting function will be bijective.

Solution 3:

The horizontal line test you mention only checks if $f$ is injective. The correct test would be: every horizontal line crosses the graph exactly once. (This is assuming the codomain is $\Bbb R$. Otherwise, the horizontal lines should be restricted to the appropriate codomain.)

Indeed, $f$ has an inverse when considered as a function from $\Bbb R \setminus \{0\}$ to $\Bbb R \setminus \{0\}$. (And not when the codomain is considered to be $\Bbb R$.)

But there's a more general phenomenon to be considered here: Suppose $f : A \to B$ is a function. The codomain is not so "inherent" to the function as much as its image (range). You could always just take a superset of the codomain and still have the "same function".
In particular, if $f : A \to B$ is an injective function, then the "restriction" $f : A \to f(A)$ is a bijection and it has an inverse. ($f(A)$ denotes the image of $f$.)

In this sense, you only need an injection to have an inverse, which is what the original horizontal line test says.