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

From what I understand, a function has an inverse if and only if such function is a bijection.

So if we consider $$f(x)=\frac{1}{x}$$, it is clear that $$f$$ is not a bijection since $$f$$ is not surjective (because its codomain is $$\mathbb{R}$$, which is not equal to its range $$\mathbb{R}$$\{$$0$$} ).

However, looking at this website here (https://www.mechamath.com/algebra/how-to-know-if-a-function-has-an-inverse/) it mentions that you can do a "horizontal line test" to determine if a function has an inverse - i.e. if you can draw a horizontal line on a sketch of $$y=f(x)$$ that passes through more than one point, then the function doesn't have an inverse.

Using this horizontal line test on $$f(x)=\frac{1}{x}$$, no horizontal line can be drawn which crosses through two points on a sketch of $$y=\frac{1}{x}$$ and so this would suggest that an inverse does exist for $$f(x)=\frac{1}{x}$$ and that this would be $$f^{-1}(x)=\frac{1}{x}$$.

So my question is simply whether $$f(x)=\frac{1}{x}$$ does, or doesn't, have an inverse?

• The function $$f:\mathbb R\setminus\{0\}\to\mathbb R\setminus\{0\}, x\mapsto \frac1x$$ is bijective and it is its own inverse. But if you choose its codomain equal to $\mathbb R$, then it is not its own inverse (and it has no inverse), because there is no $x\in\mathbb R\setminus\{0\}$ such that $\frac1x=0$. Dec 24, 2021 at 14:46

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).

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.

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.

First of all, the domain of the function $$f$$ described by $$f(x) = \frac 1x$$ is $$\mathbb R \backslash\{0\}$$ (you can plug anything but $$0$$ into this function). The range of the function is also $$\mathbb R \backslash \{0\}$$, because the equation $$y= \frac 1x$$ is solvable iff $$y \ne 0$$. Because the solution of $$y= \frac 1x$$ is unique for any $$y \ne 0$$, the function is injective (which corresponds to the horizontal line check). You could also see this by $$\frac 1x = \frac 1y \Leftrightarrow 1 = \frac xy \Leftrightarrow x=y$$ because $$y \ne 0$$ and $$x \ne 0$$.

Any injective function has an inverse if you "reduce" the codomain (which becomes the domain of the inverse) so that the function is also surjective (just make the range of the function the codomain). Therefore $$f: \mathbb R \backslash \{0\} \to \mathbb R, f(x) = \frac 1x$$ would not be invertible - but if we manipulate the codomain and change it to $$f: \mathbb R \backslash \{0\} \to \mathbb R \backslash \{0\}, f(x) = \frac 1x$$ is invertible and $$y= \frac 1x \Leftrightarrow x = \frac 1y$$ tells us that the inverse of $$f$$ is $$f$$ itself.