# Inverse functions

A function is a way of processing numbers. You plug in some number and get out a new one. The inverse of a function is then a redo-process, which takes in the old output, and spits out the initial input. ## Intro

During the Second World War, the Germans encrypted their messages with a machine known as the Enigma.

This machine relied on scrambling, assigning each letter in the message another letter. That way, the original message was scrambled into a ciphered message. In Enigma, each letter was automatically reassigned a new letter, making the cipher harder to break.

However, inspired by the work of some Poles, British cryptologists eventually invented a machine for finding the settings of Enigma.

The breaking of the Enigma code, which was crucial for the outcome of the war, meant constructing an inverse function.

## Concept

The Enigma works like a function: it takes a message as input, scrambles it, and spits out a scrambled message.

In finding the settings of the Enigma, the British cryptologists essentially found the inverse function of the Enigma, reversing the enciphering.

The inverse function undoes the effect of the original function

Inverse functions allow us to perform the equivalent of control-Z on a PC. They tell us what value we fed the original function to obtain that particular output. ## Math

Recall that a function can be thought of as a black box, taking in one input and spitting out exactly one output.

Sometimes we're asked to find the input, given the output - to break the code.

If the original function is called , its inverse is dubbed .

So:

Not all functions are invertible, though.

For example, if spits out , there's no way of knowing whether is or .

## Bijective functions

In this note, we'll introduce a bunch of important terms. So buckle your seat belt, and here we go!

A function isn't just an algebraic expression, like . For example, for all real numbers isn't the same as for . The rules aren't identical. We need a new piece of terminology to describe what distinguishes from .

The values which we can feed the function make up the domain. In the above example, and have domains and . Thus, they're not identical.

When we feed the function the values from the domain, it'll give you the range. For instance, has all positive numbers as its range, and has range . The values in the range are part of a bigger "blob", the codomain. In calculus we usually assume that the codomain consists of all real numbers, if this is not the case we generally state it as a property of the function. ### Injectivity, surjectivity, bijectivity

Let's start with the idea of injectivity. If a function returns two different outputs, then we must've fed it two different inputs. A function is injective if two distinct elements in the domain are paired with two distinct elements in the codomain. To check whether a function is injective, begin by drawing its graph. If you can draw a horizontal line that intersects the graph at more than one point, the function is not injective. Mathematicians also talk about surjectivity. If, when you feed the function all values from the domain, the function returns all values in the codomain, the function is surjective. So a function is surjective if its range is the codomain. Now to the final one (this one isn't all too bad, so hang in there!). A function is bijective if it's injective and surjective at once. In the picture below, every dot in the left blob is associated with another dot in the right blob. ### Examples

Here's a mind-bending example.

The function is neither injective, nor surjective. can only assume positive values, right? Also, since , it can't be injective either. By setting the codomain to all positive values, becomes surjective. However, it's still not injective. If we restrict the domain to all positive values, becomes injective. If , every value gets assigned a unique value, . Finally, if only takes positive inputs and its codomain consists of all positive values, it's bijective. ## Monotonic functions

Some quantities never stop increasing or decreasing. Although it sometimes feel like time pass slower than usual, or even stand still, we know that it doesn't actually.

Instead, it keeps ticking on, constantly increasing with the same pace. At least in the way us humans interact with time. A monotonic function is one which never breaks the trend of rising or falling. We generally allow for it to stay constant, but if not, we say that it is strictly monotonic.

Monotonicity

A function is said to be monotonically increasing if for every , .

A function is said to be monotonically decreasing if for every , .

A function is monotonic if it is monotonically increasing or monotonically decreasing.

For differentiable functions, monotonicity can be viewed in terms of non-negative or non-positive derivatives.

The derivative of a monotonic function never changes sign, but it is allowed to be zero.

Note that both definitions allow for the equality . Therefore, the constant function is both monotonically increasing and monotonically decreasing. Strict monotonicity

A function is said to be strictly monotonically increasing if for every , .

A function is said to be strictly monotonically decreasing if for every ,

A function is strictly monotonic if it is strictly monotonically increasing or strictly monotonically decreasing.

An example of a strictly monotonically increasing function is the exponential function: A shared property of all strictly monotonic functions is that they are injective.

## Inverse functions

A function can be thought of as a black box. Feed it an input, and it'll spit out another, unique value. Perhaps we'd like to know which value we fed the function.

You want to become rich, so you can drive a Cadillac and go to Bali twice a year.

Thus, you create a function for your total savings during a year. It takes your monthly savings as an input, and spits out the grand total . That way, you can see the compound interest effect.

Now, if you want your total savings to be dollars by the end of the year, you must calculate how much to save every month. This involves constructing an inverse function. Knowing a bit of math pays off!

The inverse function of , denoted by , takes the output of and spits out the original value we fed . It, kind of, undoes the effect of the function . There are, however, a few caveats.

Consider . Two values can yield the same output. So if we feed to , it'll spit out . Next, we ask our inverse function to return the original value. But the inverse function doesn't know whether to return or , since also equals . The inverse function can't return two or more values - then it wouldn't be a function!

In practise, this means that the function must be bijective, meaning that we have this kind of situation: ### Drawing an inverse function

To draw the function graph of an inverse function, draw the line . Next, draw the inverse function, like so: In general, and are symmetric around the line .

Let's have a go at drawing the inverse function of . First, we chop of the graph at and . Then we're left with a bijective function, which has an inverse. Using the same technique as above, you'd get something like this:   