##### Tools

This site is devoted to mathematics and its applications. Created and run by Peter Saveliev.

# Operations on functions

## 1 Operations with sets

Let's go back to our the example of five boys that form a set and another set is the set of these four balls:

They are just lists without repetitions: $$\begin{array}{lll} X&=\{\text{ Tom }, \text{ Ken }, \text{ Sid }, \text{ Ned }, \text{ Ben }\},\\ Y&=\{\text{ basketball }, \text{ tennis }, \text{ baseball }, \text{ football }\}. \end{array}$$ We can form a new set that contains all the elements of the two sets.

We merge the two sets together and, once the separator is gone, move the elements around.

Definition. The union of any two sets $X$ and $Y$ is the set that consists of the elements that belong to either $X$ or $Y$. It is denoted by $X\cup Y$.

The most common case is when both sets are subsets of the same set. The unions of these will be subsets of the union of $X$ and $Y$: $$\begin{array}{lll} T=\{\text{ Tom }\},\quad A=\{\text{ Tom, Ken }\},\quad Q=\{\text{ Tom, Ken, Sid }\},\quad ...&\subset X;\\ B=\{\text{ basketball }\},\quad V=\{\text{ basketball, tennis }\},\quad U=\{\text{ basketball, tennis, baseball }\},\quad ...&\subset Y;\\ \Longrightarrow\\ \{\text{ Tom }\}\cup \{\text{ basketball }\}=\{\text{ Tom, basketball }\}&\subset X\cup Y;\\ \{\text{ Tom, Ken }\}\cup \{\text{ basketball, tennis }\}=\{\text{ Tom, Ken, basketball, tennis }\}&\subset X\cup Y.\\ \end{array}$$ So, to find the union of two such sets, we just merge the lists. To find unions of subsets of $X\cup Y$, we merge the lists removing repetitions, i.e., the “overlap” of the two sets: $$\begin{array}{lll} \{\text{ tennis, Tom, Ken }\}\cup \{\text{ basketball, tennis, Tom }\}&=\{\text{ tennis, Tom, Ken, basketball, tennis, Tom }\}\\ &=\{\text{Tom, Ken, basketball, tennis }\}. \end{array}$$

Exercise. Present the unions of all pairs of sets shown above. Now, the triples, and so on.

Example (lists). We merge lists together and then carefully remove the repetitions: $$\{1,2,3,4\}\cup\{3,4,5,6,7\}=\{1,2,3,4,\quad 3,4,5,6,7\}=\{1,2,3,4,5,6,7\}.$$ $\square$

Next, the “overlap” itself. We look at what the two sets have in common:

We find the repeated parts and make them overlap; the rest is thrown out.

Definition. The intersection of any two sets $X$ and $Y$ is the set that consists of all the elements that belong to both $X$ and $Y$. It is denoted by $X\cap Y$.

Here is an example of such computation: $$\begin{array}{lll} \{\text{ tennis, Tom, Ken }\}\cap \{\text{ basketball, tennis, Tom }\}&=\{\text{ tennis, Tom }\}. \end{array}$$

Recall that the set-building notation is used to create a set by stating a condition these numbers are supposed to satisfy: $$Z=\{x:\ \text{ condition for } x\ \}.$$ We consider what happens to sets given this way under these two operations.

Example (equations). Numerical sets are subsets of the real line ${\bf R}$ and some of them came from solving these equations, as their solution sets: $$\begin{array}{l|ll} \text{equation }& \text{ solution set }& \text{ simplified }\\ \hline x^2-3x+2=0 &X=\{x:\ x^2-3x+2=0 \} & =\{1,2\}; \\ x^2=1 &Y=\{x:\ x^2=1 \}& = \{-1,1\}. \\ \end{array}$$ What if we have both equations to be satisfied at the same time? We are interested in the set: $$\begin{array}{llcll} Z&=\{x:\ x^2-3x+2=0 &\texttt{ AND }& x^2=1\}\\ &&& \Longrightarrow & x \text{ belongs to both }X\ \texttt{ AND }\ Y!\\ Z&=X&\cap&Y \\ &= \{x:\ x^2-3x+2=0\}&\cap&\{x:\ x^2=1\} \\ &= \{1,2\}&\cap&\{-1,1\}\\ &=\{1\}. \end{array}$$ $\square$

Warning: don't confuse an element of a set and a one-element set.

So, sometimes the condition that define the set splits into two conditions, $$Z=\{x:\ \text{ satisfies first condition }\texttt{ AND } \text{ satisfies second condition }\}.$$ The word “$\texttt{AND}$” is capitalized in order to emphasize that the set contains only those $x$'s that satisfy both conditions simultaneously. Then we can see also that there are two sets, $$X=\{x:\ \text{ satisfies first condition }\} \text{ and } Y=\{x:\ \text{ satisfies second condition }\},$$ one for either condition. We are interested in their intersection: $$Z=X\cap Y=\{x:\ \text{ satisfies first condition }\} \cap \{x:\ \text{ satisfies second condition }\}.$$

Example (inequalities). These conditions can also be inequalities. Let's consider this “double inequality”: $$0\le x \le 3.$$ Its solutions set is all $x$'s that satisfy the inequality. However, there are two in reality. When there are two inequalities, there are two solution sets: $$\begin{array}{llcll} &\{x:\ 0\le x \le 3\}\\ =&\{x:\ x\ge 0 &\texttt{ AND }& x\le 3\}\\ =& \{x:\ x\ge 0\}&\cap&\{x:\ x\le 3\} \\ =& [0,+\infty)&\cap &(-\infty,3]\\ =&[0,3]. \end{array}$$

We see intersection as an “overlap” of these subsets. What if we “flip” this inequality: $$0\ge x \ge 3.$$ Then, $$\begin{array}{llcll} &\{x:\ 0\ge x \ge 3\}\\ =&\{x:\ x\le 0 &\texttt{ AND }& x\ge 3\}\\ =& \{x:\ x\le 0\}&\cap&\{x:\ x\ge 3\} \\ =& (-\infty,0]&\cap &[3,+\infty)\\ =&\emptyset. \end{array}$$ $\square$

Exercise. What happens if you flip only one of the two inequalities above?

In summary: $$\{x:\ \text{ first condition }\texttt{ AND } \text{ second condition }\}=\{x:\ \text{ first condition }\} \cap \{x:\ \text{ second condition }\}.$$

We next consider subsets of the plane.

Example (graphs). All the graphs (of both relations and functions) are subsets of ${\bf R}^2$. For example, these are a few graphs of some relations, such as $x^2+y^2=k$ for the concentric circles:

The intersection of any two of them (for two different values of $k$) is empty. $\square$

Example (intercepts). For a function $F:{\bf R}\to {\bf R}$, its graph is the following set given presented via the set-building notation: $$\{(x,y):\ y=F(x)\}.$$ Two especially important subsets of the plane are the two axes.

Suppose $y=F(x)$ is a numerical function. Then the $x$-intercepts of $F$ are the elements of the intersection of the graph of $F$ with the $x$-axis: $$\{x\text{-intercepts}\}=\text{graph of }F\ \cap\ x\text{-axis}.$$ Meanwhile, the $y$-intercept of $F$ is the only element of the intersection of the graph of $F$ with the $y$-axis: $$\{y\text{-intercept}\}=\text{graph of }F\ \cap\ y\text{-axis}.$$ $\square$

Exercise. Give example of functions for which these sets are empty.

Exercise. Explain these: $$x\text{-axis}\ \cap\ y\text{-axis}\ \text{ and }\ \{x\text{-intercepts}\}\cap \{y\text{-intercept}\}.$$

Example (mixtures). Recall an example from Chapter 2: is it possible to create, from the Kenyan coffee - $\$2$per pound -- and the Colombian coffee -$\$3$ per pound, $6$ pounds of blend with the total price of $\$14$? The result is two linear relations each representing a line on the$xy$-plane: $$\begin{cases} x&+&y &= &6 ,\\ 2x&+&3y &= &14. \end{cases}$$ So, the intersection is a point and this point$(x,y)$is the solution of the system of equations formed by these two equations. Just as before, when there are two equations, there are two sets: $$\begin{array}{llcll} &\{(x,y):\ x+y = 6 &\texttt{ AND }&\qquad\qquad2x+3y = 14\}\\ =& \{(x,y):\ x+y = 6\}&\cap&\{(x,y):\ 2x+3y = 14\}\\ =&\{(4,2)\}. \end{array}$$ The intersection is a single point! The existence of an intersection point tells us that it is possible to create such a blend! However, if the Colombian coffee is also priced at$\$2$ per pound, there is no such mixture: $$\{(x,y):\ x+y = 6\} \cap \{(x,y):\ 2x+2y = 14\}=\emptyset.$$

The third possibility occurs when we change, in addition, the total price of the blend to $\$12$: $$\{(x,y):\ x+y = 6\} \cap \{(x,y):\ 2x+2y = 12\}=\{(x,y):\ x+y = 6\}.$$ There are infinitely many possible mixtures.$\square$Exercise. Illustrate the second and third possibilities in the last example. Exercise. Find the algebraic representations of these two lines and repeat the analysis above: Exercise. Evaluate: $$\{(x,y):\ y\ge f(x)\} \cap\{(x,y):\ y\le f(x)\}.$$ More examples of these two operations for subsets of the plane: These may also serve as illustrations of unions and intersections of “generic” sets. ## 2 Piece-wise defined functions Suppose one person knows only the preferences of Tom, Ned, and Ben, i.e., function$F$, and suppose another person knows only the preferences of Ben, Ken, and Sid, i.e., function$G$. Can the two pool their knowledge together in a meaningful way? This amounts to building a new function from two old ones: Of course, this is only possible if the data of ones isn't in conflict with that of the other (that's Ben). Otherwise we would end up with two arrows originating from the same input; not a function! So, we have two observations. • 1. We define the new function the domain of which is the union of the domains of the two functions. • 2. It is only possible as long as the values of the two functions on the intersection of their domains are the same. The two domains become the two pieces of the domain of the new function. Definition. Let$A,B$be two subsets of a set$X$such that$X = A \cup B$and let$Y$also be a set. Suppose also that$F: A \to Y,\ G:B\to Y$are two functions. A function$f:X\to Y$defined by: •$f(x)=F(x)$if$x$is in$A$, •$f(x)=G(x)$if$x$is in$B$, is called the piece-wise defined function of$F$and$G$. Since$f$is assumed to be a function, we are supposed to have one$y$for each$x$in the domain. Therefore: $$F(x)=G(x),\text{ for all } x \text{ in } A\cap B.$$ Exercise. What if the codomains are also different? We can just merge the tables of these functions: We can also superimpose the graphs of these functions: The algebraic notation for this function puts the formulas before the conditions: $$f(x)=\begin{cases} F(x) & \text{ if } x\text{ in } A; \\ G(x) & \text{ if } x\text{ in } B. \end{cases}$$ As it is often the case in algebra, the formula is to be read from right to left; i.e., $$\begin{cases} \text{ if } x\text{ in } A,& \text{compute }& f(x)=F(x); \\ \text{ if } x\text{ in } B,& \text{compute }& f(x)=G(x). \end{cases}$$ Example (graphs). In case of numerical functions, the graphs of two functions can be “glued together” (or rather “two wires soldered together”) to create a new function, as follows. The construction can fail:$\square$When there is no intersection of the domains, $$A\cap B=\emptyset,$$ there is no issue! Often however, we don't want to deal with the intersection and instead choose to glue together functions the domains of which has no intersection. It's especially true when there are more than two functions. We use the following notation (left): $$f(x)= \begin{cases} F_1(x) & \text{ if } x\text{ in } A_1; \\ F_2(x) & \text{ if } x\text{ in } A_2; \\ F_3(x) & \text{ if } x\text{ in } A_3; \\ ... &...\qquad; \end{cases}\quad\text{ means }\begin{cases} \text{ if } x\text{ in } A_1,& \text{compute }& f(x)=F_1(x); \\ \text{ if } x\text{ in } A_2,& \text{compute }& f(x)=F_2(x); \\ \text{ if } x\text{ in } A_3,& \text{compute }& f(x)=F_3(x); \\ ... &...\qquad. \end{cases}$$ provided$A_i\cap A_j=\emptyset$for$i\ne j$. With multiple sets, the “pieces” of the domain are introduced as conditions to be satisfied. Example (income tax). Suppose, hypothetically, that the tax code says: • if your income is less than$\$10000$, there is no income tax;
• if your income is between $\$ 10000$and$\$20000$, the tax rate is $10\%$;
• if your income is over $\$ 20000$, the tax rate is$20\%$. Let's build a function! Let$x$be the input (the income) and$y=f(x)$output (tax rate). Let the domain be$[0,+\infty)$. We choose the codomain to be$[0,1]$. The three “brackets” are the subsets of the domain. Since the values are different, we need to make sure that there is no overlap between the “pieces”: • if$0\le x\le 10000$, then$y=0$; • if$10000< x\le 20000$, then$y=.10$; • if$20000< x$, then$y=.20$. Let's build a flowchart. In contrast to most past examples, there is a fork on the road this time. The way we answer these questions about$x$determines the route for our computation: $$\begin{array}{ccc} f:& x & \mapsto & \begin{array}{|c|}\hline &x& \begin{array}{ll} \nearrow_{\text{ if }x\le 10000} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }0 \quad \\ \hline\end{array} & \mapsto & y & \searrow\\ \to_{\text{ if }10000< x\le 20000} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }.10 \quad \\ \hline\end{array} & \mapsto & y & \to\\ \searrow_{\text{ if }20000< x} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }.20 \quad \\ \hline\end{array} & \mapsto & y & \nearrow\\ \end{array}& y\\ \hline\end{array} & \mapsto & y \end{array}.$$ We also express the tax rate algebraically: $$f(x) = \begin{cases} 0 & \text{if } x \le 10000; \\ .10 & \text{if } 10000 < x \le 20000; \\ .20 & \text{if } 20000 <x. \end{cases}$$ This formula, however, cannot be applied directly to calculate your tax bill; indeed, if your income rises from$\$10,000$ to $\$ 10,001$, your tax bill would rise from$\$0$ to $\$ 1,000$. This is the issue of “discontinuity” discussed in Chapter 6. More realistically, the output of the formula represents a “marginal” tax rate: the rate you apply to that part of the income that lies within the bracket. These three numbers are then added together to produce your tax bill.$\square$Exercise. Find the formula of the tax bill. Hint: its graph is shown above on right. Some of very important functions are presented by several formulas at the same time. The next function is meant to give the direction from the origin to the location given by the input number: •$3$is to the right of$0$, so the direction is positive; and we say “it's$1$”; •$-5$is to the left of$0$, so the direction is negative; and we say “it's$-1$”. Definition. The sign function, which is denoted by $$y=\operatorname{sign}(x),$$ is defined as follows: • if$x<0$, then$y=-1$; • if$x=0$, then$y=0$; • if$x>0$, then$y=1$. If we think of a function as a sequence of steps, this is the case when the sequence splits; this is its flowchart: $$\begin{array}{ccc} y=\operatorname{sign}(x):& x & \mapsto & \begin{array}{|c|}\hline &x& \begin{array}{lllll} \nearrow_{\text{ if }x< 0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }-1 \quad \\ \hline\end{array} & \mapsto & y & \searrow\\ \to_{\text{ if }x=0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }0 \quad \\ \hline\end{array} & \mapsto & y & \to\\ \searrow_{\text{ if }x>0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }1 \quad \\ \hline\end{array} & \mapsto & y & \nearrow\\ \end{array}& y\\ \hline\end{array} & \mapsto & y \end{array}.$$ This is the algebraic formula: $$\operatorname{sign}(x)=\begin{cases} -1&\text{ if } x<0,\\ 0&\text{ if } x=0,\\ 1&\text{ if } x>0. \end{cases}$$ In other words, the function strips the input number off its magnitude and what's left is its sign, which is, in a way, its direction. Note how in this example there are three doors with specific values behind each and the only job of$x$is to point us at the right door. It is clear that the implied domain of this function is${\bf R}=(-\infty,+\infty)$. Since the only possible values are listed in the description of the function, the image is the set of these three,$\{-1,0,1\}$. We see that also in the table of values of the sign function, the$y$-values: $$\begin{array}{c|ccc} x&-3&-2&-1&0&1&2&3\\ \hline y&-1&-1&-1&0&1&1&1 \end{array}$$ This is the result: This is not enough, however, in order to see what the graph is around$0$; we insert more points into the table: $$\begin{array}{c|ccc} x&-.8&-.6&-.4&-.2&0&.2&.4&.6&.8\\ \hline y&-1&-1&-1&-1&0&1&1&1&1 \end{array}$$ The outputs continue to be repeated! This is an indication that the graph is horizontal in those areas. As we plot those points, we realize that can't connect them into a “single curve”. If this function to represent motion, we'd teleport... This issue is discussed in Chapter 6. The next function is meant to give the distance from the location given by the input number to the origin: both$3$and$-3$are$3$units from the origin. The result is always positive (except for$0$itself). One would commonly say that “the minus sign is dropped”. Warning: We can't “drop the sign” of$-x$because$x$itself might be negative. How else do we make a negative number positive? We multiply it by$-1$! Definition. The absolute value function, which is denoted by $$y = |x|,$$ is computed as follows: • if$x<0$, then$y=-x$; • if$x=0$, then$y=0$; • if$x>0$, then$y=x$. This is its flowchart: $$\begin{array}{ccc} y=|x|:& x & \mapsto & \begin{array}{|c|}\hline &x& \begin{array}{lllll} \nearrow_{\text{ if }x< 0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ multiply by }-1 \quad \\ \hline\end{array} & \mapsto & y & \searrow\\ \to_{\text{ if }x=0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ choose }0 \quad \\ \hline\end{array} & \mapsto & y & \to\\ \searrow_{\text{ if }x>0} &x\mapsto \begin{array}{|c|}\hline\quad \text{ pass it } \quad \\ \hline\end{array} & \mapsto & y & \nearrow\\ \end{array}& y\\ \hline\end{array} & \mapsto & y \end{array}.$$ This is the algebraic formula: $$|x|=\begin{cases} -x&\text{ if } x<0,\\ 0&\text{ if } x=0,\\ x&\text{ if } x>0. \end{cases}$$ In other words, the function does the opposite of what the sign function does; it strips the input number off its sign, or direction, and what's left is its magnitude. Exercise. Show that the two functions above are related by the following identity: $$|x|=\operatorname{sign}(x)\cdot x.$$ Exercise. Explain the alternative method is of this function: • if$x \le 0$then$y = - x$; and • if$x \ge 0$then$y = x$. Exercise. Present a flowchart for this definition. It is clear that the domain of this function is${\bf R}=(-\infty,+\infty)$. To find the image (the range of values), we take into account these two facts: • the only possible values are non-negative (by design), • every non-negative number is its own absolute value. Therefore, the image is the set of all non-negative numbers,$[0,+\infty)$. We see that also in the table of values of the absolute value function, the$y$-values: $$\begin{array}{c|ccc} x&-3&-2&-1&0&1&2&3\\ \hline y&3&2&1&0&1&2&3 \end{array}$$ As we plot more and more of those points, we realize that -- in contrast to$y=\operatorname{sign}(x)$-- we can connect them into a “single curve”. However, this V-shaped curve is made of parts of two straight lines,$y=x$and$y=-x$, without any “smoothing”. If the function to represent motion, the change of direction would be abrupt or even instantaneous! This issue is discussed in Chapter 7. Exercise. What symmetry do you see in the graph? Another important piece-wise defined function is the following. Definition. The integer value function, which is denoted by $$y = [x],$$ is defined as the largest integer$y$less than or equal to$x$. In other words, given an input of$x$, let's describe a procedure for computing this function. We have for a given$x$: • Step 1: determine whether$x$is integer or not. • Step 2: if$x$is an integer, then set$y=x$; else decrease from$x$until meet an integer, set$y$equal that integer. For example, we have: $$[5]=5,\ [3.1]=[3.99]=3,\ [-4.1]=-5.$$ Exercise. Present a flowchart for this definition. It is clear that the domain of this function is all reals${\bf R}=(-\infty,+\infty)$. To find the image, we take into account these two facts: • the only possible values are integers (by design), • the integer value of every integer is that number. Therefore, the image is the integers${\bf Z}=\{...,-3,-2,-1,0,1,2,3,...\}$. We see that also in the table of values of this function, the$y$-values: $$\begin{array}{c|ccc} x&-3&-2&-1&0&1&2&3\\ \hline y&-3&-2&-1&0&1&2&3 \end{array}$$ This is not enough, however, in order to see what the graph is. All we see is just a sequence of points on the line$y=x$: We insert more points: $$\begin{array}{c|ccc} x&-3&-2.5&-2&-1.5&-1&-.5&0&.5&1&1.5&2&2.5&3\\ \hline y&-3&-3&-2&-2&-1&-1&0&0&1&1&2&2&3 \end{array}$$ The outputs are repeated! This is an indication that the graph is horizontal in those areas. As we plot those points, we realize that can't connect them into a “single curve”, again. Example. Note that by the “pieces” of a piece-wise defined function we refer to the subsets of the domain (the segments of the$x$-axis below). Meanwhile, the corresponding pieces of the graph don't have to fit together well:$\square$Exercise. Write a formula for the above graph. Example (plotting). Let's plot the graph of the piece-wise defined function: $$f(x) = \begin{cases} 3 - \frac{1}{2}x & \text{ for } x \leq 2, \\ 2x - 5 & \text{ for } x > 2. \end{cases}$$ We follow these steps: • 1. plot$y=3 - \tfrac{1}{2} x$; • 2. plot$y=3 - \tfrac{1}{2}x$with domain$x \leq 2$; • 3. plot$y=2x - 5$; • 4. plot$y=2x - 5$with domain$x > 2$; • 5. combine the plots from 2) and 4).$\square$Exercise. Make a flowchart, write a formula, and then plot the graph of the function$y=f(x)$, where$x$is time in hours and$y=f(x)$is the parking fee over$x$hours, which is computed as follows: free for the first hour, then$\$1$ per every full hour for the next $3$ hours, and a flat fee of $\$5$for anything longer. Exercise. Make a hand-drawn sketch of the graph of the function: $$f(x)= \begin{cases} -3 &\text{ if } x<0,\\ x^2 &\text{ if } 0\le x<1,\\ x &\text{ if } x>1. \end{cases}$$ Example. The flowcharts also help to visualize what happens inside the black box that is a function when we step outside the domain: $$\begin{array}{ccc} y=1/x:& x & \mapsto & \begin{array}{|c|}\hline &x& \begin{array}{lllll} \nearrow_{\text{ if }x\ne 0} &x \mapsto &\begin{array}{|c|}\hline\quad \text{ take its reciprocal } \quad \\ \hline\end{array} & \mapsto & y & \searrow\\ \\ \searrow_{\text{ if }x=0} & x\mapsto &\begin{array}{|c|}\hline\quad \text{ STOP! } \quad \\ \hline\end{array} & & & \\ \end{array}& y\\ \hline\end{array} & \mapsto & y \end{array}$$$\square$Exercise. Make a flowchart as above for$f(x)=\sqrt{x}$. Exercise. Make a flowchart and then provide a formula for the function$y=f(x)$that represents a parking fee for a stay of$x$hours. It is computed as follows: free for the first hour and$\$1$ per hour beyond.

## 3 Numerical functions are transformations of the real number line

...and vice versa.

When an abstract numerical function $y=f(x)$ is given to us without any prior background, it may be a good idea to create a tangible representation for it. The two main ways we are familiar with are these:

• 1. we think of the function as if it represents motion: $x$ time, $y$ location;
• 2. we plot the graph of the function on a piece of paper.

Let's set these aside for now and imagine a third approach:

• 3. we think of the function as a transformation of the real line.

First, let's go back to representing a numerical function as correspondence between the $x$ and the $y$-axis:

As you can see, these are the same axes we use to plot the graph, but they are arranged parallel to each other instead of perpendicular. The arrows tell us what happens to each number. But there is more to it: they also suggest what happens to the whole $x$-axis!

Let's consider something more specific:

We ask, what has happened to the $x$-axis under this transformation?

Warning: Above you see two ways to interpret the function: (1) arrows are between the $x$-axis and the intact $y$-axis or (2) we move the $y$-axis so that $y=f(x)$ is aligned with $x$. The approaches give two different, even opposite, answers to the question. We will follow the former.

To make this more tangible, we will think as if the whole $x$-axis is drawn on a pencil:

A transformation we start with is a “motion”, specifically, a shift. We simply slide the pencil horizontally. Furthermore, there is another pencil to be used for reference. The markings (i.e., its coordinate system) on the second pencil show the new locations of the points on the first. As an example, a shift of $3$ units to the right is shown below:

Generally,

• when shifted $k>0$ units right, point $x$ becomes $x+k=y$.

Warning: replace “right” with “up” if the axes are aligned vertically; it's the positive direction that matters.

In the meantime, what about shifting left? We have:

• when shifted $k>0$ units left, point $x$ becomes $x-k$.

Of course, we can combine the two statements:

• when shifted $k>0$ units right/left, point $x$ becomes $x\pm k$.

Instead, we should allow $k$ to be negative. Then we can interpret the former statement to include the latter if we understand “$k$ units left” as “$-k$ units right”. Here is a way describe it: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} x& \ra{ \text{ right } k}& x+k=y. \end{array}$$ Of course, $k=0$ means that there is no change. This is a function: $$y=f(x)=x+k.$$

Next, what kind of motion is this: $$y=-x?$$ We plot the arrows:

To understand what is happening, we can imagine that we grab the $x$-axis with at two spots with two hands and then bring those two points to the assigned locations on the $y$-axis. We can almost see how the $x$-axis is rotated into the $y$-axis! This is a different kind of transformation, a flip. We lift, then flip the pencil with $x$-axis on it, and place next to another such pencil. This flip is shown below:

This is the algebraic interpretation: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} x& \ra{ \text{ flip } }& -x. \end{array}$$

The transformations that don't distort the line are called motions. Then, motions are the left shift and the right shift (the magnitude may vary) and the flip (the center may vary).

Let's consider something else, how about a fold (not a motion anymore)? The axis isn't on a pencil anymore! It is a piece of wire:

We also approach these issue from the opposite direction: instead of asking what transformation this function represents, we ask what function represents this transformation? From the arrow diagram on right, we conclude that half of the $x$-axis flips and the other stays put. What is this? A function with ${\bf R}$ as the domain and $[0,+\infty)$ as the range? This is the absolute value function, $y=|x|$!

A new type of transformation is a stretch. The line isn't on a pencil or a wire anymore! It is a rubber string (with knots to mark locations):

We grab it by the ends and pull them apart in such a way that the origin doesn't move. For example, a stretch by a factor of $2$ is shown below:

We, once again, can imagine that we grab the $x$-axis at two spots and bring them to the assigned locations on the $y$-axis. This is indeed a uniform stretch because the distance between any two points doubles.

Exercise. What does $f(x)=-2x$ do to the $x$-axis?

Generally,

• when the line is stretched by a factor $k>1$, point $x$ becomes $x\cdot k$.

In the meantime, what about a shrink? We have:

• when the line is shrunk by a factor $k>1$, point $x$ becomes $x/k$.

Of course, in order to combine the two statements, we should allow $k$ to be less than $1$. Then we can interpret the former statement to include the latter if we understand “stretched by a factor $k$” as “shrunk by a factor $1/k$”. Here is a way describe it ($k>0$): $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} x& \ra{ \text{ stretch by } k}& x\cdot k. \end{array}$$ Of course, $k=1$ means that there is no change. This is the new kind of function we have discovered: $$y=f(x)=x\cdot k.$$

Exercise. What is the meaning of $|m|$ in the transformation given by $f(x)=mx+b$?

Exercise. What is the meaning of $b$ in the transformation given by $f(x)=mx+b$?

Example (coloring). We will often color the numbers according to their values. This is the summary of the functions we have considered:

We also plot the graphs of these functions below:

$\square$

A very simple, but important, class of function is the constant functions, $f(x)=k$. What does this function do to the $x$-axis? There is only one output:

The real line is shrunk to a single point; we can call this transformation collapse.

It is, however, more typical to have a non-uniform stretching throughout the domain of a function because it is likely to be non-linear.

Example (list). Let's consider this function given by its values: $$\begin{array}{l|lllll} x&0&1&2&3&4&5&6&7&8&9&10\\ \hline y&0&2&5&7&8&8.5&8.5&8&7&4&2\\ \end{array}$$ We then assume that the function continues between these values in a linear fashion: the $1$-unit segments on the $x$-axis are stretched and shrunk at different rates, and the ones beyond $x=6$ are also flipped over:

We also plot the graph of this function on right. So, at its simplest, a non-linear function is a combination of linear patches. $\square$

Exercise. Represent the following function given by its values as a transformation: $$\begin{array}{l|lllll} x&0&1&2&3&4&5&6&7&8&9&10\\ \hline y&6&5&4&3&3&3&4&5&6&6&6\\ \end{array}$$

Exercise. Make up your own function by its values and then represent it as a transformation. Repeat.

Example (fixed point). The stretch/shrink rates can also change continuously. To illustrate these basic transformations, we can also use a color representation of the real line. We can color locations at random; this is a combination of -- location dependent -- shifting, stretching, and shrinking:

Among all this complexity, the point marked with star is fixed. $\square$

Exercise. Sketch the graph of the function that represents the above transformation.

Example (graphs). The most common way to visualize a function remains its graph. The picture below shows how the two approaches come together. The transformation of the domain into the codomain performed by the function can be seen in what happens to its graph:

First, we take the $x$-axis as if it is a (colored) rope and lift it vertically (with some inevitable stretching) to the graph of the function and, second, we push it horizontally to the $y$-axis (practically, we shrink the image horizontally). At the end, we can see what has happened by considering what happens to these three intervals: stretching at the ends and shrinking in the middle. The transformation in the next example does more:

There is also a flip in the middle with a fold. $\square$

Exercise. Draw your own graph and then interpret the function as a transformation. Repeat.

Example (discontinuity). In general, a transformation can tear this rope:

We, however, will want to know when this happens. The issue of “continuity” is addressed in Chapter 6. $\square$

Exercise. Provide the graph of a function (a transformation) that tears this rope and then (a) pulls the two halves apart, (b) overlaps their ends.

Example (sign function). The sign function collapses the $x$-axis to three different points on the $y$-axis:

$\square$

Exercise. What does the integer value function $y=[x]$ do to the $x$-axis?

## 4 Functions with regularities: one-to-one and onto

We go back to functions that assign to each boy a ball to play with. In order for this to be a function, the table of this relation must have exactly one mark in each row:

It does but if we further study this function, we might notice two different but related “irregularities”.

First, no-one seems to like baseball! There is no arrow ending at the baseball and its column has no marks.

Let's modify the function slightly: Ken changes his preference from football to baseball. Then, there is an arrow for each ball and all columns in the table have marks.

In the graph, there is a dot corresponding to each horizontal line.

Definition. A function $F:X\to Y$ is called onto when there is an $x$ for each $y$ with $F(x)=y$.

The opposite is the sign that a potential output is “wasted”; some $y$ belongs to the codomain but not the image (the range of values).

Below, the reason for this terminology is explained:

We start with an element of $X$ and bring it -- along the arrow -- to the corresponding element of $Y$. The function is onto if all elements of $Y$ are covered.

Second, both Tom and Ben prefer basketball! The two arrows converge on the basketball and we can also see that its column has two marks. We note the same about the football.

The above function is modified: Tom and Ben have left. Then, no two arrows converge on one ball and no column has more than one mark.

In the graph, there can be only one, or none, dot corresponding to each horizontal line.

Definition. A function $F:X\to Y$ is called one-to-one when there is at most one $x$ for each $y$ with $F(x)=y$.

Below, the reason for this terminology is explained:

We start with an element of $X$ and bring it -- along the arrow -- to the corresponding element of $Y$. The function is one-to-one if every element of $Y$ is covered only once, if at all.

In summary, the two concepts are not about how many arrows originate from each $x$ -- it's always one -- but about how many arrows arrive at each $y$.

Now numerical functions. These functions are represented by their transformations and by their graphs. These two concepts will reveal whether the function is a kind we have discussed. We will assume below that

• the codomain the set of all reals ${\bf R}$.

We imagine that the $x$-axis, $X$, is transformed somehow and then placed on top of the $y$-axis, $Y$:

• onto: does $X$ cover the whole $Y$?
• one-to-one: does $X$ cover any location on $Y$ more than once?

Example (transformations). Let's consider the transformations from the last section. Their descriptions -- and illustrations -- tell the whole story. The left and right shifts, the flip, stretch, and the shrink -- are all both one-to-one and onto:

It is crucial though that the axes are infinite... What would make a transformation of an interval in the real line to be not one-to-one? Any folding present a visible problem:

And so does collapsing:

$\square$

Example (graphs). What about graphs? Let's start with this case: the domain is the reals $X={\bf R}=(-\infty, +\infty)$, while the codomain is the non-negative reals, $Y=[0,\infty)$. If the graph of a function $f:X\to Y$ is given, can we determine whether this function is one-to-one or onto by just examining the graph? The idea is to “sample” the function and see how the arrows behave:

If we notice that

• the arrows in the first row seem to cover the whole $Y$, while
• the arrows in the first column seem not to cover any location on $Y$ twice.

We conclude that these functions are onto and one-to-one, respectively. We make this conclusions with the understanding that they are based on the partial information provided by the graph. The case for not onto and not one-to-one is better; we can definitely see and mark with circles the following:

• the arrows in the second row missing a specific value in $Y$, and
• the arrows in the second column arriving to the same specific location.

$\square$

Exercise. How are the conclusions in the above example affected by different choices of (a) codomains, (b) domains.

Example (powers). Suppose this time the domain and the codomain are the reals, $X=Y={\bf R}$. Then the function $f(x)=x^{2}$ is not onto but $g(x)=x^{3}$ is. It is easy to prove the former: $$x^2\ne -1.$$ To prove the latter will require some algebra.

$\square$

Exercise. How can we “make” (a) $x^{2}$ or (b) $|x|$ onto?

What makes a difference? The graph doesn't progress below a certain line! The following is a useful observation:

• a function is onto if and only if its graph and any horizontal line have at least one point in common.

Example (powers). The function $f(x)=x^{2}$ is not one-to-one but $g(x)=x^{3}$ is. It is easy to prove the former: $$1^2=(-1)^2=1.$$ To prove the latter will require some algebra.

$\square$

Exercise. How can we “make” (a) $x^{2}$ or (b) $|x|$ one-to-one?

What makes a difference? Two points on the graph have the same height above the $x$-axis! The following is a useful observation:

• function is one-to-one if and only if the intersection of its graph and any horizontal line contains at most one point.

Notice the connection with the Vertical Line Test (is this a function?) from the Chapter 2:

Example (quadratic). Quadratic polynomials, $$F(x)=ax^2+bx+c,\ a\ne 0,$$ are neither one-to-one nor onto.

It will be proven in this chapter. $\square$

Exercise. Identify and classify the functions below:

Exercise. Function $y=f(x)$ is given below by a list of some of its values. Add missing values in such a way that the function is one-to-one. $$\begin{array}{r|l|l|l|l|l}x&-1 &0 &1 &2 &3 &4 &5\\ \hline y=f(x)&-1 & &4 &5 & &2 \end{array}$$

Exercise. What codomain of the function given above should we assume to assure that it is onto?

We summarize the results in the following important theorem.

THEOREM (Horizontal Line Test).

• (1) A function is onto if and only if its graph and any horizontal line have at least one point in common.
• (2) A function is one-to-one if and only if its graph and any horizontal line have at most one point in common.

In light of the theorem, we redo the table presented earlier by counting the number of intersections of horizontal lines with the graph:

In each cell of the table, we see an example of how -- in a simplest possible way -- these two conditions can be violated, for a numerical function.

Exercise. Illustrate each of the four possibilities above with a choice of a function given a list of values.

Linear functions are easy to characterize this way:

Indeed, as we know from geometry, two lines have exactly one intersection unless they are parallel; therefore the Horizontal Line Test is passed by all linear functions except the ones with zero slope. Those are constant functions.

However, we need to prove these facts algebraically.

Example (linear). Suppose we have a linear function with slope $3$ and $y$-intercept $2$, $$F(x)=3x+2.$$ Is it one-to-one? Suppose we have two inputs $x_1$ and $x_2$, can their outputs be equal under $F$? Let's try: suppose $F(x_1)=F(x_2)$. We substitute and obtain the following: $$3x_1+2=3x_2+2.$$ Cancelling $2$ produces the following: $$3x_1=3x_2.$$ Finally we divide by $3$: $$x_1=x_2.$$ No, the outputs are equal only when the inputs are!

Is it onto? Suppose we have an input $y$, is there an $x$ taken to $y$ under $F$? We just need to solve the equation $F(x)=y$ for $x$ for each $y$. In other words, we have an equation with an unspecified $y$: $$3x+2=y.$$ No matter what $y$ is, we subtract $2$ and then divide by $3$ producing: $$x=\frac{y-2}{3}.$$ Yes, there is such an $x$, for each $y$! $\square$

THEOREM (Linear functions). A linear function with slope $m$ and $y$-intercept $b$, $$F(x)=mx+b,$$ is both one-to-one and onto as long as $m\ne 0$.

Proof. One-to-one. Suppose we have two inputs $x_1$ and $x_2$. Then: $$F(x_1)=F(x_2)\ \Longrightarrow\ mx_1+b=mx_2+b\ \Longrightarrow\ mx_1=mx_2\ \Longrightarrow\ x_1=x_2.$$ It's the same input.

Onto. Suppose we have an input $y$. We solve the equation $F(x)=y$ for $x$: $$mx+b=y\ \Longrightarrow\ x=\frac{y-b}{m}.$$ There is such an $x$. $\blacksquare$

The picture confirms the conclusion:

Exercise. Prove algebraically that $f(x)=1/x$ is one-to-one but not onto.

Exercise. Classify the function $f(x)=x^3-x$ according to these two definitions. Prove algebraically.

THEOREM. (a) A function $F:X\to Y$ is onto if and only if its image is the whole codomain, $Y$. (b) A function $F:X\to Y$ is on-to-one if and only if the pre-image of every element of the codomain $Y$ is a single element of the domain, $X$.

Exercise. Prove the theorem.

To summarize, the restrictions in these definitions can be violated when there are too few or too many arrows arriving to a given $y$. These violations are seen in the co-domain. This one is not onto:

That one is not one-to-one:

Example (both). What functions are the most “regular”? The ones that are both one-to-one and onto, sometimes called bijections:

They may look plain but they have an interesting feature: the boys and the balls can be used as substitutes of each other! For example, you don't have to remember the name of every boy but just say “the one that plays basketball” to identify Tom without a chance of confusion... $\square$

Exercise. What are the smallest set $X$ and the smallest set $Y$ for which a function $F:X\to Y$ can be not one-to-one, not onto?

Exercise. Sketch the graph of the function $f$ given by its list of values below. Is it one-to-one? $$\begin{array}{r|ll} x&1&2&3&4&5\\ \hline y=f(x)&1&2&0&3&1 \end{array}$$

Exercise. Make up your own functions by providing their lists of values and test the two definitions. Repeat.

Example (power functions). All power functions, $$y=x^n,\ n=...,-3,-2,-1,0,1,2,3,...,$$ can now be classified:

$\square$

Exercise. Which ones are onto?

Exercise. What is the relation between being one-to-one and having a mirror symmetry?

Exercise. What kind of function is “many-to-one”? What about “one-to-many”?

## 5 Compositions of functions

Back in our boys-and-balls example, let's note the colors of the balls. This has nothing to do with the boys and it creates a new function:

It is a function $G:Y\to Z$ from the set of all balls to the new set $Z$ of the main colors. (Note that the new function is one-to-one but not onto.)

Since we also know the boys' preferences in balls, we can answer the question about their preferences in colors! We just need to combine the new function with the old:

If we start with a boy on the left, we can continue with the arrows all the way to the right. This way, we will know the color of the ball the boy is playing with:

This is a new function, say $H:X\to Z$, from the set of boys to the set $Z$ of the main colors:

(Note that the new function is neither one-to-one nor onto.)

In general, this is the setup: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} X& \ra{ F }& Y & \ra{ G }& Z. \end{array}$$ How do we get from $X$ to $Z$?

Definition. Given two functions (with the codomain of the former matching the domain of the latter), $$F:X\to Y \text{ and } G:Y\to Z,$$ their composition is the function (from the domain of the former to the codomain of the latter) $$H:X\to Z,$$ denoted by: $$G\circ F,$$ which is computed for every $x$ in $X$ according to the following two-step procedure: $$x\mapsto F(x)=y \mapsto G(y)=z;$$ i.e., the new function is given by the substitution formula: $$z=H(x)=G(F(x)).$$

We just follow from $X$ along the arrows of $F$ to $Y$ and then along the arrows of $G$ to $Z$:

This is the “deconstruction” of the notation: $$\begin{array}{lll} &&\text{names of the second and first functions}\\ &&\downarrow\qquad\downarrow\\ \big(\ G\circ F\ \big)\ (x)&=&G \big(\quad F\ (x)\quad\big)\ .\\ \qquad\uparrow&&\qquad\uparrow\quad\uparrow\quad\uparrow\\ \text{name of the new function}&&\quad\text{substitution} \end{array}$$

If we represent the two functions as diagrams of black boxes, we wire them together: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccc} \text{input} & & \text{function} & & \text{output} \\ x & \mapsto & \begin{array}{|c|}\hline\quad F \quad \\ \hline\end{array} & \mapsto & y\\ &&&&\downarrow\\ &&&&\text{input} & & \text{function} & & \text{output} \\ &&&&y & \mapsto & \begin{array}{|c|}\hline\quad G \quad \\ \hline\end{array} & \mapsto & z&.\\ \end{array}$$ So, we use the output of the former as the input of the latter.

To make it clear that $Y$ is no longer a part of the picture, we can also visualize the composition as follows: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} X& \ra{ F }& Y \\ &\searrow^H& \da{ G }\\ && Z. \end{array}$$ The meaning of the diagram is as follows: whether we follow $F$-then-$G$ route or the direct $H$ route, the results will be the same.

If we think of functions as lists of instructions, we just attach the list of the latter at the bottom of the list of the former. In other words, here is the list of $G\circ F$:

• step 1: do $F$,
• step 2: do $G$.

They are executed consecutively: you can't start with the second until you are done with the first.

Let's test that on running example. We take the two lists of values and then cross-reference them (from left to right): $$\begin{array}{lll} F(\text{ Tom })&=\text{ basketball },\\ F(\text{ Ned })&=\text{ tennis },\\ F(\text{ Ben })&=\text{ basketball },\\ F(\text{ Ken })&=\text{ football },\\ F(\text{ Sid })&=\text{ football };\\ \end{array}\qquad\begin{array}{lll} G(\text{ basketball })&=\text{ orange },\\ G(\text{ tennis })&=\text{ yellow },\\ G(\text{ football })&=\text{ brown },\\ G(\text{ baseball })&=\text{ white }.\\ \end{array}$$ We ignore any alignment between the two lists. We take the first entry in the second list, $$G(\text{ basketball })=\text{ orange },$$ and replace “basketball”, according to the first entry of the first list, with $F(\text{ Tom })$. This is the result: $$G(\ F(\text{ Tom })\ )=\text{ orange }.$$ Therefore, $$H(\text{ Tom })=\text{ orange }.$$ This is the first entry in the new list...

Exercise. Finish the list.

Once again, algebraically, composition is nothing but substitution!

Example (numerical functions). This substitution is just as simple for numerical functions. For example,

• $y=x^2$ is substituted into $z=y^3$ resulting in $z=\big(x^2\big)^3$.

The idea remains the same: insert the input value in all of these boxes. For example, this function on the left is understood and evaluated via the diagram on the right: $$f\left(y \right)=\frac{2y^2-3y+7}{y^3+2y+1},\quad f\left( \square \right)=\frac{2\square^2-3\square+7}{\square^3+2\square+1}.$$ In Chapter 2, we inserted $3$ at each of these windows: $$f\left( \begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array} \right)=\frac{2\begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array}^2-3\begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array}+7}{\begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array}^3+2\begin{array}{|c|}\hline\ 3 \ \\ \hline\end{array}+1}.$$ This was the substitution $y=3$. This time, let's insert $\sin x$, or, better, $(\sin x)$. This is the substitution $y=\sin x$: $$f \begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array} =\frac{2\begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array}^2-3\begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array}+7}{\begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array}^3+2\begin{array}{|c|}\hline\ (\sin x) \ \\ \hline\end{array}+1}.$$ Then, we have $$f\left(\sin x \right)=\frac{2(\sin x)^2-3(\sin x)+7}{(\sin x)^3+2(\sin x)+1}.$$ Note that if you don't know what $\sin$ does, it makes no difference! The only thing that matters is that we know that this is a function. $\square$

Example (tables). Next, what about representing functions by their tables? These are the tables of $F$ and $G$ above:

How do we combine them to find $H$? The alignment we might see is meaningless. We need to align what the two have in common, $Y$. Then we start with an $x$ in $X$, use $F$ to find the corresponding value of $y$ in $Y$, then use $G$ to find the corresponding value of $z$ (one such step is illustrated below):

$\square$

Example (graphs). What if we have only their graphs? Suppose we have the two graphs of $$u=f(x)\ \text{ and }\ y=g(y),$$ side by side and we need to find the composition, $g\circ f$. Let's take a single value: $$d=g(f(a)).$$ Then, we use the first graph to find $c=f(a)$ on the vertical axis, then travel all the way to the horizontal axis of the second, find the corresponding $c$ on it, and finally find $d=g(c)$ on the vertical axis.

Graphs don't do a very good job visualizing compositions... Alternatively, we match the output axis, $u$, of the first function with the input axis, $u$, of the second:

It's still quite complicated! $\square$

Example (transformations). What if we, instead, think of numerical functions as transformations? For example, consider this:

• if the first transformation is a stretch by a factor of $2$, and
• the second transformation is a stretch by a factor of $3$, then
• the composition of the two transformations is a stretch by a factor of $3\cdot 2=6$:

So, we just carry out two transformations in a row. Consider also this:

• if the first transformation is a shift (right) by a $3$, and
• the second transformation is a stretch by a flip, and
• the third transformation is a shift (right) by a $5$, then
• the composition does the following:

$\square$

Exercise. Illustrate, as above, the composition of: the shift left by $5$, stretch by $2$, and a flip.

Exercise. Illustrate -- as a transformation -- the composition of the two functions shown below:

If we think of functions as lists of instructions, then each of them is already a composition! The steps on the list are the functions the composition of which creates the function. For example,

• $F$: add $3$, multiply by $-2$, subtract $1$.

This is called a decomposition of $F$. If, furthermore, there is another function, say,

• $G$: subtract $2$, apply $\sin$,

we just add the latter list to the bottom of the former:

• $G\circ F$: add $3$, multiply by $-2$, subtract $1$, subtract $2$, apply $\sin$.

Of course, we can have compositions of many functions in a row as long the output of each function matches the input of the next.

It's as if the first function gives us direction to a destination and at that destination we receive the directions to our next destination. At that location, we get further directions, and so on...

We represent functions as black boxes that process the input and produce the output: $$\begin{array}{ccc} \text{input} & & \text{function} & & \text{output} \\ x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y\\ &&&&\text{input} & & \text{function} & & \text{output} \\ &&&&y & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & z\\ &&&&&&&&\text{input} & & \text{function} & & \text{output} \\ &&&&&&&&z & \mapsto & \begin{array}{|c|}\hline\quad h \quad \\ \hline\end{array} & \mapsto & u&. \end{array}$$ Because of the match, we can carry over the output to the next line -- as the input of the next function.

This chain of events can be as long as we like: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccc} x_1 & \mapsto & \begin{array}{|c|}\hline f_1 \\ \hline\end{array} & \mapsto & x_2& \mapsto & \begin{array}{|c|}\hline f_2 \\ \hline\end{array} & \mapsto & x_3& \mapsto & \begin{array}{|c|}\hline f_3 \\ \hline\end{array} & \mapsto & x_4&\mapsto& \begin{array}{|c|}\hline f_4 \\ \hline\end{array} & \mapsto & x_5&\mapsto&...\\ \end{array}$$

Example (flowchart). Such a decomposition will allow us to study the function one piece at a time:

$\square$

Exercise. Represent the following function by a single formula: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\ \text{multiply by }2 \ \\ \hline\end{array} & \mapsto & y& \mapsto & \begin{array}{|c|}\hline\ \text{add }5 \ \\ \hline\end{array} & \mapsto & z& \mapsto & \begin{array}{|c|}\hline\ \text{divide by }3 \ \\ \hline\end{array} & \mapsto & u\ .\\ \end{array}$$

Exercise. Represent the function $h(x)=(x-1)^2+(x-1)^3$ as the composition $g\circ f$ of two functions $y=f(x)$ and $z=g(y)$.

Example (spreadsheet). This is how the composition of several functions represented by formulas is computed with a spreadsheet. We start with just a list of numbers in the first column. Then we produce the values in the next column one row at a time. How? We input a formula in the next column with a reference to the last one. For example, we have in the second and third columns respectively: $$\texttt{=RC[-1]*2},\quad \texttt{=RC[-1]+5}\ .$$ Each of the two consecutive columns is a list of values of a function, left:

If we hide the middle column, we have the list of values of the composition. We can have as many columns as we like. $\square$

Example (lists). What if the functions are given by nothing but their lists of values? Then we need find a match for the output of the first function among the inputs of the second. Given the tables of values of $f, g$, find the table of values of $f \circ g$: $$\begin{array}{l|ll} x&y=g(x)\\ \hline 0&1\\ 1&0\\ 2&2\\ 3&4\\ 4&2 \end{array}\qquad\circ\qquad \begin{array}{l|ll} y&z=g(y)\\ \hline 0&0\\ 1&3\\ 2&5\\ 3&1\\ 4&2 \end{array}\qquad = \qquad \begin{array}{l|ll} x&z=f(g(x))\\ \hline 0&?\\ 1&?\\ 2&?\\ 3&?\\ 4&? \end{array}$$ We need to fill the second column of the last table. First, we need to match the outputs of $f$ with the inputs of $g$.

Alternatively, we simply re-arrange the rows of $g$ according to the values of $y$ and then just remove the $y$-columns: $$\begin{array}{l|ll} x&y\\ \hline 0&1 \\ 1&0\\ 2&2\\ 3&4\\ 4&2 \end{array} \begin{array}{l|ll} y&z\\ \hline 1&3\\ 0&0\\ 2&5\\ 4&2\\ 2&5 \end{array}\quad\leadsto\quad\begin{array}{l|ll} x&z\\ \hline 0&3 \\ 1&0\\ 2&5\\ 3&2\\ 4&5 \end{array}$$ $\square$

Exercise. Given the tables of values of $f, g$, find the table of values of $f \circ g$: $$\begin{array}{l|ll} x&y=g(x)\\ \hline 0&0\\ 1&4\\ 2&3\\ 3&0\\ 4&1 \end{array}\qquad\circ\qquad \begin{array}{l|ll} y&z=g(y)\\ \hline 0&4\\ 1&4\\ 2&0\\ 3&1\\ 4&2 \end{array}\quad = \quad ?$$

For example, the search may be executed with this formula: $$\texttt{=VLOOKUP(RC[-6],R3C[-4]:R18C[-3],2)}.$$ $\square$

Example (bad substitution). You may encounter problems stated as follows:

• “Find the composition $f \circ g$ of the functions:

$$f(x) = \frac{x}{1 + x},\quad g(x) = \sin x.”$$ Since both function have the same input variable, it might be unclear how to substitute! Let's sort this out.

The flowchart of the composition $f \circ g$ is: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & z &. \end{array}$$ This means that, in order to make the output of the first to match the input of the second, we had to rename the variables: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad \sin x \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad \dfrac{y}{1 + y} \quad \\ \hline\end{array} & \mapsto & z &. \end{array}$$ This is the new version of the problem:

• “Find the composition, $f \circ g$, of the functions:

$$f(y) = \frac{y}{1 + y},\quad y=g(x) = \sin x.”$$ Now we substitute $$y = \sin x\ \text{ into }\ f(y)=\frac{y}{1 + y},$$ as follows: $$\begin{array} {lll} (f \circ g )( x ) & = f(g(x)) = f(y) \\ & = \dfrac{y}{1 + y } \\ & = \dfrac{\sin x}{1 + \sin x} . \end{array}$$

As an exercise, let's do the reverse:

• “Find the composition, $g \circ f$, of the functions:

$$y=f(x) = \frac{x}{1 + x},\quad g(y) = \sin y.”$$ The flowchart of the composition $g \circ f$: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & z &. \end{array}$$ Once again, we had to rename the variables: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad \dfrac{x}{1 + x} \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad \sin y \quad \\ \hline\end{array} & \mapsto & z &. \end{array}$$ Now we substitute $$y=\frac{x}{1 + x}\ \text{ into }\ g(y)=\sin y,$$ as follows: \begin{aligned} (g \circ f )( x ) & = g(f(x)) = g(y) \\ & = \sin\left( \frac{x}{1 + x }\right) . \end{aligned} $\square$

Exercise. Represent the function $h(x)=2\sin^3x+\sin x+5$ as the composition of two functions one of which is trigonometric. Hint: it doesn't matter what $\sin$ does.

Exercise. (a) Represent the function $h(x)=\sqrt{x-1}$ as the composition of two functions. (b) Represent the function $k(t)=\sqrt{t^2-1}$ as the composition of three functions. (c) Represent the function $p(t)=\sin\left(\sqrt{t^2-1}\right)$ as the composition of four functions.

Exercise. Functions $y=f(x)$ and $u=g(y)$ are given below by tables of some of their values. Present the composition $u=h(x)$ of these functions by a similar table: $$\begin{array}{r|c|c|c|c} x &0 &1 &2 &3 &4 \\ \hline y=f(x) &1 &1 &2 &0 &2 \end{array}$$ $$\begin{array}{c|c|c|c|c} y &0 &1 &2 &3 &4 \\ \hline u=g(y) &3 &1 &2 &1 &0 \end{array}$$

Exercise. Represent the composition of these two functions: $f(x)=1/x$ and $g(y)=\frac{y}{y^2-3}$, as a single function $h$ of variable $x$. Don't simplify.

Exercise. Function $y=f(x)$ is given below by a list of its values. Is the function one-to-one? $$\begin{array}{r|l|l|l|l|l}x&0 &1 &2 &3 &4 \\ \hline y=f(x)&0 &1 &2 &1 &2 \end{array}$$

## 6 The inverse of a function

Our main example of a function answers the question: which ball is this boy playing with?

What if we turn this around: which boy is playing with this ball?

The solution would seem to be a simple reversal of the arrows:

We can see that, even though the latter question is asked about the same situation as the former, it cannot be answered in a positive manner! Indeed:

• there is no boy playing with the baseball -- no answer.

This mean that there is no function this time!

All functions from $X$ to $Y$ are also relations between $X$ and $Y$. However, not every relation is a function -- either from $X$ to $Y$ or from $Y$ to $X$. The reasons are the same: too many or too few arrows starting at the domain set.

An especially important question is, can we reverse the arrows of a function so that that same relation is now seen as a new, “inverse”, function? The answer is No for all of the example. Why not?

• First, some $y$'s in $Y$ have no corresponding $x$'s in $X$. In other words, the function isn't onto!
• Second, some $y$'s in $Y$ have two or more corresponding $x$'s in $X$. In other words, the function isn't one-to-one!

So, the original function lacked either of the two types of regularity for this to be possible.

What kind of function would make this possible? A function that is both one-to-one and onto:

We have added an extra ball (soccer) and redrew the arrows: there is exactly one arrow for each ball. This is a very simple, almost uninteresting, kind of function. Indeed, each boy holds a ball and every ball is held by a boy. The difference is only in the name... Indeed, if you don't remember Tom's name, you just say “the boy who plays with a basketball”. Or, if you don't remember what that red ball is for, you just say “the game Sid plays". There is no ambiguity in this substitution.

Definition. Suppose $F:X\to Y$ is a function. A function $G:Y\to X$ is called the inverse of $F$ when $$F(x)=y\ \text{ if and only if }\ G(y)=x,$$ i.e., $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\la}[1]{\!\!\!\!\!\xleftarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} x& \ra{ F }& y&\Longleftrightarrow& y& \ra{ G }& x&.\\ \end{array}$$

THEOREM. A function is both one-to-one and onto if and only if it has an inverse.

Exercise. Prove the theorem.

Under this condition, the arrows can be safely reversed:

THEOREM. There is only one inverse for a function.

This justifies using “the inverse”.

Exercise. Prove the theorem.

The inverse of a function $F$ is denoted by: $$F^{-1}.$$ It is read “$F$ inverse”. Here “$F$” is the name of the old function and “$F^{-1}$” is the name of the new function.

Warning: the notation is not to be confused with the power notation for the reciprocal: $2^{-1}=\frac{1}{2}$. (Warning inside a warning: the inverse of multiplication is division.)

An idea to hold on to is that a function and its inverse represent the same relation between sets $X$ and $Y$:

• $x$ and $y$ are related when $y=F(x)$, or
• $x$ and $y$ are related when $x=F^{-1}(y)$.

The choice between $F$ and $F^{-1}$ is the choice the “roles” for $X$ and $Y$, input or output, domain or codomain.

Exercise. Explain the picture below:

What does this have to do with compositions? They allow us to make the informal idea of “reversing the arrows” fully precise.

Notice that the domain of the new function would have to be the codomain of the original! Their composition then makes sense:

We have made -- through this composition -- a full circle from boys to balls and back to boys. Every time, we arrive to our starting point, a boy.

There is another way to build a composition though!

We have made -- through that composition -- a full circle from balls to boys and back to balls. Every time, we arrive to our starting point, a ball.

Here is a flowchart representation of this idea: $$\begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad F \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad G \quad \\ \hline\end{array} & \mapsto & x &,\text{ same }x!\\ y & \mapsto & \begin{array}{|c|}\hline\quad G \quad \\ \hline\end{array} & \mapsto & x & \mapsto & \begin{array}{|c|}\hline\quad F \quad \\ \hline\end{array} & \mapsto & y &,\text{ same }y! \end{array}$$ We feed the output of $F$ into $G$ and vice versa.

THEOREM. Suppose $F:X\to Y$ is a function that is both one-to-one and onto. Then a function $G:Y\to X$ is the inverse of $F$ if

• $G(F(x))=x$ for all $x$, and
• $F(G(y))=y$ for all $y$.

Exercise. Prove the theorem.

The two identities in the theorem take the following form: $$(F^{-1}\circ F)(x)=x \text{ and }(F\circ F^{-1})(y)=y.$$ Making circles in the diagram below won't change the value of $x$ or $y$: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\la}[1]{\!\!\!\!\!\xleftarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} x& \ra{ F }& y\\ \uparrow& & \downarrow\\ x& \la{ F^{-1} }& y\\ \end{array}$$

Definition. A function that is both one-to-one and onto is also called invertible.

Such a function creates a correspondence between the two sets that it's as if this is the same set...

Exercise. Complete the sentence: “The set of all invertible functions from $X$ to $Y$ is the _____________ of the set of one-to-one functions and the set of onto functions.”

Now, the numerical functions...

Example (transformations). What is the meaning of the inverse of a function when seen as a transformation of the line? It is a transformation what would reverse the effect of the original.

Just by examining these simple transformations, we discover the following:

• the inverse of the shift $s$ units to the right is the shift of $s$ units to the left;
• the inverse of the flip is another flip;
• the inverse of the stretch by $k$ is the shrink by $1/k$.

In fact, we realize that they pair up:

• the shift $s$ units to the right and the shift of $s$ units to the left are the inverses of each other;
• the flip is the inverse with itself;
• the stretch by $k$ and the shrink by $1/k$ are the inverses of each other.

When executed consecutively, the effect is nil. Algebraically: $$\begin{array}{l|lll} &f&\text{vs.}&f^{-1}\\ \hline \text{shift}&y=x+s&&x=y-s\\ \text{flip}&y=-x&&x=-y\\ \text{stretch}&y=x\cdot k &&x=y/k\\ \end{array}$$ What about the fold? It can't be undone as any two points that are brought together become indistinguishable... Any further transformations will produce the same output: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\la}[1]{\!\!\!\!\!\xleftarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} x=a& \\ &\searrow_F\\ &&y&\ra{ G? }&x\\ &\nearrow_F\\ x=b&\\ \end{array}$$ This function isn't one-to-one! $\square$

Example (lists). Suppose a function is given by its list of values: $$f=\begin{array}{|l|l|} x&y=f(x)\\ \hline 0&1\\ 1&0\\ 2&2\\ 3&1\\ 4&3\\ ...&... \end{array}\ =\ \begin{array}{|lll|} x&\to&y\\ \hline 0&\to&1\\ 1&\to&0\\ 2&\to&2\\ 3&\to&1\\ 4&\to&3\\ ...&...&... \end{array}.$$ The table is understood as if there are arrows going horizontally left to right. That is why “reversing the arrows” means interchanging the columns: $$f^{-1}=\begin{array}{|lll|} x&\to&y\\ \hline 0&\leftarrow&1\\ 1&\leftarrow&0\\ 2&\leftarrow&2\\ 3&\leftarrow&1\\ 4&\leftarrow&3\\ ...&...&... \end{array}\ =\ \begin{array}{|lll|} y&\to&x\\ \hline 1&\to&0\\ 0&\to&1\\ 2&\to&2\\ 1&\to&3\\ 3&\to&4\\ ...&...&... \end{array}\ =\ \begin{array}{|lll|} y&\to&x\\ \hline 0&\to&1\\ 1&\to&0\\ 1&\to&3\\ 2&\to&2\\ 3&\to&4\\ ...&...&... \end{array}\ =\ \begin{array}{|l|l|} y&x=f^{-1}(y)\\ \hline 0&1\\ 1&0\\ 1&3\\ 2&2\\ 3&4\\ ...&... \end{array}.$$ It may, or may not, become clear that the new function isn't a function! To make sure, it's a good idea to arrange the inputs in the increasing order. Then we clearly see the conflict: $f^{-1}(1)=0$ and $f^{-1}(1)=3$. The original function, $f$, wasn't one-to-one! $\square$

The general rule for finding the inverse of a function given by a formula follows from the definition:

• the inverse of $y=f(x)$ is found by solving this equation for $x$; i.e., $x=f^{-1}(y)$.

Example. To find the inverse of a linear polynomial $$f(x)=3x-7,$$ set and solve $$y=3x-7\ \Longrightarrow\ y+7=3x\ \Longrightarrow\ \frac{y+7}{3}=x.$$ Therefore, $$f^{-1}(y)=\frac{y+7}{3}.$$ If it is not known ahead of time if the function is one-to-one, this fact is established, automatically, as a part of the solution. For example, to find the inverse of the quadratic function $$f(x)=x^2,$$ set and solve $$y=x^2\ \Longrightarrow\ \pm\sqrt{y}=x.$$ The $\pm$ sign indicates that there are two solutions ($x>0$). The original function wasn't invertible! $\square$

A linear polynomial, $$f(x)=mx+b,$$ is one-to-one and onto whenever $m\ne 0$. Algebraically, we just solve the equation $y=mx+b$ for $x$. The algebraic result is below.

THEOREM (inverse of linear polynomial). The inverse of a linear polynomial $$f(x)=mx+b,\ m\ne 0,$$ is also a linear polynomial and its slope is the reciprocal of that of the original: $$f^{-1}(y)=\frac{1}{m}y-\frac{b}{m}.$$

So, the set of all linear polynomials is split into pairs: a steeper line and a shallower one ($2$ and $1/2$, $-2$ and $-1/2$, as well as $1$ with itself and $-1$ with itself):

Next, one can imagine how some new algebraic operations may have appeared. Some emerged as the abbreviations for repeated familiar operations; for example, repeated addition, $2 + 2 + 2 = 2 \cdot 3$, leads to a new operation: multiplication. Meanwhile, repeated multiplication, $2 \cdot 2 \cdot 2 \cdot 2 = 2^{4}$, leads to a new operation: exponent. But what about subtraction and division?

Example (subtraction). Suppose I know how to add. Problem: I have $\$5$, how much do I add to have$\$12$? Answer: $\$ 7$. How do I know? Solve the equation: $$5 + x = 12.$$ This equation leads to a new operation, subtraction:$x = 12 - 5$. Subtraction is the “inverse” of addition.$\square$Example (division). Suppose now I know to multiply. Problem: I have a few$2$-by-$4$s and I need a table$20$inches wide. How many do I need? Answer:$5$. How do I know? Solve the equation: $$4x = 20 .$$ This equation leads to a new operation, division:$x = \frac{20}{4}$. Division is the “inverse” of multiplication.$\square$Example (square root). I need a square table of area 25 square feet. What should be the width of the table? Solve the equation: $$x \cdot x = 25 \Longrightarrow x^{2} = 25 \Longrightarrow x = \sqrt{25} .$$ Thus, we have a new operation: square root. It is the “inverse” of the square.$\square$Example (cubic root). What is the side of a box given a volume of$8$cubic feet? Solve the equation: $$x^{3} = 8 \Longrightarrow x = \sqrt[3]{8}.$$ It is the “inverse” of the cubic power.$\square$Thus, solving equations requires us to undo some operations present in the equation: $$\begin{array}{rl} x+2=5& \Longrightarrow & (x+2)-2=5-2& \Longrightarrow &x=3;\\ 3x=6&\Longrightarrow & (3x)/3=6/3&\Longrightarrow &x=2;\\ x^2=4&\Longrightarrow & \sqrt{x^2}=\sqrt{4}& \Longrightarrow &x=\pm 2. \end{array}$$ But these are functions! And some functions undo the effect of others: • the addition of$2$is undone by the subtraction of$2$, and vice versa; • the multiplication by$3$is undone by the division by$3$, and vice versa; • the second power is undone by the square root (for$x\ge 0$), and vice versa. Each of these undoes the effect of its counterpart under substitution: • substituting$y=x+2$into$x=y-2$gives us$x=x$; • substituting$y=3x$into$x=\frac{1}{3}y$gives us$x=x$; • substituting$y=x^2$into$x=\sqrt{y}$gives us$x=x$, for$x,y\ge 0$. And vice versa! • substituting$x=y-2$into$y=x+2$gives us$y=y$; • substituting$x=\frac{1}{3}y$into$y=3x$gives us$y=y$; • substituting$x=\sqrt{y}$into$y=x^2$gives us$y=y$, for$x,y\ge 0$. As we know, it is more precise to say that they undo each other under composition: two numerical functions$y=f(x)$and$x=g(y)$are inverse of each other when for all$x$in the domain of$f$and for all$y$in the domain of$g$, we have: $$g(f(x))=x \quad\text{ and }\quad f(g(y))=y.$$ This is how they are written via substitutions: $$g(y)\Bigg|_{y=f(x)}=x \quad\text{ and }\quad f(x)\Bigg|_{x=g(y)}=y.$$ Thus, we have three pairs of inverse functions: $$\begin{array}{rl} f(x)=x+2& \text{ vs. }& f^{-1}(y)=y-2,\\ f(x)=3x&\text{ vs. }& f^{-1}(y)=\frac{1}{3}y,\\ f(x)=x^2&\text{ vs. }& f^{-1}(y)=\sqrt{y} \quad\text{ for }x,y\ge 0. \end{array}$$ Next, what is the relation between the graph of a function and the graph of its inverse? In other words, what do we do with the graph of$f$to get the graph$f^{-1}$? We don't really need to do anything. After all, a function and its inverse represent the same relation. Indeed, the graph of$f$illustrates how$y$depends on$x$... as well as how$x$depends on$y$. But the latter is what determines$f^{-1}$! So, there is no need for a new graph -- the graph of$f^{-1}$is the graph of$f$. The only problem is that the$x$- and$y$-axes point in the wrong directions. It's easy to fix. Example (points on the graph). Suppose we are transitioning from$f$to its inverse$f^{-1}$: $$f=\begin{array}{|l|l|} x&y=f(x)\\ \hline 2&5\\ 3&1\\ 8&7\\ ... \end{array}\quad \leadsto \quad f^{-1}=\begin{array}{|l|l|} y&x=f^{-1}(y)\\ \hline 5&2\\ 1&3\\ 7&8\\ ... \end{array}.$$ This makes us replace the points in the$xy$-plane with new points in the$yx$-plane: $$\begin{array}{ll} (2,5)&\leadsto&(5,2),\\ (3,1)&\leadsto&(1,3),\\ (8,7)&\leadsto&(7,8),\\ ...&&. \end{array}$$ The two coordinates are flipped. As a result, each point jumps across the diagonal line$y=x$, as shown below: So, every point$(x,y)$in the$xy$-plane corresponds to the point$(y,x)$in the$yx$-plane.$\square$Example (graph point by point). Suppose, again, a function is given only by its graph and we need to find the graph of the inverse$x = f^{-1}(y)$. This time we are to do this without any help. Start with choosing a few points on the graph. Each of them will just across the diagonal under this flip. How exactly? The general rule for plotting a counterpart of a point is: • from the point go perpendicular to the diagonal ($45$degrees) and then measure the same distance on the other side. In other words, we plot a line through our point with slope$-1$. However, we can choose the points more judiciously: choose ones with easy to find counterparts. First, points on the diagonal don't mode by the flip about the diagonal. Second, points on one of the axes jumps to the other axis with no need for measuring. Once all points are in place, finally, draw a curve that connects them.$\square$Example (flip graph). This can be done by hand. One grabs the piece of paper with the$xy$-axis and the graph of$y=f(x)$on it and flips it. We flip by grabbing the end of the$x$-axis with the right hand and grabbing the end of the$y$-axis with the left hand then interchanging them: We face the opposite side of the paper then, but the graph is still visible: the$x$-axis is now pointing up and the$y$-axis right, as intended.$\square$Example (fold graph). We can also fold: The shapes of the graphs are the same but they are mirror images of each other:$\square$Example (slope). This is what happens when we apply this flip to the graph of a linear function: Then, we can compare: $$\text{slope of }f\ = \frac{\text{rise}}{\text{run}}=\frac{A}{B}\ \text{ and }\ \text{slope of }f^{-1}\ = \frac{\text{rise}}{\text{run}}=\frac{B}{A}.$$ They are reciprocals!$\square$Example (image app). Such a transformation of the plane can be accomplished with image processing software by first rotating the image clockwise$90$degrees and then flipping it vertically: Suppose a function is given only by its graph. Find the graph of the inverse$x = f^{-1}(y)$.$\square$Furthermore, we only need the graph of the original function to be able to evaluate the inverse: Example (square and square root). This is a familiar pair of functions that undo each other: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccc} x & \mapsto & \begin{array}{|c|}\hline\quad \text{ square } \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad \text{ square root} \quad \\ \hline\end{array} & \mapsto & x \text{, same? } \end{array}$$ No, the diagram fails if we plug in$x=-2$: $$\begin{array}{ccc} -2 & \mapsto & \begin{array}{|c|}\hline\quad \text{ square } \quad \\ \hline\end{array} & \mapsto & 4 & \mapsto & \begin{array}{|c|}\hline\quad \text{ square root} \quad \\ \hline\end{array} & \mapsto & 2 \text{, not the same! } \end{array}$$ As we know, not all functions have inverses... However, we can make it work by restricting the domain and the codomain of the function. For example, the old function is$y = x^{2}$, with the domain and the codomain assumed to be$(-\infty, \infty)$. It simply doesn't have the inverse! The new function is$y = x^{2}$, with the domain and the codomain chosen to be$[0, \infty )$. Then it works: this function has the inverse: We have eliminated the second possibility: $$2^{2} = 4,\ (-2)^{2} = 4.$$$\square$THEOREM (Powers). (1) The odd powers are one-to-one; consequently, they are invertible. The even powers aren't one-to-one; consequently, they are not invertible. (2) The even powers with domains and codomains reduced to$[0,+\infty)$are one-to-one; consequently, they are invertible. Exercise. Can we reduce the domain to$(-\infty,0]$instead? Are there other options? Hint: bottom right. Example. Suppose a function is given only by its formula. Find the formula of the inverse$x = f^{-1}(y)$. For example, let $$f(x)=x^3-3.$$ We simply rewrite $$y=x^3-3,$$ and then solve for$x$: $$x=\sqrt[3]{y+3}.$$ Thus the answer is: $$f^{-1}(y)=\sqrt[3]{y+3}.$$$\square$Example. Plot the graph of the inverse of$y = f(x)$shown below: • Draw the diagonal$y = x$, • pick a few points on the graph of$f$(we choose four); • plot a corresponding point for each of them: • on the line through point$A$that is perpendicular to the diagonal (i.e., its slope is$45$degrees down), • on the other side of the diagonal from$A$, • same distance from the diagonal as$A$; • draw by hand a curve from point to point; • verify the answer with drawing software.$\square$Exercise. Function$y=f(x)$is given below by a list its values. Find its inverse and represent it by a similar table. $$\begin{array}{r|l|l|l}x &0 &1 &2 &3 &4 \\\hline y=f(x) &1 &2 &0 &4 &3 \end{array}$$ Exercise. What is the function that is its own inverse? Exercise. Plot the inverse of the function shown below, if possible. Exercise. Plot the graph of the inverse of this function: Exercise. Function$y=f(x)$is given below by a list of its values. Is the function one-to one? What about its inverse? $$\begin{array}{r|l|l|l|l|l}x&0 &1 &2 &3 &4 \\ \hline y=f(x)&7 &5 &3 &4 &6 \end{array}$$ Exercise. Plot the graph of the function$f(x)=\frac{1}{x-1}$and the graph of its inverse. Identify its important features. Exercise. Find the formulas of the inverses of the following functions: (a)$f(x)=(x+1)^3$, (b)$g(x)=\ln (x^3)$. Exercise. Sketch the graph of the inverse of the function below: ## 7 Transforming the axes transforms the plane First, a function is represented by its graph as a certain subset of the$xy$-plane. Second, a function is seen as a transformation of the real number line. Now, we discover two prominent number lines on the$xy$-plane: the$x$-axis and the$y$-axis! Suppose we have the graph of a function$f$. We then face the following two questions. • Question 1: What will happen to the graph of$f$if the$x$-axis is transformed by another function$g$? Answer: the graph will transform into that of$f\circ g$. • Question 2: What will happen to the graph of$f$if the$y$-axis is transformed by another function$h$? Answer: the graph will transform into that of$h\circ f$. The order, of course, matters: $$\begin{array}{ccc} t & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y \\ &&&&x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad h \quad \\ \hline\end{array} & \mapsto & z \end{array}$$ The graphs of functions are plotted on the Cartesian plane. We then start with a broader question: • how the transformations of the axes -- both horizontal and vertical -- affect the$xy$-plane? But first let's review what we know. These are the three transformations of an axis: shift, flip, and stretch: What are the basic transformations of the$x$-axis? It is oriented horizontally on the$xy$-plane. Then, we have a horizontal shift: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} t& \ra{ \text{ shift by } k}& x=g(t)=t+k; \end{array}$$ a horizontal flip: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} t& \ra{ \text{ flip } }& x=g(t)=-t; \end{array}$$ and a horizontal stretch: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} t& \ra{ \text{ stretch by } k}& x=g(t)=t\cdot k. \end{array}$$ What about the$y$-axis? It is oriented vertically on the$xy$-plane. Then, we have a vertical shift: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} y& \ra{ \text{ shift by } k}& z=h(y)=y+k; \end{array}$$ a vertical flip: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} y& \ra{ \text{ flip } }& z=h(y)=-y; \end{array}$$ and a vertical stretch: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} y& \ra{ \text{ stretch by } k}& z=h(y)=y\cdot k. \end{array}$$ Now, transforming the axes transforms -- in the same manner -- all the lines on the plane parallel to it. The result is this set of transformations familiar from using a graphics editor: What remains is to see how the above algebra of the real line creates a new algebra of the Cartesian plane. We start with a vertical shift. We shift the whole$xy$-plane as if it is printed on a sheet of paper. Furthermore, there is another sheet of paper underneath used for reference. It is on the second sheet that we see the resulting points. We then use its coordinate system to record the coordinates of the new point. For example, a shift of$3$units upward is shown below: So, all vertical lines are shifted up by$k$. Then, the whole plane is shifted$k>0$units up. A generic point$(x,y)$makes a step up/down by$k$and becomes$(x,y+k)$. This is another algebraic way to present the transformation: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} (x,y)& \ra{ \text{ up } k}& (x,y+k). \end{array}$$ It is as if the algebra of the flip of the$y$-axis given previously,$y\to y+k$, is copied and paired with$x$. Exercise. What is the effect of two vertical stretches executed consecutively? What about the horizontal shift? For example, a shift of$2$units right is shown below: So, all horizontal lines are shifted right by$k$. Then, the whole plane is shifted$k>0$units right. A generic point$(x,y)$makes a step right/left by$k$and becomes$(x+k,y)$. This is an algebraic way to present the transformation: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} (x,y)& \ra{ \text{ right } k}& (x+k,y). \end{array}$$ It is as if the algebra of the flip of the$x$-axis given previously,$x\to x+k$, is copied and paired with$y$. Exercise. What is the effect of a vertical stretch and a horizontal stretch executed consecutively? What if we change the order? These shifts can also be described a translation along the$y$-axis and a translation along the$x$-axis respectively. That is why the former only changes the$y$-coordinates of the points and the latter only the$x$-coordinates. Now a vertical flip. We lift, then flip the sheet of paper with$xy$-plane on it, and finally place it on top of another such sheet so that the$x-axes align. This flip is shown below: So, all vertical lines are flipped about their origins. Then, the whole plane is flipped about thex$-axis. A generic point$(x,y)$jumps across the$x$-axis and becomes$(x,-y)$. This is the algebraic outcome: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} (x,y)& \ra{ \text{ vertical flip } }& (x,-y). \end{array}$$ Exercise. What is the effect of two vertical flips executed consecutively? For the horizontal flip, we lift, then flip the sheet of paper with$xy$-plane on it, and finally place it on top of another such sheet so that the$y-axes align. This flip is shown below: So, all horizontal lines are flipped about their origins. Then, the whole plane is flipped about they$-axis. A generic point$(x,y)$jumps across the$y$-axis and becomes$(-x,y)$. This is the algebraic outcome: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} (x,y)& \ra{ \text{ horizontal flip } }& (-x,y). \end{array}$$ Exercise. What is the effect of a vertical flip and a horizontal flip executed consecutively? What if we change the order? These flips can also be described a mirror reflection about the$x$-axis and a mirror reflection about the$y$-axis respectively. That is why the former only changes the$y$-coordinates of the points and the latter only the$x$-coordinates. Next, a vertical stretch. The coordinate system isn't on a piece of paper anymore! It is on a rubber sheet. We grab it by the top and the bottom and pull them apart in such a way that the$x$-axis doesn't move. For example, a stretch by a factor of$2$is shown below: So, all vertical lines are stretched by$k$away from their origins. Then, the whole plane is stretched/shrunk by a factor$k>0$away from the$x$-axis. The distance of a generic point$(x,y)$from the$x$-axis grows/declines proportionally to$k$and the point becomes$(x,y\cdot k)$. This is the algebra to describe it: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} (x,y)& \ra{ \text{ vertical stretch by } k}& (x,y\cdot k). \end{array}$$ Even though the stretch is the same, the placement will vary depending on the location of the object relative to the$x$-axis: Recall that$k=0$is the collapse: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} (x,y)& \ra{ \text{ projection } }& (x,0). \end{array}$$ Since all points land on the$x$-axis, this transformation is also called the projection on the$x$-axis. Exercise. What is the effect of a vertical flip and a horizontal shift executed consecutively? What if we change the order? What about horizontal stretch? This time, we grab it by the left and right edges of the rubber sheet and pull them apart in such a way that the$y$-axis doesn't move. For example, a stretch by a factor of$2$is shown below: So, all horizontal lines are stretched by$k$away from their origins. Then, the whole plane is stretched by a factor$k>0$away from the$y$-axis. The distance of a generic point$(x,y)$from the$y$-axis grows/declines proportionally to$k$and the point becomes$(kx,y)$. This is a way describe a horizontal stretch: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} (x,y)& \ra{ \text{ horizontal stretch by } k}& (x\cdot k,y). \end{array}$$ The case$k=0$is the projection on the$y$-axis: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} (x,y)& \ra{ \text{ projection } }& (0,y). \end{array}$$ Exercise. What is the effect of a vertical flip and a horizontal flip executed consecutively? What if we change the order? Exercise. What is the effect of a vertical projection and a horizontal projection executed consecutively? These stretches can also be described a uniform deformation away from the$y$-axis and a uniform deformation away from the$y$-axis respectively. That is why the former only changes the$x$-coordinates of the points and the latter only the$y$-coordinates. These are our six basic transformations: The algebra below reflects the geometry above. $$\begin{array}{lcccclcccclcccc}\text{vertical shift: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x&,&y+k&)\end{array},&\text{flip: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x&,&y\cdot(-1)&)\end{array},&\text{stretch: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x&,&y\cdot k&)\end{array},\\ \text{horizontal shift: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x+k&,&y&)\end{array},&\text{flip: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x\cdot(-1)&,&y&)\end{array},&\text{stretch: }&\begin{array}{rlcll} (&x&,&y&)\\ (&x\cdot k&,&y&)\end{array}.\end{array}$$ Horizontal transformations don't change$y$and vertical don't change$x$! These transformations of the plane are functions of the plane to itself, i.e.,$F:{\bf R}^2\to{\bf R}^2$. For now, each of these six operations is limited to one of the two directions: along the$x$-axis or along the$y$-axis. We combine them as compositions. For example, $$\begin{array}{ccc} ...& \to & \begin{array}{|c|}\hline\quad \text{ stretch vertically by }k \quad \\ \hline\end{array} & \to & \to & \to & \begin{array}{|c|}\hline\quad \text{ flip horizontally } \quad \\ \hline\end{array} & \to &... \\ (x,y) & \mapsto & \begin{array}{|c|}\hline\quad \text{ multiply }y\text{ by }k \quad \\ \hline\end{array} & \mapsto & (x,yk) & \mapsto & \begin{array}{|c|}\hline\quad \text{ multiply }x\text{ by }(-1) \quad \\ \hline\end{array} & \mapsto & (-x,yk). \end{array}$$ We produce a variety of results: Exercise. Execute -- both geometrically and algebraically -- the following transformations: • translate up by$2$, then reflect about the$x$-axis, then translate left by$3$; • pull away from the$y$-axis by a factor of$3$, then pull toward the$x$-axis by a factor of$2$. Exercise. What sequences of transformations produce these results? Exercise. Describe -- both geometrically and algebraically -- a transformation that makes a square into a$2\times 1$rectangle. Exercise. What transformations increase/decrease slopes of lines? Exercise. Point out the inverses of each of the six transformations of the plane on the list. Exercise. Has this parabola been shrunk vertically or stretched horizontally? Recall some of the transformations of the plane we saw in Chapter 2 when we discussed symmetry. For example, the fact that the parabola's left branch is a mirror image of its right branch is revealed via a horizontal flip: $$(x,y)\mapsto (-x,y).$$ How do we represent a rotation$180$degrees around the origin? We can imagine instead we flip the plane about the$y$-axis and then about the$x$-axis (or vice versa): $$(x,y)\mapsto (-x,y)\mapsto (-x,-y).$$ However, some transformations cannot be decomposed into a composition of those six transformations! Here is, for example, a$90$-degree rotation: Exercise. Find a formula for a$90$-degree clockwise rotation. Another is a flip about the line$x=y$that appeared in the last section: It is given by $$(x,y)\mapsto (y,x).$$ Transformations of the plane are discussed in Chapter 18 and Chapter 23. Exercise. What are the inverses of the transformations presented in this section? Before addressing functions, what happens to relations under these transformations? We just execute the corresponding substitution in the formula. For example, what happens to the line $$3x-5y=7$$ under the shift$5$units left and$2$units up? We execute the substitution: $$u=x+5,\ v=y+5\,\ \text{ or }\ x=u-5,\ y=v-5.$$ This is the new line: $$3(u-5)-5(v-2)=7.$$ Now, a function $$y=f(x)\ \text{ becomes }\ (v-2)=f(u-5).$$ Are we done? Not yet, the formula for the new function is: $$v=f(u-5)+2.$$ This minus sign is something to watch out for when dealing with transformations of functions. ## 8 Change of variables The variables of the functions we are considering are quantities we meet in real life. These quantities often have multiple ways to be measured: • length and distance: inches, miles, kilometers, light years; • time: minutes, seconds, hours, years; • weight: pounds, kilograms, karats; • temperature: degrees of Celsius, of Fahrenheit; • currency: dollars, euros, pounds, yen; • etc. Example (time and temperature). Suppose we have a function$f$that records the temperature -- in Fahrenheit -- as a function of time -- in minutes. Now, what$f$should be replaced with if we want to records the temperature in Celsius as a function of time in seconds? Let's name the variables: •$s$time in seconds; •$m$time in minutes; •$F$temperature in Fahrenheit; •$C$temperature in Celsius. Then the original function is $$F=f(m),$$ and it is to be replaced with some $$C=g(s).$$ First, we need the conversion formulas for these units. First, the time. This is what we know: $$1 \text{ minute } = 60 \text{ seconds }.$$ However, this is not the formula to be used to convert$s$to$m$because these are the number of seconds and the number of minutes respectively. Instead, we have: $$m=s/60.$$ Second, the temperature: $$C=(F-32)/1.8.$$ These are the relations between the four quantities: $$g:\quad s \xrightarrow{\quad s/60 \quad} m \xrightarrow{\quad f\quad} F \xrightarrow{\quad (F-32)/1.8\quad} C.$$ The answer to our question is, we replace$f$with$g$, the composition of the above functions: $$F=g(s)=(f(s/60)-32)/1.8.$$ Note that both of the conversion formulas are one-to-one functions! That's what guarantees that the conversions are unambiguous and reversible. More precisely, we say that these functions are invertible. Indeed, for the time: $$s=60m,$$ and for the temperature: $$F=1.8C+32.$$$\square$Mathematically, we see such a transition as a change of variables. Usually, it is done one at a time: either the dependent or the independent variable. Note: We can interpret every composition as a change of variables. Example (distance). Suppose$t$is time and$x$is the location. Suppose also that function$g$represents the change of units of length, such as from miles to kilometers: $$z=g(x)=1.6x.$$ Then, the change of the units will change very little; the coefficient,$m=1.6$, is the only adjustment necessary. If$f$is the distance in miles, then$h$is the distance in kilometers:$h(t)=1.6f(t)$. Thus, all the functions are replaced with their multiples.$\square$Example (angles). Degrees and radians: $$\pi \text{ radians } = 180 \text{ degrees }.$$ Therefore, the conversion of the number of degrees$d$to the number of radians$r$is: $$r=\frac{\pi}{180}d.$$$\square$Note that all of the conversion formulas have been provided by linear functions. Then • a linear change of variables will cause the$x$-axis or the$y$-axis to shift, stretch, or flip. Therefore, from what we know about transformations of functions' graphs, • a linear change of variables will cause the graph of the function to shift, stretch, or flip. Some nonlinear changes of variables are also known. Example (non-linear). The loudness of sound (the decibel) and the magnitude of earthquakes (the Richter scale) are measured on a logarithmic scale. This scale is based on orders of magnitude rather than a linear scale, i.e., the next mark on the scale corresponds to the previous mark multiplied by a given value, such as$10$: Spreadsheet has an option to switch the scale in just a couple of clicks. For example, we can see how the graph of an exponential function becomes linear over a logarithmic scale (the$y$-axis):$\square$Exercise. Establish algebraic relation between the quantities listed in the beginning of the section. ## 9 Changing variables transforms the graphs of functions We now look at what happens to the graph of a function “drawn” on the$xy$-plane as it is being transformed. Warning: graphs aren't functions and functions aren't graphs; this is about visualization... For the six transformations, there will be six rules governing the algebra of the functions affected by them. We start with the vertical shift. Since the graph is drawn on the same piece of paper, it is shifted exactly the same way. What about the formula for the new function? Suppose a point$(x,y)$lies on the graph of$f$, then$f(x)=y$. The shifted point$(x,y+k)$lies on the graph of the new function$F$, hence$F(x)=y+k=f(x)+k$. Rule 1 (vertical shift): If the graph$y = F(x)$is the graph of$y = f(x)$shifted$k$units up, then $$F(x) = f(x) + k,$$ and vice versa. By “vice versa”, we mean that if function$g$satisfies$F(x) = f(x) + k$then its graph is the graph of$f$shifted$k$units up. The most important conclusion is the new function has the exact same shape of the graph as the old one. Next is the horizontal shift. What about the formula for the new function? Things are a bit more complicated than for a horizontal shift. Suppose a point$(x,y)$lies on the graph of$f$, then$f(x)=y$. The shifted point$(x+k,y)$lies on the graph of the new function$F$, hence$F(x+k)=y=f(x)$. Therefore, the new function is$F(x)=f(x-k)$. Example. To confirm the idea, take$f(x) = x^{2}$, and shift$2$units to the left and to the right too: $$f(x+2) = (x+2)^{2} \text{ and } f(x-2) = (x-2)^{2}.$$ To confirm the match, what is the$x$-intercept of these two new functions? Set either equal to$0$and solve: $$\begin{array}{r | l} (x + 2) ^2 = 0 & (x - 2) ^2 = 0 \\ x + 2 = 0 & x - 2=0 \\ x = -2 & x = 2\\ \text{left shift } & \text{ right shift } \end{array}$$ The shift is in the opposite direction!$\square$Rule 2 (horizontal shift): If the graph of$y = F(x)$is the graph of$y = f(x)$shifted$k$units to the right, then $$F(x) = f(x-k),$$ and vice versa. Once again, the new function has the exact same shape of the graph as the old one. This is the algorithmic interpretation of these shifts. Vertical shift, up$3$units: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & u & \mapsto & \begin{array}{|c|}\hline\quad u+3 \quad \\ \hline\end{array} & \mapsto & y; \end{array}$$ horizontal shift, left$2$units: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline\quad x+2 \quad \\ \hline\end{array} & \mapsto & u & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y. \end{array}$$ What about “combination” of these two types of transformations? Example. Let $$Q(x) = (x + 2)^{2} +4.$$ What is the graph? First, some analysis: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline\quad x+2 \quad \\ \hline\end{array} & \mapsto & u & \mapsto & \begin{array}{|c|}\hline\quad u^2 \quad \\ \hline\end{array} & \mapsto & z & \mapsto & \begin{array}{|c|}\hline\quad z+4 \quad \\ \hline\end{array} & \mapsto & y \end{array}$$ This is a$2$-unit leftward shift followed by a$4$-unit upward shift.$\square$Exercise. What happens to the$x$- and$y$-intercepts of a function under vertical and horizontal shifts? Exercise. What happens to the domain and the range of a function under vertical and horizontal shifts? Next is the vertical flip. Suppose a point$(x,y)$lies on the graph of$f$, then$f(x)=y$. The vertically flipped point$(x,-y)$lies on the graph of the new function$F$, hence$F(x)=-y=-f(x)$. Rule 3 (vertical flip): If the graph of$y = F(x)$is the graph of$y = f(x)$flipped vertically then $$F(x) = - f(x),$$ and vice versa. Again, the new function has the exact same shape of the graph as the old one. Example. Let $$Q(x) = - f(x) + 3.$$ How do we get the graph of$h$? $$x \longmapsto f(x) \underbrace{\longmapsto}_{\textrm{vertical flip}} - f(x) \underbrace{\longmapsto}_{\textrm{vertical shift}} - f(x) + 3.$$ The order matters... Let's interchange these two: $$x \longmapsto f(x) \underbrace{\longmapsto}_{\textrm{vertical shift}} f(x) + 3 \underbrace{\longmapsto}_{\textrm{vertical flip}} - (f(x)+3).$$ The graphs are also different:$\square$Next is the horizontal flip. Suppose a point$(x,y)$lies on the graph of$f$, then$f(x)=y$. The horizontally flipped point$(-x,y)$lies on the graph of the new function$F$, hence$F(-x)=y=f(x)$. Therefore,$F(x)=-f(x)$. Rule 4 (horizontal flip): If the graph of$y = F(x)$is the graph of$y = f(x)$flipped horizontally, then $$F(x) = f(-x),$$ and vice versa. Exercise. Does the order matter when the horizontal flip is combined with a horizontal shift? What about the horizontal flip with a vertical shift? Vertical flip: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & u & \mapsto & \begin{array}{|c|}\hline\quad -u \quad \\ \hline\end{array} & \mapsto & y \end{array}$$ Horizontal flip: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline\quad -x \quad \\ \hline\end{array} & \mapsto & u & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y \end{array}$$ Exercise. What happens to the$x$- and$y$-intercepts of a function under vertical and horizontal flips? Exercise. What happens to the domain and the range of a function under vertical and horizontal flips? Next is the vertical stretch. Suppose a point$(x,y)$lies on the graph of$f$, then$f(x)=y$. After a vertical stretch, the point$(x,ky)$lies on the graph of the new function$F$, hence$F(x)=ky=kf(x)$. Rule 5 (vertical stretch): If the graph of$y = F(x)$is the graph of$y = f(x)$stretched vertically by a factor of$k > 0$, then $$F(x) = kf(x),$$ and vice versa. Next is the horizontal stretch. What about the formula for the new function after the plane has been stretched, horizontally? Suppose a point$(x,y)$lies on the graph of$f$, then$f(x)=y$. After the stretch, the point$(kx,k)$lies on the graph of the new function$F$, hence$F(kx)=y=f(x)$. Therefore,$F(x)=f(x/k)$. Rule 6 (horizontal stretch): If graph$y = F(x)$is the graph of$y = f(x)$stretched by the factor$k>0$horizontally, then $$F(x) = f(x/k),$$ and vice versa. It is clear that the new function has a somewhat different shape of the graph than the old one. Example. One can stretch and shrink with image processing software:$\square$Now the algorithmic interpretation of these operations. A vertical stretch, factor$3$: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & u & \mapsto & \begin{array}{|c|}\hline\quad 3u \quad \\ \hline\end{array} & \mapsto & y \end{array}$$ A horizontal stretch, factor$2$: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline\quad x/2 \quad \\ \hline\end{array} & \mapsto & u & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y \end{array}$$ Example. It seems that vertical stretching is somehow equivalent to horizontal shrinking. Consider $$f(x) = x.$$ Stretched by a factor$2$vertically it becomes: $$F(x) = 2 x.$$ Shrunk by a factor$2$horizontally it becomes: $$Q(x) = x/\tfrac{1}{2}=2x.$$ It is the same function. However, if we do the same to$f(x)=x^2$, we discover that $$2 x^{2} \ne (2 x )^{2}!$$ Let's try the horizontal stretch by$\sqrt{2}$. Then $$H(x) = (\sqrt{2} x )^{2}.$$ Now there is a match: $$(\sqrt{2} x)^{2} =2 x^{2}.$$ We don't expect such a match for most functions; just try$f(x)=1$!$\square$This is the summary of our general analysis: the vertical transformations of the graph of a function$y=f(x)$result from compositions of$f$with functions that follow$f$, i.e.,$h\circ f$: And the horizontal transformations result from compositions of$f$with functions that precede$f$, i.e.,$f\circ g$: As we can see, such a transformation of an axis is a change of variables (or units). Every function$f$has two, input and output. Then, • in the former case, we change the output variable: from$y$to$z=h(y)$, while • in the latter case, we change the input variable: from$x$to$t=g^{-1}(x)$. This difference is the reason why the effect on the graph of$f$is so different. Exercise. What happens to the$x$- and$y$-intercepts of a function under vertical and horizontal stretches? Exercise. What happens to the domain and the range of a function under vertical and horizontal stretches? Exercise. (a) How do these transformations affect the monotonicity of a function? (b) Investigate the monotonicity of quadratic functions. Exercise. By transforming the graph of$y=x^2$, plot the graphs of the functions: (a)$y=\sqrt{x}$and (b)$y=\sqrt{x+3}$. ## 10 The graph of a quadratic polynomial is a parabola In this section, we will concentrate on a specific class of functions. We have called the graph of$y=x^2$a “parabola”. What about others? $$\begin{array}{|c|}\hline \\ \quad \text{ The graph of every quadratic polynomial is a parabola.} \quad \\ \\ \hline\end{array}$$ This is what it means. Suppose we have a quadratic polynomial, $$F(x)=ax^2+bx+c,\ a\ne 0,$$ then its graph can be acquired from the parabola of $$f(x)=x^2,$$ via our six transformations, even fewer in fact. Example (transforming a parabola). Suppose the graph of$g$is given on right. We need to transform the graph of$y=x^2$into this parabola. We start with a comparison. • The most obvious feature is that the right one opens down. We will, therefore, have to do a vertical flip. • The second most prominent feature is that the right one is slimmer. We will have do a vertical stretch or a horizontal shrink. • The last one is the location: the vertex of the parabola is away from the origin. We will have to do both vertical and horizontal shifts. Note that a horizontal flip is useless here because the parabola has a vertical mirror symmetry. Also note that we pick a vertical stretch over a horizontal shrink as a simpler one to implement. We now turn to the actual algebra. What is the order of operations? We start with the vertical: $$\begin{array}{rcl} \text{original:}& x^2\\ \text{vertical flip:}& x^2\cdot (-1)&=-x^2\\ \text{vertical stretch:}& x^2\cdot (-1)\cdot 5&=-5x^2\\ \text{vertical shift:}& x^2\cdot (-1)\cdot 5+4&=-5x^2+4\\ \text{horizontal shift:}& (x-3)^2\cdot (-1)\cdot 5+4&=-5(x-3)^2+4\\ \end{array}$$ This algebra produces the following sequence of transformations: One can also see how the data is changing as we progress through the sequence:$\square$If the polynomial is given by a formula, its standard representation, $$f(x)=ax^2+bx+c,\ a\ne 0,$$ the list of such transformations is unclear. Judging by the example, we need to morph it into the following form: $$f(x)=a(x-h)^2+k.$$ While$a$contains information about the stretch/shrink and the flip of the graph,$h$and$k$are the shifts. In fact, the point$(h,k)$is called the vertex of the parabola. Example (completing a square). Let's show how this is done algebraically. Suppose $$f(x)=2x^2+8x+3.$$ We manipulate the formula towards our goal: $$\begin{array}{ll} f(x)&=2x^2+8x+3&\text{ start with the original;}\\ &=(2x^2+8x)+3&\text{ bring together the two terms with }x;\\ &=2(x^2+4x)+3&\text{ factor, so that you have }x^2;\\ &=2(x^2+4x+2^2-2^2)+3&\text{ add (and subtract) the missing term of the square;}\\ &=2(x^2+4x+2^2)-2\cdot 2^2+3&\text{ pull out the extra term;}\\ &=2(x+2)^2-8+3&\text{ complete the square;}\\ &=2(x+2)^2-5&\text{ acquire the final form.}\\ \end{array}$$ Reading from the inside out: shift left by$2$, stretch vertically by$2$, flip vertically, shift up by$15$.$\square$Exercise. How can you transform any parabola into any other parabola? Recall the complete square formula: $$(u+v)^2=u^2+2uv+v^2.$$ A quadratic polynomial that may be called a “complete square” if it is $$f(x)=(x-h)^2=x^2+2xh+h^2.$$ It is easy to plot; just shift the original$h$units right. This idea has a broader applicability, but the challenge is to recognize complete squares in (or extract from) quadratic polynomials. THEOREM. Any quadratic function $$f(x)=ax^2+bx+c,\ a\ne 0,$$ can be represented as an “incomplete square”: $$f(x)=a(x-h)^2+k,$$ where$h,k$are for some numbers. Proof. All we need is to find these parameters:$h$and$k$. We simply set the two equal to each other: $$f(x)=ax^2+bx+c=a(x-h)^2+k=ax^2+2axh+ah^2+k.$$ We then match up the terms: $$b=2ah,\ c=ah^2+k.$$ Then, $$h=-\frac{b}{2a},\ k=c-ah^2.$$$\blacksquare$Consequently, the graph of$f$can be acquired from the graph of$y=x^2$via the six transformations, or just four if we exclude the vertical flip and the horizontal shrink. We can say that there is only one parabola! Exercise. The graphs below are parabolas. One is$y=x^2$. What is the other? In conclusion, composing a function with a linear function -- before or after -- will transform its graph in these six ways: shift, flip, and stretch, vertical or horizontal. This is the summary of the rules: $$\begin{array}{l|ll||ll} &\text{vertical, }y&&\text{horizontal, }x&\\ \hline \text{shift by }s:&y=f(x)&+s&y=f(x&-s)\\ \text{flip }:&y=f(x)&\cdot(-1)&y=f(x&\cdot(-1))\\ \text{stretch by }k:&y=f(x)&\cdot k&y=f(x&/k)\\ \end{array}$$ What is behind these pairs of transformations we see above? Compare these: • add$s$vs. subtract$s$; • multiply by$(-1)$vs. multiply by$(-1)$; • multiply by$k>0$vs. divide by$k$. They are inverses of each other. Inverses appeared every time we solved an equation to find the formula for the new function,$F$, after a change of the input variable (i.e., a horizontal transformation) of a function$f$. For example, if we have$F(x+k)=f(x)$after a horizontal shift, we substitute$u=x+k$and find$x$in terms of$u$, i.e.,$x=u-k$, resulting in$F(u)=f(u-k)$. After an optional renaming,$u$for$x$, the formula takes its final form,$F(x)=f(x-k)$. Exercise. The graph drawn with a solid line is$y=x^3$. What are the other two? Exercise. The graph below is the graph of the function$f(x)=A\sin x+B$for some$A$and$B$. Find these numbers. Exercise. The graph of the function$y=f(x)$is given below. Sketch the graph of$y=2f(x)$and then$y=2f(x)-1$. ## 11 The algebra of compositions Functions can be visualized as flowcharts and so can be their compositions: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline\quad x+3 \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad y\cdot 2 \quad \\ \hline\end{array} & \mapsto & z & \mapsto & \begin{array}{|c|}\hline\quad z^2 \quad \\ \hline\end{array} & \mapsto & u \end{array}$$ Note how the names of the variables match so that we can proceed to the next step. An algebraic representation of the diagram is below: $$y=x+3,\quad z=y\cdot 2,\quad u=z^2.$$ It is also possible but not required to name the functions, say$f,g,h$. Then we have: $$y=f(x)=x+3,\quad z=g(y)=y\cdot 2,\quad u=h(z)=z^2.$$ As we see, with the variables properly named, composition is substitution, Indeed, • we substitute$z=g(y)=y\cdot 2$into$u=h(z)=z^2$, which results in the following: $$u=h(z)=h(g(y)), \quad u=z^2=(y\cdot 2)^2.$$ • we substitute$y=f(x)=x+3$into$z=g(y)=y\cdot 2$, which results in the following: $$z=g(y)=g(f(x)), \quad z=y\cdot 2=(x+3)\cdot 2.$$ In general, we represent a function$f$diagrammatically as a black box that processes the input and produces the output: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} \text{input} & & \text{function} & & \text{output} \\ x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y \end{array}$$ Now, what if we have another function$g$: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} \text{input} & & \text{function} & & \text{output} \\ x & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & y \end{array}$$ How do we represent their composition$g \circ f$? To represent it as a single function, we need to “wire” their diagrams together consecutively: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{ccccccccccccccc} x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y& \ne & x & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & y \end{array}$$ But its only possible when the output of$f$coincides with the input of$g$. We can rename the variables of$g$. Warning: If the names of the variables don't match, it might be for a good reason. In that case, do nothing. This is what we have after renaming: $$\begin{array}{ccccccccccccccc} & x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & z \end{array}$$ Then we have a diagram of a new function: $$\begin{array}{ccccccccccccccc} g\circ f:& x & \mapsto & \begin{array}{|c|}\hline x & \mapsto & \begin{array}{|c|}\hline\quad f \quad \\ \hline\end{array} & \mapsto & y & \mapsto & \begin{array}{|c|}\hline\quad g \quad \\ \hline\end{array} & \mapsto & z \\ \hline\end{array} & \mapsto & z \end{array}$$ It's just another black box: $$\begin{array}{ccccccccccccccc} & x & \mapsto & \begin{array}{|c|}\hline \quad g\circ f \quad \\ \hline\end{array} & \mapsto & z \end{array}$$ Compositions are meant to represent tasks that cannot be carried out in parallel. If you have two persons working for you, you can't split the work in half to have them work on it at the same time as the second task cannot be started until the first is finished. Example. For example, you are making a chair. The last two stages are polishing and painting. You can't do them at the same time: $$\begin{array}{ccccccccccccccc} & \text{ chair } & \mapsto & \begin{array}{|c|}\hline\quad \text{ polishing } \quad \\ \hline\end{array} & \mapsto & & \mapsto & \begin{array}{|c|}\hline\quad \text{ painting } \quad \\ \hline\end{array} & \mapsto & \text{ finished chair } \end{array}$$ You can't change the order either!$\square$Example. Below the instructions of the function is “push these buttons” (in that order): These are the functions: $$\frac{1}{x^2},\ \sqrt{x+6},\ -\left( x^2 \right)^2.$$$\square$Example. The composition of $$g(x)=x^2 \text{ and } f(x)=x+2$$ is in fact the composition of $$z=g(y)=y^2 \text{ and } y=f(x)=x+2,$$ after renaming. Then we just substitute the latter into the former: $$(g\circ f)(x)=g(f(x))=g(x+2)=(x+2)^2.$$$\square$Just as with the rest of the algebraic operations, we sometimes want to “reverse” composition. By doing so, we decompose the given function into two (or more) simpler parts that can then be addressed separately. Example. Represent$z = h(x) = \sqrt[3]{x^{2} + 1 }$as the composition of two functions: $$x \mapsto y=x^{2} + 1 \mapsto z=\sqrt[3]{y} .$$ To confirm, substitute back...$\square$Example. Decompose: $$y=\sin(t^2+1).$$ The presence of parentheses is a clue that what's inside may be our new variable: $$x=t^2+1.$$ We substitute that into the original: $$y=\sin(x).$$ Done! For completeness, we can name the functions: $$x=f(t)=t^2+1,\ y=g(x)=\sin x\ \Longrightarrow\ h(t)=(g\circ f)(t)=\sin(t^2+1).$$$\square$Example. Decompose: $$y=\frac{t^2+1}{t^2-1}.$$ There are no parentheses to use as a clue here but what if we choose the numerator (the same formula as in the last example) as our new variable: $$x=t^2+1.$$ We substitute that into the original: $$y=\frac{x}{t^2-1}.$$ Not done! The substitution remains unfinished because there is still$t$left. Solving a simple equation, we conclude: $$t^2-1=x-2.$$ Then, $$y=\frac{x}{x-2}.$$ Now we are done. Just as valid, but simpler, choice is $$x=t^2;$$ then $$y=\frac{x+1}{x-1}.$$ What can we say about the choice $$x=\frac{t^2+1}{t^2-1}?$$ The new function is the same as the original. Such a decomposition is, though technically correct, is pointless as it provides no simplification.$\square$Exercise. Decompose$y=\frac{1}{t^2+1}.$There may be more than two functions involved in compositions. Example. Suppose a car is driven at$60$m/h. Suppose we also know that the car uses$30$m/gal, while the cost per gallon is$\$5$. Represent the expense as a function of time.

Analysis: $$\begin{array}{ccc} \text{time (hours)}& \xrightarrow{\ 60\text{ m/h }\ }& \text{distance (miles)}&\xrightarrow{\ 30\text{ m/gal }\ }& \text{gas used (gal)}& \xrightarrow{\ \ 5/ \text{ gal }}&\text{expense } (\) \\ t& \xrightarrow{\ f\ }& d&\xrightarrow{\ k\ }& g& \xrightarrow{\ h\ }&e \\ \end{array}$$ The functions: $$d = f(t) = 60t, \ g = k(d) = \frac{d}{30}, \ e = h(g) = 5g.$$ Substitution: $$\begin{array}{ll} g = k(d) & = k(f(t)) \\ e = h(g) & = h(k(d)) \\ & = h(k(f(t))) \end{array}$$ $\square$

Example. Find $f(g(x))$ and $g(f(x))$ with: $$f(x) = x^{2}\text{ and } g(x) = \cos x.$$ The problem may represent a challenge because the variables don't match!

First, to find $f(g(x))$, first re-write: $$f(y) = y^{2}\text{ and } y=g(x) = \cos x.$$ Then replace (substitute) $y$ in $f$ with $(\cos x )$, always with parentheses: $$y^{2} \leadsto ( \cos x )^{2},$$ or $\cos^{2} x$.

Second, to find $g(f(x))$, first re-write: $$y=f(x) = x^{2}\text{ and } g(y) = \cos y.$$ Then replace $y$ in $g$ with $(x^{2})$: $$\cos y \leadsto \cos (x^{2}).$$ $\square$

Example. When the two functions are represented by their tables of values, the composition can be computed just as with the rest of algebraic operations (as discussed later). It is more complex as we cannot simply go row by row adding the values. One has to find the right entry in the next function.

Suppose we need to compose these two functions: $$\begin{array}{c|cc} t&x=f(t)\\ \hline 0&1\\ 1&2\\ 2&3\\ 3&0\\ 4&1 \end{array}\quad \circ \quad \begin{array}{c|cc} x&y=g(x)\\ \hline 0&5\\ 1&-1\\ 2&2\\ 3&3\\ 4&0 \end{array}\quad=\quad ?$$ The result should be another table of values for the function $h=g\circ f$. To fill this table, we watch where every $t$ goes, after two steps: under $f$ we have $0\mapsto 1$, where does $1$ go under $g$? We look at the second table: under $g$ we have $1\mapsto -1$. Therefore, under $h$ we have $0\mapsto -1$. That gives us the first row in the new table. Furthermore: $$f:1\mapsto 2\quad g:2\mapsto 2\quad \Longrightarrow\ h:1\mapsto 2.$$ And so on. Some are shown below: $$\begin{array}{c|rcl|cll} t&x&&x&y\\ \hline 0&1&\searrow&0&5\\ 1&2&\searrow&1&-1& \Longrightarrow\ 0\mapsto -1\\ 2&3&\searrow&2&2& \Longrightarrow\ 1\mapsto 2\\ 3&0&&3&3& \Longrightarrow\ 2\mapsto 3\\ 4&1&&4&0 \end{array}$$ And this is the answer: $$\begin{array}{c|cc} t&x=f(t)\\ \hline 0&1\\ 1&2\\ 2&3\\ 3&0\\ 4&1 \end{array}\quad \circ \quad \begin{array}{c|cc} x&y=g(x)\\ \hline 0&5\\ 1&-1\\ 2&2\\ 3&3\\ 4&0 \end{array}\quad =\quad \begin{array}{c|cc} t&y=g(f(t))\\ \hline 0&-1\\ 1&2\\ 2&3\\ 3&5\\ 4&-1 \end{array}$$

$\square$

Functions represented by graphs can also be composed. The procedure is, however, more convoluted than for the rest of the algebraic operations.

Example. Suppose a car is driven through a mountain terrain. The location, as seen on a map, is known and so is the altitude for each location.

We set up two functions, for location and altitude, and their composition is what we are interested in:

The second function is literally the profile of the road.

Here,

• $t$ is time measured in $\text{hr}$;
• $x=f(t)$ is the location of the car as a function of time -- measured in $\text{mi}$;
• $y=g(x)$ is the altitude of the road as a function of (horizontal) location -- measured in $\text{ft}$; and
• $y=h(t)=g(f(t))$ is the altitude of the road as a function of time -- measured in $\text{ft}$.

$\square$

This is the familiar way to evaluate a function: $$f(x)=x^2-x\ \Longrightarrow\ f(3)=3^2-3.$$ There is also an alternative notation for substitution: $$f(x)=x^2-x\ \Longrightarrow\ f(3)=x^2-x\Bigg|_{x=3}=3^2-3.$$ This notation also applies to compositions. For example,

• we substitute $z=g(y)=y\cdot 2$ into $u=h(z)=z^2$, which results in the following:

$$u=z^2\Bigg|_{z=y\cdot 2}=(y\cdot 2)^2.$$

• we substitute $y=f(x)=x+3$ into $z=g(y)=y\cdot 2$, which results in the following:

$$z=y\cdot 2\Bigg|_{y=x+3}=(x+3)\cdot 2.$$

## 12 Solving equations

As explained in Chapter 2, to solve an equation with respect to $x$ means to find all values of $x$ that satisfy the equation. In other words, when we substitute those values into the equation we have a true statement. For example, consider how this equation is solved: $$x+2=5\ \Longrightarrow\ x=3.$$ This is an abbreviated version of the following statement:

• if $x$ satisfies the equation $x+2=5$ then $x$ satisfies the equation $x=3$.

Plug in: $$x+2=(3)+2=5.$$ It checks out! We could try others and they won't check out: $$\begin{array}{ll} x=0&(0)+2=2\ne 5&\text{No!}\\ x=1&(1)+2=3\ne 5&\text{No!}\\ x=2&(2)+2=4\ne 5&\text{No!}\\ x=3&(3)+2=5= 5&\text{Yes!}\\ x=4&(4)+2=6\ne 5&\text{No!}\\ \end{array}$$ Of course, this trail-and-error method is unfeasible because there are infinitely many possibilities.

A method of how we may arrive to the answer is discussed in this section.

As a reminder, in the special case when the right-hand side of the equation is zero, a solution to this equation has a clear geometric meaning: an $x$-intercept of a numerical function $f$ is any solution to the equation $f(x)=0$. In other words, these are the $x$-coordinates of the intersections of the graph with the $x$-axis:

When the right-hand side is a number, say, $k$, a solution to this equation $f(x)=k$ gives us an intersection of the graph with the line $y=k$.

Our interest in this section is algebra though... We will address a simple kind of equation:

• $x$ is present only once, in the left-hand side.

Starting with such an equation, our goal is -- through a series of manipulations -- to arrive to an equation with an isolated $x$. In other words, we will have only $x$ on the left and no $x$ on the right, like this: $$x=\sqrt{17}.$$

Warning: this is an equation.

Suppose we see a single $x$ “wrapped” in several layers of functions: $$3\cdot\left( \frac{\sqrt{x}}{4}+1\right)=6.$$ It's a composition of several functions applied to $x$. To get to it, we will need to remove these layers one by one. In what order? From the outside in, of course. We reverse the flowchart: $$\begin{array}{ccc} x & \to & \begin{array}{|c|}\hline\ \text{ root } \ \\ \hline\end{array} & \to & \begin{array}{|c|}\hline\ \text{divide by }4 \ \\ \hline\end{array} & \to & \begin{array}{|c|}\hline\ \text{add }1 \ \\ \hline\end{array} & \to & \begin{array}{|c|}\hline\ \text{multiply by }3 \ \\ \hline\end{array} & \to &6&;\\ x & \leftarrow & \begin{array}{|c|}\hline\ \text{ square } \ \\ \hline\end{array} & \leftarrow & \begin{array}{|c|}\hline\ \text{multiply by }4 \ \\ \hline\end{array} & \leftarrow & \begin{array}{|c|}\hline\ \text{subtract }1 \ \\ \hline\end{array} & \leftarrow & \begin{array}{|c|}\hline\ \text{divide by }3 \ \\ \hline\end{array} & \leftarrow &6&.\\ \end{array}$$ So, $x=\pm 2$!

Warning: this plan does not work for many familiar types of equations including quadratic equations.

The main idea is as follows:

• we apply a function to both sides of the equation producing a new equation.

For example, if we have an equation, say, $$x+2=5,$$ we treat it as a number, call it $y$. Then we deal with this number: $$y=x+2=5,\ \text{ apply }z=y-2\ \Longrightarrow\ (x+2)-2=3-2\ \Longrightarrow\ x=3.$$ The idea is to produce -- from an equation satisfied by $x$ -- another equation satisfied by $x$.

However, the challenge is that any function will produce a new equation! $$\begin{array}{lll} y=x+2=5,& \text{apply }z=y+2& \Longrightarrow\ (x+2)+2=5+2& \Longrightarrow\ x+4=7;\\ y=x+2=5,& \text{apply }z=y^2& \Longrightarrow\ (x+2)^2=5^2;\\ y=x+2=5,& \text{apply }z=\sin y& \Longrightarrow\ \sin (x+2)=\sin 5. \end{array}$$ Indeed, it is the definition of a function that every input has exactly one output. Therefore, two equal inputs (an equation) produce -- under $f$ -- two equal outputs (another equation), always: $$\newcommand{\ra}[1]{\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\la}[1]{\!\!\!\!\!\xleftarrow{\quad#1\quad}\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \newcommand{\ua}[1]{\left\uparrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} \begin{array}{ccc} \text{old equation:}&a& = &b\\ &\da{g}& &\da{g}\\ \text{new equation:}&g(a) & = &g(b) \end{array}$$ So, we have, for any function $g$: $$x+2=5\ \Longrightarrow\ g(x+2)=g(5).$$ That is why if the first equation is satisfied by $x$ then so does the second.

There are infinitely many possibilities for this function $g$ then: $$\begin{array}{rrcll} x+4=7 & & (x+2)^2=5^2 & & \sin (x+2)=\sin 5\\ & \nwarrow & \uparrow & \nearrow\\ x+5=8 & \leftarrow & \begin{array}{|c|}\hline \quad x+2=5 \quad \\ \hline\end{array} & \to & 2^{x+2}=2^5\\ & \swarrow & \downarrow & \searrow\\ x+6=9 & & (x+2)^3=5^3 & & \sqrt{x+2}=\sqrt{5}\\ \end{array}$$ If $x$ satisfies the equation in the middle, it also satisfies the rest of the equations.

If we want to solve the original equation, which function -- out of infinitely many -- do we pick? Some of them clearly make the equation more complex than the original! It is the challenge for the equation solver to have enough foresight to choose a function to apply that will make the equation simpler.

If between us and $x$ there is a function, we would like to remove it. How? The answer is, apply the inverse of the function that we face! We have for our equation: $$x\mapsto f(x)=x+2\ \Longrightarrow\ f^{-1}(y)=y-2.$$

Is applying the inverse of the function that contains $x$ in the equation a fool-proof plan? No. Try this: $$x^2=1, \text{ apply } z=\sqrt{y}\ \Longrightarrow\ \sqrt{x^2} =\sqrt{1}\ \Longrightarrow\ x=1??$$ We have lost $x=-1$! It satisfies the first equation but not the last. What happened? There is nothing wrong with the logic of applying the inverse and producing a new equation satisfied by $x$; however, the cancellation of the function and its “inverse” was incorrect. The square and the square root are inverses of each other (and cancel) only, separately, on the rays $[0,+\infty)$ and $(-\infty, 0]$. We disregarded the latter of these two cases: $$\text{case 1: }\ x\ge 0\ \Longrightarrow\ \sqrt{x^2}=x,\quad \text{case 2: }\ x\le 0\ \Longrightarrow\ \sqrt{x^2}=-x.$$ We can point out exactly why this failed; the function isn't one-to-one!

Example. What if we have several functions applied consecutively to $x$? Which function do we choose to apply? In the equation, $$5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)-17=3,$$ the last operation on the left is $-17$. That's the function we face and the inverse of this function is applied. We choose: $$f(z)=z-17,$$ where $$z=5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big).$$ Then we apply $$f^{-1}(y)=y+17.$$ We conclude: $$z-17=3\ \Longrightarrow\ (z-17)+17=3+17\ \Longrightarrow\ z=20.$$ We have a new equation now: $$5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)=20.$$ As we progress, we apply the inverse of the function that appear first in the equation (i.e., it is applied last). We have the following sequence of steps “unwrapping” the parentheses one pair at a time: $$\begin{array}{lclc} 5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)=20& \Longrightarrow&5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)/5=20 /5&\Longrightarrow&\\ \left( \frac{x}{2}+1\right)^2+3 =4 &\Longrightarrow&\left( \frac{x}{2}+1\right)^2+3-3 =4-3 &\Longrightarrow&\\ \left( \frac{x}{2}+1\right)^2 =1 &\Longrightarrow&\sqrt{\left( \frac{x}{2}+1\right)^2} =\sqrt{1} &?\Longrightarrow?&\\ \frac{x}{2}+1 =1 &\Longrightarrow&\frac{x}{2}+1-1 =1-1&\Longrightarrow& \\ \frac{x}{2} =0 &\Longrightarrow&\frac{x}{2} \cdot 2=0\cdot 2 &\Longrightarrow&\\ x =0. \\ \end{array}$$ But $x=-4$ is also a solution! What happened? We disregarded the latter of these two cases: $$\text{case 1: }\ z\ge 0\ \Longrightarrow\ \sqrt{z^2}=z,\quad \text{case 2: }\ z\le 0\ \Longrightarrow\ \sqrt{z^2}=-z.$$ We then re-do the solution starting at the question mark. The equation produces two cases: $$\begin{array}{rcl} &\sqrt{\left( \frac{x}{2}+1\right)^2} =\sqrt{1}\\ \swarrow&&\searrow\\ \end{array}$$ $$\begin{array}{lll|c|ll} z=\frac{x}{2}+1\ge 0&&&\texttt{ OR }&z=\frac{x}{2}+1\le 0\\ \hline \left( \frac{x}{2}+1\right)^2 &=1 &\Longrightarrow&\texttt{ OR }&-\left( \frac{x}{2}+1\right)^2 &=1 &\Longrightarrow&\\ \frac{x}{2}+1 &=1 &\Longrightarrow&\texttt{ OR }&\frac{x}{2}+1 &=-1 &\Longrightarrow \\ \frac{x}{2} &=0 &\Longrightarrow&\texttt{ OR }&\frac{x}{2} &=-2 &\Longrightarrow&\\ x &=0&&\texttt{ OR }&x&=-4. \\ \end{array}$$ Both $x=1$ and $x=-4$ satisfy their respective conditions. Therefore, the solution set is $\{1,-4\}$... unless we have missed a few solutions on the way! The issue is addressed in this section. $\square$

Exercise. Solve the equation: $$5\cdot\Big( \left( \frac{x^2}{2}+1\right)^2+3 \Big)-17=3.$$

Exercise. Solve the equation: $$\left( 5\cdot\Big( \left( \frac{x}{2}+1\right)^2+3 \Big)-17\right)^3=27.$$ Make up your own equation and solve it. Repeat.

Is applying the inverse of the function that contains $x$ in the equation -- making sure that it is one-to-one -- a fool-proof plan? No. Try this: $$\sqrt{x}=-1, \text{ apply } z=y^2\ \Longrightarrow\ \left( \sqrt{x} \right)^2 =(-1)^2\ \Longrightarrow\ x=1??$$ We have a solution where there is none! It satisfies the last equation but not the first. What happened? There is nothing wrong with our logic; however, the cancellation of the function and its “inverse” was incorrect, once again. The square and the square root are inverses of each other (and cancel) only, separately, on the rays $[0,+\infty)$ and $(-\infty, 0]$. We can point out exactly why this failed; the function isn't onto!

Example. Consider the equation: $$\sqrt{x+1}=3.$$ Examining the equation, we see $x$ on left only and it is subjected to two functions, the last of which is the square root. Therefore, to make a step toward isolating $x$, square both sides: $$\left( \sqrt{x+1} \right)^2=3^2.$$ If we were to cancel the two functions on left as inverses, we get this new equation: $$x+1=9.$$ The solution is $x=8$... but was the cancellation valid? We just need to confirm that the solution falls within the domain -- $x+1\ge 0$ -- of the original equation. It does. $\square$

Exercise. Solve the equation: $$\sqrt{x^2+1}=3.$$

Exercise. Solve the equation: $$5\sqrt{x+1}=3.$$ Make up your own equation and solve it. Repeat.

Using only invertible functions ensures that we don't lose solutions or gain non-solutions. This is why this approach will often allow us to enhance our solution method: from

• “if $x$ satisfies an equation then it satisfies the next”, to
• “$x$ satisfies an equation if and only if it satisfies the next”.

In other words, the latter contains both the former and its converse!

The advantage of this approach is that the equations will have the same solution set as we progress through the stages. For example, this how we would rather present the solution of the very first equation in this section: $$x+2=5\ \Longleftrightarrow\ x=3.$$ This is an abbreviated version of the following statement:

• $x$ satisfies $x+2=5$ if and only if $x$ satisfies $x=3$.

Repeated as many times as necessary, the solution set of each equation is the same as that of the original equation!

Example. Two complete solutions are below: $$\begin{array}{lll} 2(x+2)-3=5x\ \Longleftrightarrow\ 2x+4-3=5x\ \Longleftrightarrow\ -3x=-1\ \Longleftrightarrow\ x=1/3;\\ x^2+1=0\ \Longleftrightarrow\ x^2=-1\ \Longleftrightarrow\ \emptyset. \end{array}$$ $\square$

So, to solve the type of equation we face -- a variable $x$ subjected to a sequence of functions -- we apply the inverses of these functions in the reversed order. We may have to split the domains of the functions so that they are both one-to-one and onto. As we have seen, this step also splits our equation.

Example. A solution is below: $$\begin{array}{lll} x^2=1\ \Longleftrightarrow\ x=-1\ \texttt{ OR }\ x=1. \end{array}$$ $\square$

Exercise. Solve the equation in this manner: $$\sqrt{x+1}=3.$$

Exercise. Solve the equation in this manner: $$\sqrt{x^2+1}=3.$$ Make up your own equation and solve it. Repeat.

Example. What if, instead of a single $x$, we face an expression that depends on $x$? For example, we might face this: $$5\cdot\Big( \left( x^2+x+1\right)^2+3 \Big)-17=3.$$ But what is an “expression” if not just another variable, $y=x^2+x+1$, represented (expressed) as a function of $x$. To make this choice clear, we substitute: $$5\cdot\Big( (y)^2+3 \Big)-17=3.$$ In that we case, we go after this variable, $y$, by following the same plan as before: remove these layers one by one. Once $y$ is found (as in the example), you have a much simpler equation, or equations, for $x$: $$x^2+x+1 =1\ \texttt{ OR }\ x^2+x+1=-4.$$ $\square$

Exercise. Finish the solution. Make up your own equation and solve it. Repeat.

Example. Another solution is below: $$\begin{array}{lll} \sqrt{x^2-3x+2}=0\ \Longleftrightarrow\ \sqrt{y}=0\ \texttt{ AND }\ y=x^2-3x+2\\ \Longleftrightarrow\ y=0\ \Longleftrightarrow\ x^2-3x+2=0\ \Longleftrightarrow\ x=2\ \texttt{ OR }\ x=1. \end{array}$$ $\square$