## Section0.6Inverse Functions

There is one last thing that we should review before we get into the main material of the course and that is inverse functions. As we have seen above functions are really just rules for taking an input (almost always a number), processing it somehow (usually by a formula) and then returning an output (again, almost always a number).

\begin{gather*} \text{input number}\;\; x \quad \mapsto \quad f\;\; \text{does stuff'' to}\;\; x \quad \mapsto \quad \text{return number}\;\; y \end{gather*}

In many situations it will turn out to be very useful if we can undo whatever it is that our function has done. ie

\begin{gather*} \text{take output}\;\;y \quad \mapsto \quad \text{do stuff'' to}\;\; y \quad \mapsto \quad \text{return the original}\;\; x \end{gather*}

When it exists, the function “which undoes” the function $f(x)$ is found by solving $y=f(x)$ for $x$ as a function of $y$ and is called the inverse function of $f\text{.}$ It turns out that it is not always possible to solve $y=f(x)$ for $x$ as a function of $y\text{.}$ Even when it is possible, it can be really hard to do  1 Indeed much of encryption exploits the fact that you can find functions that are very quick to do, but very hard to undo. For example — it is very fast to multiply two large prime numbers together, but very hard to take that result and factor it back into the original two primes. The interested reader should look up trapdoor functions..

For example — a particle's position, $s\text{,}$ at time $t$ is given by the formula $s(t) = 7t$ (sketched below). Given a calculator, and any particular number $t\text{,}$ you can quickly work out the corresponding positions $s\text{.}$ However, if you are asked the question “When does the particle reach $s=4\text{?}$” then to answer it we need to be able to “undo” $s(t)=4$ to isolate $t\text{.}$ In this case, because $s(t)$ is always increasing, we can always undo $s(t)$ to get a unique answer:

\begin{align*} s(t) &= 7t = 4 & \text{ if and only if }&& t&= \frac{4}{7}. \end{align*}

However, this question is not always so easy. Consider the sketch of $y=\sin(x)$ below; when is $y=\half\text{?}$ That is, for which values $x$ is $\sin(x)=\half\text{?}$ To rephrase it again, at which values of $x$ does the curve $y=\sin x$ (which is sketched in the right half of Figure 0.6.1) cross the horizontal straight line $y=\frac{1}{2}$ (which is also sketched in the same figure)?

We can see that there are going to be an infinite number of $x$-values that give $y=\sin(x)=\half\text{;}$ there is no unique answer.

Recall (from Definition 0.4.1) that for any given input, a function must give a unique output. So if we want to find a function that undoes $s(t)\text{,}$ then things are good — because each $s$-value corresponds to a unique $t$-value. On the other hand, the situation with $y=\sin x$ is problematic — any given $y$-value is mapped to by many different $x$-values. So when we look for an unique answer to the question “When is $\sin x = \half\text{?}$” we cannot answer it.

This “uniqueness” condition can be made more precise:

###### Definition0.6.2

A function $f$ is one-to-one (injective) when it never takes the same $y$ value more than once. That is

\begin{gather*} \mbox{if } x_1 \neq x_2 \mbox{ then } f(x_1) \neq f(x_2) \end{gather*}

There is an easy way to test this when you have a plot of the function — the horizontal line test.

###### Definition0.6.3Horizontal line test

A function is one-to-one if and only if no horizontal line $y=c$ intersects the graph $y=f(x)$ more than once.

i.e. every horizontal line intersects the graph either zero or one times. Never twice or more. This test tell us that $y=x^3$ is one-to-one, but $y=x^2$ is not. However note that if we restrict the domain of $y=x^2$ to $x \geq 0$ then the horizontal line test is passed. This is one of the reasons we have to be careful to consider the domain of the function.

When a function is one-to-one then it has an inverse function.

###### Definition0.6.4

Let $f$ be a one-to-one function with domain $A$ and range $B\text{.}$ Then its inverse function is denoted $f^{-1}$ and has domain $B$ and range $A\text{.}$ It is defined by

\begin{align*} f^{-1}(y) &= x & \text{ whenever }&& f(x)&=y \end{align*}

for any $y \in B\text{.}$

So if $f$ maps $x$ to $y\text{,}$ then $f^{-1}$ maps $y$ back to $x\text{.}$ That is $f^{-1}$ “undoes” $f\text{.}$ Because of this we have

\begin{align*} f^{-1}( f(x) ) &= x &\mbox{ for any $x \in A$}\\ f( f^{-1}(y) )&=y &\mbox{ for any $y \in B$} \end{align*}

We have to be careful not to confuse $f^{-1}(x)$ with $\ds \frac{1}{f(x)}\text{.}$ The “$-1$” is not an exponent.

Let $f(x)=x^5+3$ on domain $\mathbb{R}\text{.}$ To find its inverse we do the following

• Write $y=f(x)\text{;}$ that is $y=x^5+3\text{.}$
• Solve for $x$ in terms of $y$ (this is not always easy) — $x^5=y-3\text{,}$ so $x=(y-3)^{1/5}\text{.}$
• The solution is $f^{-1}(y) = (y-3)^{1/5}\text{.}$
• Recall that the “$y$” in $f^{-1}(y)$ is a dummy variable. That is, $f^{-1}(y) = (y-3)^{1/5}$ means that if you feed the number $y$ into the function $f^{-1}$ it outputs the number $(y-3)^{1/5}\text{.}$ You may call the input variable anything you like. So if you wish to call the input variable “$x$” instead of “$y$” then just replace every $y$ in $f^{-1}(y)$ with an $x\text{.}$
• That is $f^{-1}(x) = (x-3)^{1/5}\text{.}$

Let $g(x) = \sqrt{x-1}$ on the domain $x \geq 1\text{.}$ We can find the inverse in the same way:

\begin{align*} y &= \sqrt{x-1}\\ y^2 &= x-1\\ x &= y^2+1 = f^{-1}(y) & \text{or, writing input variable as $x$'':}\\ f^{-1}(x) &= x^2+1. \end{align*}

Let us now turn to finding the inverse of $\sin(x)$ — it is a little more tricky and we have to think carefully about domains.

We have seen (back in Figure 0.6.1) that $\sin(x)$ takes each value $y$ between $-1$ and $+1$ for infinitely many different values of $x$ (see the left-hand graph in the figure below). Consequently $\sin(x)\text{,}$ with domain $-\infty \lt x \lt \infty$ does not have an inverse function.

But notice that as $x$ runs from $-\frac{\pi}{2}$ to $+\frac{\pi}{2}\text{,}$ $\sin(x)$ increases from $-1$ to $+1\text{.}$ (See the middle graph in the figure above.) In particular, $\sin(x)$ takes each value $-1 \le y\le 1$ for exactly one $-\frac{\pi}{2}\le x\le \frac{\pi}{2}\text{.}$ So if we restrict $\sin x$ to have domain $-\frac{\pi}{2}\le x\le \frac{\pi}{2}\text{,}$ it does have an inverse function, which is traditionally called arcsine (see Appendix A.9).

That is, by definition, for each $-1\le y\le 1\text{,}$ $\arcsin(y)$ is the unique $-\frac{\pi}{2}\le x\le \frac{\pi}{2}$ obeying $\sin(x)=y\text{.}$ Equivalently, exchanging the dummy variables x and y throughout the last sentence gives that for each $-1\le x\le 1\text{,}$ $\arcsin(x)$ is the unique $-\frac{\pi}{2}\le y\le \frac{\pi}{2}$ obeying $\sin(y)=x\text{.}$

It is an easy matter to construct the graph of an inverse function from the graph of the original function. We just need to remember that

\begin{equation*} Y=f^{-1}(X) \iff f(Y)=X \end{equation*}

which is $y=f(x)$ with $x$ renamed to $Y$ and $y$ renamed to $X\text{.}$

Start by drawing the graph of $f\text{,}$ labelling the $x$– and $y$–axes and labelling the curve $y=f(x)\text{.}$

Now replace each $x$ by $Y$ and each $y$ by $X$ and replace the resulting label $X=f(Y)$ on the curve by the equivalent $Y=f^{-1}(X)\text{.}$

Finally we just need to redraw the sketch with the $Y$ axis running vertically (with $Y$ increasing upwards) and the $X$ axis running horizontally (with $X$ increasing to the right). To do so, pretend that the sketch is on a transparency or on a very thin piece of paper that you can see through. Lift the sketch up and flip it over so that the $Y$ axis runs vertically and the $X$ axis runs horizontally. If you want, you can also convert the upper case $X$ into a lower case $x$ and the upper case $Y$ into a lower case $y\text{.}$

Another way to say “flip the sketch over so as to exchange the $x$– and $y$–axes” is “reflect in the line $y=x$”. In the figure below the blue “horizontal” elliptical disk that is centred on $(a,b)$ has been reflected in the line $y=x$ to give the red “vertical” elliptical disk centred on $(b,a)\text{.}$

As an example, let $f(x) = x^2$ with domain $0\le x \lt \infty\text{.}$

• When $x=0\text{,}$ $f(x)=0^2=0\text{.}$
• As $x$ increases, $x^2$ gets bigger and bigger.
• When $x$ is very large and positive, $x^2$ is also very large and positive. (For example, think $x=100\text{.}$)

The graph of $y=f(x)=x^2$ is the blue curve below. By definition, $Y=f^{-1}(X)$ if $X=f(Y)=Y^2\text{.}$ That is, if $Y=\sqrt{X}\text{.}$ (Remember that, to be in the domain of $f\text{,}$ we must have $Y\ge 0\text{.}$) So the inverse function of “square” is “square root”. The graph of $f^{-1}$ is the red curve below. The red curve is the reflection of the blue curve in the line $y=x\text{.}$