# Inverse Functions: Restricted Domain for Square Root (Part 5)

With the last four posts as prelude, let’s consider finding the inverse of the function $f: \mathbb{R} \to \mathbb{R}$ defined by $f(x) = x^2$.

Of course, we can’t find an inverse for this function as stated. Colloquially, the graph of $f$ fails the horizontal line test. More precisely, there exist two numbers $x_1$ and $x_2$ so that $x_1 \ne x_2$ but $f(x_1) = f(x_2)$. (Indeed, there are infinitely many such pairs — $a$ and $-a$ for any $a \ne 0$ — but that’s beside the point.)

So how will we find the inverse of $f$? Well, we can’t. But we can do something almost as good: we can define a new function $g$ that’s going look an awful lot like $f$. Here’s the function:

$g: [0,\infty) \to [0,\infty)$ defined by $g(x) = x^2$.

Notice that the function $g$ looks an awful lot like $f$, except that the domain has been restricted. In this way, the left half of the graph of $f$ is essentially erased to produce the graph of $g$.

So while the graph of $f$ fails the horizontal line test, the graph of $g$ does pass the horizontal line test. Therefore, $g$ has an inverse function. We reverse the roles of domain and range (of course, for this example, the domain and range are identical):

$g^{-1}: [0,\infty) \to [0,\infty)$

Also, the graph of $g^{-1}$ can be produced by reflecting through the line $y=x$, producing the purple graph below.

Of course, the function $g^{-1}(x)$ is more customarily written as $\sqrt{x}$. Stated another way using the restricted domain of $g$.

$y = \sqrt{x}$ means that $x = y^2$ and $y \ge 0$.

Pedagogically, when teaching Precalculus, I’ve found that this way of writing the definition of $\sqrt{x}$ is a useful prelude to the definition of the inverse trigonometric functions.

A couple of notes:

1. Notice that, if the purple parabola was completed, the full parabola would violate the vertical line test and thus fail to be a function. Thinking back to the original function, that’s another way of saying that the original full parabola violates the horizontal line test.
2. Since $g$ and $g^{-1}$ are inverse functions, it’s always true that $g(g^{-1}(x)) = x$ and $g^{-1}(g(x)) = x$. However, $g^{-1}$ and $f$ are not inverse functions, and so it’s possible for $g^{-1}(f(x))$ to be something other than $x$. This subtle distinction will be discussed more in tomorrow’s post.
3. Restricting the domain to $[0,\infty)$ was a perfectly arbitrary decision. It would have been perfectly OK if we have chosen the left half of the original parabola instead of the right half, as either half of the parabola satisfies the horizontal line test. So why did we choose the right half (with the nonnegative domain) instead of the left half (with the nonpositive domain)? That I can answer with one word: tradition. (By the way, finding an expression for the restriction of $f$ to $(-\infty,0])$ is a standard problem in a first course in real analysis.