Functions - Composition and Inverse In this module, we will cover two important things to do with functions: composing functions, and inverse functions . Composing a function with itself means applying the same function twice. For example, if you have a function f(x) = x + 1 and you want to apply it twice, you canwrite f(f(x)). In this case, f is applied to x and then the result is added to 1. So you getf(x) + 1 for all x. Inverse functions are defined as having an inverse relation between them. In other words, for every y there exists some x such that f(x) = y. The inverse function of g isdenoted by g-1 or g^-1. For example, if g(x)=x^2 then g-1(y) = y/y^2 = 1/y = x/x^2 =x. Composing 2 functions ● Basic Idea ● A warning Inverse Functions ● Basic Idea ● A Neat Picture ● A warning Let's begin by examining the composition of functions. Suppose we have f(x) = x^2and g(x) = x+5. Now we`re not going to graph these for a second. Let's rememberthat functions are actually machines that map sets—in this case, the real line—tosets. So here is a copy of the real line, here is a copy of the real line, and here is thefunction f that goes from here to here. So remember this machine takes any point xand maps it to x^2. Here is another copy of the real line, here is an arrow, and here isg. So this machine takes anything here and maps it to that thing plus five. Let's connect the triangle here with a dotted line. we`re going to do this funnysymbol, g circle f. We read this as g composed with f. By definition, g composed withf means that of an input thing x, the result is equal to first feeding x into the machinef. The machine goes whir, chunk, it spits out an output f(x). Now you feed that outputinto the machine g; g(f(x)). Let's work through an example. Suppose we have a typical input, x. We thencompute what g of f(x) actually is in this example. So that's supposed to be g of f(x).What's f(x)? f(x) is x^2, so this is g of x^2. Now here's the hard part: we need tofigure out what happens when you apply the machine to its input. The machine takesanything and adds five to it, so in our case what does it do? It takes x^2 вЂ“ anyinput вЂ“ and adds five to it. Don't be deceived by the fact that you have an x here;that just stands for any input. In this case, it was x^2; now we're talking about whathappens when we apply the machine to its input (x^2 + 5).
Composition refers to taking a function and applying it to another function beforeperforming the operation on all of its arguments. For example, g of f of two will beg(f(2)), and g(f(2)) = 2^2 = 4. Then we take four and add five to it, which gives usnine. That's what it means to compose functions. The reverse order is also possible:f of g of x in this case would be f(g(x)). In that situation, we would have to compute (x+ 5)^2 = (x + 5) * (x + 5) = x^2 + 5, which unfortunately isn't the same as x^4 + 5 aswe all know. So, you can't necessarily compose things in whatever order you want;often you can but not always. Okay that's what it means to compose functions. There is a special type of function that when you compose them, you undo what youdid. Suppose we start with f(x) = 2x. Suppose someone magically hands us g(x) = 1/2 x.Let's see what happens when we compose these functions using the input x. Sonote: f(g(x)) = f(1/2 x). We know that f(x) = 2x, so now we have f(1/2 x) = 2(1/2 x),which equals 1/2 x by definition of g(x). Now let's plug in 1/2 x for x into our gfunction and see what happens: (1/2) times the input вЂ“ so now we`re setting theinput to be 1/2 x вЂ“ is equal to 1/2 x. And there's the punchline: one half times twois one вЂ“ so this is equal to x by definition of f(x). The function g(f(x)) = 3 for every x such that f(x) ≠ 0. In other words, g of f of three, ifwe follow through all this madness, we`re gonna get three; g of f of negative pi, if wefollow through all this madness, we`re gonna get negative pi. In this case, we saythat f and g are inverses of each other. That is, g undoes what f does. And we oftenwrite this: g is equal to f to the -1. It is important to note that g is not 1/f—that is a very unfortunate notation. Oftenwhen we say two to the -1, we mean one half. That's not really what we mean here.
We mean it's a function that undoes a machine that undoes the original machine. Ifyou liked your x and some idiot came along and multiplied it by two and you weren'thappy with that, you didn't put in a work order for that g is a function which undoeswhat that idiot does and puts it right, sort of a way of getting rid of the stupid action.That's the point. Let's examine an interesting geometric relationship between non-coincident inversefunctions, which is shown in the following graph. On the left side of the graph, wesee the function y = 2x. On the right side of the graph, we see a function that is notequal to its inverse. In other words, y = 1/2x is not equal to its inverse f(x) = 2x.Someone took an x and turned it into four, we didn't like that, we want x back. If thisis our picture of y = 2x, here's four. We can take this horizontal line at y=4 and dash itover until we hit the graph. The result is a horizontal line at y = 2(x − 2), which isequivalent to y = 4 − 2(2) or y = 2. Therefore, if the horizontal line hits a point on thegraph with an x value of two, then all horizontal lines would have their x valueschanged to two. If you take any dotted line here and drop it, whatever x-value is onthat dotted line will give you the corresponding y-value. The inverse function swapsthe roles of x and y, so to find the inverse function we need to reflect the entire graphabout a 45° line. When we reflect about this line, we get a red graph which is equalto 1/2x. Again, these are just some conceptual ideas that may help you understandwhat is happening when you find inverses from functions from the real line to the realline. That picture leads us to the following warning. So first let me just write this: not everyfunction f from R to R can be inverted. In fact, in some vaguely defined sense, mostdon't have inverses. By the way, if you'd like a non-vague definition of most, take lotsand lots of probability courses вЂ“ that gets to be some really interesting abstractmath.
Let us consider the function f(x) = x2. We can draw the graph of this function. Wesee that there is no inverse function, and we can once again apply a trick to find aparticular value by stretching the graph upward. For example, if someone told us thatf(x) = 4, then we could find the value of x that led to this result by plugging in f(x) = 4.Unfortunately, that same horizontal line also passes through the graph at anotherpoint. Remember the horizontal line test? The line hits the graph twice; therefore,you can't take its square root to obtain an answer. That is the whole problem rightthere. If we take the square root of four, we actually have to take plus or minus two.The values of those two expressions are functions of the values of the variables xand y. When we multiply them together and then square the result, we get 2x2 + 2y2.The whole problem is finding a function f that takes in 4 as input and spits out 2 and–2 as output. The punch line here is that if a function fails the horizontal line test,then it has no inverse and all strictly increasing or decreasing functions have aninverse. If you remember from previous videos, the horizontal line test says that forany given value of x, there exists at least one value of y that makes f(x) = 0 true.